MCPcopy Index your code
hub / github.com/effector/effector / createNode

Function createNode

src/effector/createNode.ts:13–67  ·  view source on GitHub ↗
({
  node = [],
  from,
  source,
  parent = from || source,
  to,
  target,
  child = to || target,
  scope = {},
  meta = {},
  family: familyRaw = {type: 'regular'},
  regional,
}: {
  node?: Array<Cmd | false | void | null>
  from?: NodeUnit | NodeUnit[]
  source?: NodeUnit | NodeUnit[]
  parent?: NodeUnit | NodeUnit[]
  to?: NodeUnit | NodeUnit[]
  target?: NodeUnit | NodeUnit[]
  child?: NodeUnit | NodeUnit[]
  scope?: {[name: string]: any}
  meta?: {[name: string]: any}
  family?: {
    type?: 'regular' | 'crosslink' | 'domain'
    links?: NodeUnit | NodeUnit[]
    owners?: NodeUnit | Array<NodeUnit | NodeUnit[]>
  }
  regional?: boolean
} = {})

Source from the content-addressed store, hash-verified

11): Node[] => (Array.isArray(list) ? list : [list]).flat().map(getGraph)
12
13export function createNode({
14 node = [],
15 from,
16 source,
17 parent = from || source,
18 to,
19 target,
20 child = to || target,
21 scope = {},
22 meta = {},
23 family: familyRaw = {type: 'regular'},
24 regional,
25}: {
26 node?: Array<Cmd | false | void | null>
27 from?: NodeUnit | NodeUnit[]
28 source?: NodeUnit | NodeUnit[]
29 parent?: NodeUnit | NodeUnit[]
30 to?: NodeUnit | NodeUnit[]
31 target?: NodeUnit | NodeUnit[]
32 child?: NodeUnit | NodeUnit[]
33 scope?: {[name: string]: any}
34 meta?: {[name: string]: any}
35 family?: {
36 type?: 'regular' | 'crosslink' | 'domain'
37 links?: NodeUnit | NodeUnit[]
38 owners?: NodeUnit | Array<NodeUnit | NodeUnit[]>
39 }
40 regional?: boolean
41} = {}): Node {
42 const sources = arrifyNodes(parent)
43 const links = arrifyNodes(familyRaw.links)
44 const owners = arrifyNodes(familyRaw.owners)
45 const seq: Cmd[] = []
46 forEach(node, item => item && add(seq, item))
47 const result: Node = {
48 id: nextNodeID(),
49 seq,
50 next: arrifyNodes(child),
51 meta,
52 scope,
53 family: {
54 triggers: sources.length,
55 type: familyRaw.type || CROSSLINK,
56 links,
57 owners,
58 },
59 }
60 forEach(links, link => add(getOwners(link), result))
61 forEach(owners, owner => add(getLinks(owner), result))
62 forEach(sources, source => add(source.next, result))
63 if (regional && regionStack) {
64 own(getValue(regionStack), [result])
65 }
66 return result
67}

Callers 15

index.test.tsFile · 0.90
launch.test.tsFile · 0.90
useUnitBaseFunction · 0.90
createTemplateFunction · 0.90
createWatchFunction · 0.90
watchUnitFunction · 0.90
createEventFunction · 0.90
createStoreFunction · 0.90
splitFunction · 0.90
withFactoryFunction · 0.90
createLinkNodeFunction · 0.90
forwardFunction · 0.90

Calls 7

forEachFunction · 0.90
addFunction · 0.90
getOwnersFunction · 0.90
getLinksFunction · 0.90
ownFunction · 0.90
getValueFunction · 0.90
arrifyNodesFunction · 0.85

Tested by 6

applyFunction · 0.72
factoryFunction · 0.72
customOperatorFunction · 0.72
createQueryFunction · 0.72
nameClashCheckFunction · 0.72
nameClashCheckFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…