npm.io
0.2.0 • Published 3 years ago

node-dir-to-obj

Licence
BSD-3-Clause
Version
0.2.0
Deps
1
Size
7 kB
Vulns
0
Weekly
0

node-dir-to-obj

Build Status npm version Node.js Version

Convert the contents of a directory to an object.

Installation

npm i node-dir-to-obj

Usage

Suppose a directory structure like this:

a.txt
subDir
-- b.txt
import dirToObj from 'node-dir-to-obj';

const obj = await dirToObj('<dir path>');
/*
  {
    'a.txt': '<contents of a.txt>',
    sub: {
      'b.txt': '<contents of a.txt>',
    },
  }
*/
Options
  • ignoreMap a set of names that should be ignored.
  • textMode dumps file contents as text instead of hex.