MCPcopy Create free account
hub / github.com/handsontable/handsontable / breadthFirst

Function breadthFirst

handsontable/src/utils/dataStructures/tree.ts:61–82  ·  view source on GitHub ↗

* @param {Function} callback A callback which will be called on each visited node. * @param {*} context A context to pass through.

(this: TreeNode<object>, callback: Function, context: unknown)

Source from the content-addressed store, hash-verified

59 * @param {*} context A context to pass through.
60 */
61function breadthFirst(this: TreeNode<object>, callback: Function, context: unknown) {
62 const queue: TreeNode<object>[] = [this];
63
64 /**
65 * Internal processor.
66 */
67 function process() {
68 if (queue.length === 0) {
69 return;
70 }
71
72 const node = queue.shift()!;
73
74 queue.push(...node.childs);
75
76 if (callback.call(context, node) !== false) {
77 process();
78 }
79 }
80
81 process();
82}
83
84/**
85 * Default strategy for tree traversal.

Callers

nothing calls this directly

Calls 1

processFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…