File Register
(Node.js) The way we organize code: break into files and folders and map to an object.
Originally part of Carcass.
How to use
First you wanna organize your files with directories. For example say you have a group of files and directories look like this:
example/
index.js
lib/
utils.js
models/
User.js
...
views/
index.js
...
...
Quick usage
Put this in the index.js
file:
var Register = ;var example = ;example;
Now you have everything in lib/
mapped to the example.lib
object.
examplelibshouldhave;examplelibshouldhave;examplelibshouldhave;
Some details (about the above example)
For files, the key is the filename without the extension, and the value is what you can get with require(file)
(i.e. whatever the file exports).
examplelibshouldhavewithtype'object';examplelibutilsshouldhavewithtype'function';
For directories, if require()
can handle it (i.e. there's an index.js
or package.json
etc.), we use require()
.
examplelibshouldhavewithtype'string';
Otherwise the directory is mapped recursively.
examplelibshouldhavewithtype'object';examplelibmodelsshouldhavewithtype'function';
For advanced usage, see
test/example/
test/example.mocha.js
Git summary
project : file-register
repo age : 1 year, 1 month
active : 7 days
commits : 18
files : 17
authors :
18 Makara Wang 100.0%