merge-object-files

2.0.0 • Public • Published

merge-object-files

Merges a directory containing json or other files exporting objects and merges them into a single object.

Sub directories and files become keys under the merged objects, with file contents becoming values.

Requires Node 6.

api

merge-object-files exposes a single method.

  • merge(dirname, extensions, \*optional*\ callback) - merges the given dirname.

Arguments:

  • dirname - the directory to merge - defaults to caller's directory.
  • extensions - an array of extensions to accept - defaults to ['json'].
  • callback - if omitted, a promise is returned.

usage

const Files = require('merge-object-files');
const Path = require('path');
 
Files.merge(Path.resolve(__dirname, 'objects'), ['json', 'js'])
.then((merged) => {
    //...
})
.catch((error) => {
    console.error(error.stack);
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    497
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    497
  • 1.0.3
    1
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i merge-object-files

Weekly Downloads

498

Version

2.0.0

License

MIT

Unpacked Size

4.86 kB

Total Files

7

Last publish

Collaborators

  • tlivings