compound-callback-subtree
v5.0.1
Published
A subtree method that offers great flexibility and features to the developer
Downloads
258
Readme
compound-callback-subtree
A subtree method that offers great flexibility and features to the developer.
const CompoundCallbackSubTree = require("compound-callback-subtree");
/*
node_modules (root)
|__test.js
|__compund-callback-subtree
| |__ .git
| | |__ etc...
| |__ MONKEY.json
| |__ index.js
| |__ package.json
| |__ README.md
|__etc...
*/
const CompoundCallbackSubTree = require("compound-callback-subtree");
const statCallback = (branchData, callback) => callback(branchData.branch.path = branchData.path);
const subtree = new CompoundCallbackSubTree({
dirStatCb: statCallback,
fileStatCb: statCallback,
subBranchCb: (branchData, proceed, block) => branchData.file.includes(".git") ? block() : proceed()
});
// posix no absolute path
subtree.fromPath("./");
{
path: './',
'index.d.ts': { path: 'index.d.ts' },
'index.js': { path: 'index.js' },
'MONKEY.json': { path: 'MONKEY.json' },
'package.json': { path: 'package.json' },
'README.md': { path: 'README.md' }
}
// win32 with absolute path (only if process.platform === "win32")
subtree.fromPath(path.resolve("./"));
{
path: 'D:\\js\\node_modules\\compound-callback-subtree',
'index.d.ts': {
path: 'D:\\js\\node_modules\\compound-callback-subtree\\index.d.ts'
},
'index.js': { path: 'D:\\js\\node_modules\\compound-callback-subtree\\index.js' },
'MONKEY.json': {
path: 'D:\\js\\node_modules\\compound-callback-subtree\\MONKEY.json'
},
'package.json': {
path: 'D:\\js\\node_modules\\compound-callback-subtree\\package.json'
},
'README.md': {
path: 'D:\\js\\node_modules\\compound-callback-subtree\\README.md'
}
}
// posix with absolute path
subtree.fromPath(path.posix.resolve("./"));
{
path: '/js/node_modules/compound-callback-subtree',
'index.js': { path: '/js/node_modules/compound-callback-subtree/index.js' },
'MONKEY.json': { path: '/js/node_modules/compound-callback-subtree/MONKEY.json' },
'package.json': { path: '/js/node_modules/compound-callback-subtree/package.json' },
'README.md': { path: '/js/node_modules/compound-callback-subtree/README.md' }
}
subtree.fromPath("./");