text-file-register
v0.2.1
Published
Adds text files into a js object with file path as key. Used for quick lookup of file contents.
Downloads
334
Readme
File register
Adds text files into a js object with file path as key. Used for quick lookup of file contents.
var fileRegister = require('text-file-register');
var register = fileRegister();
register.addFiles('./files/**/*.txt', function(){});
register.addFiles('./files/*.txt', function(){
var contents = register.getFile('files/test.txt');
console.log(contents);
});
register.addFiles('./files/*.txt', function(){
var obj = register.getAll();
console.log(obj);
// { '/path/to/file.txt': 'my text', '/path/to/file2.txt': 'my text' }
});
API
addFiles(["multi-glob", "patterns"], function(){});
getFile('path/to/file.txt');
getAll();