texas-ranger

Created: 2014-05-18 23:23
Updated: 2014-05-20 03:21

README.md

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 or null
    • {String[]} files - an array of the files

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
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more