Base classes and toolkit for asimov.js
$ npm install asimov-core
Klass is a base class, which all other classes build on, and it is itself mostly a wrapper for the EventEmitter in wunderbits.core.
var Klass = Klass;var MyClass = moduleexports = Klass;
If you've worked with Backbone or wunderbits.core before, the API for binding to and triggering events should feel very familiar.
var theThing = ;theThing;theThing;
Klass and all of its child classes comes with a convenient method for typechecking.
var MyClass = moduleexports = Klass;
A class can implement a public interface by defining an array of method names. Useful for singleton, top-level modules.
var MyClass = Klass;var instance = ;moduleexports = instance;
The logger class wraps console log to provide namespacing, task durations and more than one log level.
var Logger = Logger;var logger = ;logger;
var started = ;;
These logs will only appear if
All synchronous filesystem abstraction, providing shortcuts for common use cases.
var Filesystem = require('asimov-core').Filesystem;var fs = new Filesystem();
fs.exists (string path)Check if path exists, returns true or false.
fs.cleanDirectory (string path)Recursively delete everything in path.
fs.copyDirectoryIfExists (string srcPath, string destPath)If source path exists, copy it to destination and return true. If source path doesn't exist, returns false.
fs.findFirstMatch (string grep, array paths)Returns the path of the first file found matching the string grep, or false if no file was found.
fs.forceExists (string path)Force a folder path to exist.
fs.getStats (string path)Return the stat object for path.
fs.isDirectory (string path)Returns true if path is a directory, otherwise false.
fs.hasFileExtension (string filename, string extension)Check if filename has the expected extension, returns true or false.
fs.readDirectory (string path, function iterator)If path exists, execute iterator with path of each file and return true. If path doesn't exist, returns false.
fs.readFile (string path)Read and return file.
fs.rebuildDirectory (string path)Delete a folder and recreate it as empty.
fs.recursiveDelete (string path)Walks a tree, deletes all files and folders.
fs.recursiveForFolders (string path, function iterator)Execute iterator for all folders in path, top down.
fs.watchTree (string path, function handler)Watch path for added, removed and modified files using watchdirectory. Returns a function that can be called to stop watching the path.
fs.writeFile (string path, value)Write value to file at path.
A small wrapper for child_process. Documentation coming soon!