JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q77514F
  • License MIT

call an object with deeply nested functions

Package Exports

  • call-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 (call-tree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

call-tree

import { create } from "call-tree"

const tree = create({ x: console.log })

const parameters = {
  x: `x`,
  y: {
    z: `z`,
  },
}

tree.attach({ y: { z: console.log } })

tree(parameters, 1, 2, 3)
// x 1 2 3
// z 1 2 3

tree.attach({ y: console.log })

tree(parameters)
// x
// z
// { z: 'z' }

api

create([tree])

.attach([ ...branches ])

.prepare(fn)

.clear()

.includes(fn)

.current

call(tree[,parameters[, ...args ]])

import { call } from "call-tree"

concat(tree[, ...trees])

import { concat } from "call-tree"

concat(
  { a: () => {} },
  { a: () => {}, b: () => {} }
)
// {
//   a: [
//     () => {},
//     () => {}
//   ],
//   b: () => {}
// }

omit(tree[, ...trees])

import { omit } from "call-tree"

const a = () => {}
const b = () => {}

omit(
  { x: [ a, b ] },
  { x: b }
)
// { x: a }

includes(tree, branch)

import { includes } from "call-tree"

const e = () => {}
const f = () => {}

const tree = {
  a: {
    b: () => {}
  },
  c: {
    d: [ { e } ]
  }
}

includes(tree, e) // true
includes(tree, f) // false

map(tree, callback((fn, path) => {})

import { map } from "call-tree"

const tree = {
  a: {
    b: path => path,
  },
  c: {
    d: [ { e: path => path } ],
  },
}

const callback = (fn, path) => fn(path)

console.log(map(tree, callback))
// {
//   a: {
//     b: [ `a`, `b` ],
//   },
//   c: {
//     d: [
//       {
//         e: [ `c`, `d`, `e` ],
//       },
//     ],
//   },
// }