5.0.1 • Published 3 years ago

compound-callback-subtree v5.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago

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("./");
5.0.1

3 years ago

5.0.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago