README
Deps Documentation
Types
- class (c)
- function (fn, f)
- instance (i)
new Deps(opts)
opts:
type
: type used if none is specified (defaults to class)cwd
: current working directory (defaults to process.cwd())
deps.add(name, value, opts)
This is used to add dependencies to the deps system.
It will be accessible at Deps.[name]
.
Opts:
preload
: load immediately [default: false]type
: type of value: class, function, or instancepath
: boolean if src with be a path to require. If so module.exports will be used as value [default: false]
deps.addFiles(glob_pattern, opts)
Uses glob pattern to add files.
Params
path
: glob pathopts
:cwd
: String - working directory to search (defaults to global option)type
: String - type to load as from filesname
: Function(path) - that should return the name to usenamed
: Boolean - Should names be added to depspreload
: Boolean - Should deps be preloaded (will be in undetermined order)
deps.glob(path, opts)
Load many values from files. Does not put as properties on deps object. (The file can do it themselves if they would like)
Params
path
: glob pathopts
:cwd
: working directory to search (defaults to global option)type
: type to load as from filesref
: path on module to get value
Usage
let deps = new Deps({default_type: 'class', cwd:__dirname,});
deps.add('config', require('config'), {type: 'function'})
.add('app', require('app'))
.add('random_object', {all_of:'the_data'}, {type: 'instance'})
.glob('**/*.load.js', {cwd: __dirname});