@communities-webruntime/services
Version:
If you would like to run Lightning Web Runtime without the CLI, we expose some of our programmatic APIs available in Node.js. If you're looking for the CLI documentation [you can find that here](https://www.npmjs.com/package/@communities-webruntime/cli).
24 lines • 823 B
JavaScript
;
/**
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.findInTree = void 0;
/**
* Find a node in a tree
*
* @param root the tree root
* @param predicate the predicate applied to each node
* @returns the matching node, or `undefined` if the node cannot be found
*/
function findInTree(root, predicate) {
if (predicate(root)) {
return root;
}
return Object.values(root).reduce((n, value) => n || (value && typeof value === 'object' && findInTree(value, predicate)) || undefined, undefined);
}
exports.findInTree = findInTree;
//# sourceMappingURL=tree.js.map