@saber2pr/nana
Version:
a http-server framework.
19 lines (18 loc) • 511 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* DFS
*
* @export
* @template T
* @param {T} rootNode
* @param {(currentNode: T, parent?: T) => void} callback
* @param {T} [parentNode=null]
*/
function DFS(rootNode, callback, parentNode) {
if (parentNode === void 0) { parentNode = null; }
callback(rootNode, parentNode);
rootNode.children &&
rootNode.children.forEach(function (node) { return DFS(node, callback, rootNode); });
}
exports.DFS = DFS;