npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

directory-to-object

1.1.1

@yoshuawuyts

npmHomeRepoSnykSocket
Downloads:1
$ npm install directory-to-object
DailyWeeklyMonthlyYearly

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

  • directory-to-json - write a directory to a JSON file

License

MIT