New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

directory-shaker

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory-shaker

Convert JS files structure to object, extract data

latest
Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
Created
Source

Directory Shaker

Convert JS files (include ES6) structure into object, extract data

Installation

npm install directory-shaker

Usage

const path = require('path');
const getTreeObj = require('directory-shaker');

.........

const folder = path.resolve(__dirname, 'folder');

const { tree, parserName1, parserName2 } = getTreeObj(folder, {
 recursive: true,
 spreadIndex: true,
 pattern: /^.*\.js$/,
 filter: () => true,
}, { // parser }, { // parser } )

.........

Check test folder for more examples

Arguments

  • path: string: path to the root folder to start with
  • options: object: configuration options
  • parser: object: parser to extract data separately

Options

  • recursive: boolean: true deep object construction
  • spreadIndex: boolean: true assign index props to the root or in 'index' node
  • pattern: RegExp: /^.*\.js$/ file pattern to be included in the tree
  • filter: function: filter files to be included in the tree

Parser

{
  name: 'paths',
  key: 'name',
  map: ({ name, page }, meta) => ({ name, page, meta}),
}
  • name: string: name of the object to be returned
  • key: string: key in the result object to assign result of the map function
  • map: function: function to prepare object data to be returned
Map Function
  • data: object: file default exported object
  • meta: object: file meta data: 'name' and 'path'

Limitations

See 'esm' library documentation for the limitations

Keywords

directory

FAQs

Package last updated on 14 Nov 2018

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