dir-to-object

2.0.0 • Public • Published

dir-to-object

Builds an object from the files contained inside a directory.

Installation

npm install dir-to-object

Usage example

const dirToObject = require('dir-to-object');
const { join } = require('path');
 
const path = join(__dirname, './__mocks__/foo');
 
const options = { canAdd: () => true };
 
const bar = dirToObject(path, options);
 
console.log(bar);

Where path is a string and it is required:

e.g.: join(__dirname, './foo')

And where config is an object with the following property:

name type example required or optional
canAdd function: (data) => boolean data => data.resolve && data.type optional

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

License

Distributed under the MIT license. See LICENSE for more information.

Package Sidebar

Install

npm i dir-to-object

Weekly Downloads

1,408

Version

2.0.0

License

MIT

Unpacked Size

7.2 kB

Total Files

12

Last publish

Collaborators

  • mattiaerre