@itwin/presentation-hierarchies
Version:
A package for creating hierarchies based on data in iTwin.js iModels.
40 lines • 2.25 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(
/* v8 ignore next -- @preserve */
(0, LoggingUtils_js_1.log)({ category: exports.LOGGING_NAMESPACE, message: (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(
/* v8 ignore next -- @preserve */
(0, LoggingUtils_js_1.log)({
category: exports.LOGGING_NAMESPACE,
message: (hasChildrenFlag) => `${(0, Common_js_1.createNodeIdentifierForLogging)(n)}: determined children: ${hasChildrenFlag}`,
}), (0, rxjs_1.map)((hasChildrenFlag) => Object.assign(n, { children: hasChildrenFlag })));
}),
/* v8 ignore next -- @preserve */
(0, LoggingUtils_js_1.log)({ category: exports.LOGGING_NAMESPACE, message: (n) => `out: ${(0, Common_js_1.createNodeIdentifierForLogging)(n)}` }));
};
}
//# sourceMappingURL=DetermineChildren.js.map