Package Exports
- map-files
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (map-files) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
map-files 
Return an object for a glob of files. Pass a
renamefunction for the keys, or aparsefunction for the content, allowing it to be used for readable or require-able files.
Install
Install with npm:
npm i map-files --save-devRun tests
npm testUsage
var mapFiles = require('map-files');
console.log(mapFiles('lib/*.txt'));Returns an object that looks something like:
{ a: { path: 'test/fixtures/a.txt', contents: 'This is file a.txt.' },
b: { path: 'test/fixtures/b.txt', contents: 'This is file b.txt.' },
c: { path: 'test/fixtures/c.txt', contents: 'This is file c.txt.' } }API
mapFiles
patterns{String}: Glob patterns to pass to globbyopts{Object}: Options for globby, or pass a customparseorrename.returns: {Object}
Return an object for all files matching the
given patterns and options. The basename
of the file is used as the key.
Examples
options.rename
Pass a rename function to be used as the key of each file object:
var files = mapFiles('lib/*.txt', {
rename: function (filepath) {
return path.basename(filepath);
}
});
console.log(files);Returns something like:
{ 'a.txt': { path: 'test/fixtures/a.txt', contents: 'This is file a.txt.' },
'b.txt': { path: 'test/fixtures/b.txt', contents: 'This is file b.txt.' },
'c.txt': { path: 'test/fixtures/c.txt', contents: 'This is file c.txt.' } }options.parse
Pass a parsing function to change the object returned for each file. The
default function reads files and returns a string. This example shows how
you might instead require each file.
var files = mapFiles('lib/*.txt', {
parse: function (filepath) {
return {
path: filepath,
fn: require(path.resolve(filepath))
}
}
});
console.log(files);Returns something like:
{ a: { path: 'test/fixtures/a.js', fn: { foo: [Function: foo] } },
b: { path: 'test/fixtures/b.js', fn: { bar: [Function: bar] } },
c: { path: 'test/fixtures/c.js', fn: { baz: [Function: baz] } } }Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on September 20, 2014.