texas-ranger
v0.2.0
Published
Walks through a directory looking for files.
Downloads
4
Maintainers
Readme
Texas Ranger
This is an npm module for walking directories. Get it?
API
find
Asynchronously finds files in a directory with a given extension.
Parameters:
- {String}
directory
- the directory to search - {String}
extension
- the file extension to look for - {Boolean}
recursive
- search sub-directories - {Function}
callback
- {Error}
err
- error encountered ornull
- {String[]}
files
- an array of the files
- {Error}
Returns: {undefined}
var txRng = require('texas-ranger');
txRng.find('some-dir', 'txt', false, function (err, files) {
if (!err && files) {
console.log(files);
}
});
getExtension
Returns the extension of a given file in lowercase.
Parameters:
- {String}
file
Returns: {String}
var txRng = require('texas-ranger');
txRng.getExtension('foo.bAr'); // 'bar'
isExtension
Test a file to see if it has an extension.
Parameters:
- {String}
file
- {String}
extension
Returns: {Boolean}
var txRng = require('texas-ranger');
txRng.isExtension('foo.bAr', 'BaR'); // true
txRng.isExtension('foo', 'baz'); // false
settings
Settings can be changed to affect how results are returned.
settings.get
Getter for settings value.
Parameters:
- {String}
name
Returns: {String/Boolean/Number}
var txRng = require('texas-ranger');
txRng.settings.get('some-value');
settings.set
Setter for settings value.
Parameters:
- {String}
name
- {String/Boolean/Number}
value
Returns: {undefined}
var txRng = require('texas-ranger');
txRng.settings.set('some-value', 1234);
txRng.settings.get('some-value', 1234); // 1234