Package Exports
- dd-paths-to-tree
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dd-paths-to-tree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
dd-paths-to-tree
Convert a list of path strings to tree
Installation
$ npm install dd-paths-to-tree
Use
// CommonJS
const pathsToTree = require('dd-paths-to-tree');
// ES6
import pathsToTree from 'dd-paths-to-tree';
const paths = [
'src/lib/git.js',
'src/lib/server.js',
'externs/jquery.js',
'index.js'
];
const tree_1 = pathsToTree(paths, { format: 'json' });
const tree_2 = pathsToTree(paths);
console.log(tree_1);
// {
// 'index.js': 'file',
// 'src': {
// 'lib': {
// 'git.js': 'file',
// 'server.js': 'file'
// },
// },
// 'externs': {
// 'jquery.js': 'file'
// }
// }
console.log(tree_2);
// [
// {
// name: 'src',
// type: 'folder',
// children: [
// {
// name: 'lib',
// type: 'folder',
// children: [
// {
// name: 'git.js',
// type: 'file'
// },
// {
// name: 'server.js',
// type: 'file'
// }
// ]
// }
// ]
// },
// {
// name: 'externs',
// type: 'folder',
// children: [
// {
// name: 'jquery.js',
// type: 'file'
// }
// ]
// },
// {
// name: 'index.js',
// type: 'file'
// }
// ]