@itwin/presentation-hierarchies
Version:
A package for creating hierarchies based on data in iTwin.js iModels.
34 lines • 2.15 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.LOGGING_NAMESPACE = void 0;
exports.createDetermineChildrenOperator = createDetermineChildrenOperator;
const rxjs_1 = require("rxjs");
const Common_js_1 = require("../../internal/Common.js");
const LoggingUtils_js_1 = require("../../internal/LoggingUtils.js");
const ReleaseMainThread_js_1 = require("../../internal/operators/ReleaseMainThread.js");
const OPERATOR_NAME = "DetermineChildren";
/** @internal */
exports.LOGGING_NAMESPACE = (0, Common_js_1.createOperatorLoggingNamespace)(OPERATOR_NAME, Common_js_1.LOGGING_NAMESPACE_INTERNAL);
/**
* Ensures all input nodes have their children determined.
*
* @internal
*/
function createDetermineChildrenOperator(hasNodes) {
return function (nodes) {
return nodes.pipe((0, LoggingUtils_js_1.log)({ category: exports.LOGGING_NAMESPACE, message: /* c8 ignore next */ (n) => `in: ${(0, Common_js_1.createNodeIdentifierForLogging)(n)}` }), (0, ReleaseMainThread_js_1.releaseMainThreadOnItemsCount)(200), (0, rxjs_1.concatMap)((n) => {
if (n.children !== undefined) {
return (0, rxjs_1.of)(n);
}
return hasNodes(n).pipe((0, LoggingUtils_js_1.log)({
category: exports.LOGGING_NAMESPACE,
message: /* c8 ignore next */ (hasChildrenFlag) => `${(0, Common_js_1.createNodeIdentifierForLogging)(n)}: determined children: ${hasChildrenFlag}`,
}), (0, rxjs_1.map)((hasChildrenFlag) => Object.assign(n, { children: hasChildrenFlag })));
}), (0, LoggingUtils_js_1.log)({ category: exports.LOGGING_NAMESPACE, message: /* c8 ignore next */ (n) => `out: ${(0, Common_js_1.createNodeIdentifierForLogging)(n)}` }));
};
}
//# sourceMappingURL=DetermineChildren.js.map