Socket
Book a DemoInstallSign in
Socket

directory-to-object

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory-to-object

Analyze a directory structure and return a `json` representation.

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

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

Keywords

directory

FAQs

Package last updated on 12 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts