Require a directory of modules and apply a function on module.exports
JavaScript
Latest commit a66fd85 Apr 3, 2014 @landau add custom regex
Permalink
Failed to load latest commit information.
fixtures implemented Mar 26, 2014
.gitignore Initial commit Mar 26, 2014
.jshintrc implemented Mar 26, 2014
.travis.yml implemented Mar 26, 2014
LICENSE implemented Mar 26, 2014
README.md add custom regex Apr 3, 2014
index.js add custom regex Apr 3, 2014
package.json add custom regex Apr 3, 2014
test.js add custom regex Apr 3, 2014

README.md

Build Status

map-require

Require a directory of modules and apply a function on module.exports

function mapRequire(dir, fn, ctx) { }

Install

npm i -S map-require

Usage

var path = require('path');
var is = require('is-predicate');
var assert = require('assert');

var mapRequire = require('map-require');
var FIXTURES = path.join(__dirname, 'fixtures');

var arr = mapRequire(FIXTURES, property('name'));
assert(is.array(arr));
assert(arr.indexOf('Charmander') > -1);
assert(arr.indexOf('Pikachu') > -1);

// override regex
var arr = mapRequire(FIXTURES, property('name'), null, /[^pikachu].js$/);
assert.equal(arr.length, 1);
assert(arr.indexOf('Charmander') > -1);
assert.equal(arr.indexOf('Pikachu'), -1);

Changelog

0.0.5

  • Added ability to override internal RegExp as 4th param

0.0.2 - 0.0.4

  • Bug fixes

0.0.1

  • Initial releaset