1.1.1 • Published 9 years ago

directory-to-object v1.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

directory-to-object

NPM version Downloads

Analyze a directory structure and return a json representation. Expects a flat folder structure with either files or directories.

Installation

$ npm install directory-to-object

Usage

const dto  = require('directory-to-object')
const path = require('path')

dto(path.resolve('./test'), (err, res) => console.log(res))
// {
//   fooDir: [file1, file2, file3],
//   barDir: [file4, file5, file6]
// }

API

dto(opts|path, callback)

dto(path.resolve('./test'), (err, res) => console.log(res))

// `noDot` ignores files which have a leading `.`
// in the filename.
const opts = {noDot: true, path: path.resolve('./test')}
dto(opts, (err, res) => console.log(res))

Why?

When parsing several directories of files it's nice to just have to provide a path rather than creating an index object manually. This is useful for creating static sites out of markdown files.

See Also

License

MIT