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 instance -
path
: 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 path -
opts
:-
cwd
: String - working directory to search (defaults to global option) -
type
: String - type to load as from files -
name
: Function(path) - that should return the name to use -
named
: Boolean - Should names be added to deps -
preload
: 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 path -
opts
:-
cwd
: working directory to search (defaults to global option) -
type
: type to load as from files -
ref
: 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});