UNPKG

@itwin/presentation-hierarchies

Version:

A package for creating hierarchies based on data in iTwin.js iModels.

30 lines 1.81 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { concatMap, map, of } from "rxjs"; import { createNodeIdentifierForLogging, createOperatorLoggingNamespace, LOGGING_NAMESPACE_INTERNAL } from "../../internal/Common.js"; import { log } from "../../internal/LoggingUtils.js"; import { releaseMainThreadOnItemsCount } from "../../internal/operators/ReleaseMainThread.js"; const OPERATOR_NAME = "DetermineChildren"; /** @internal */ export const LOGGING_NAMESPACE = createOperatorLoggingNamespace(OPERATOR_NAME, LOGGING_NAMESPACE_INTERNAL); /** * Ensures all input nodes have their children determined. * * @internal */ export function createDetermineChildrenOperator(hasNodes) { return function (nodes) { return nodes.pipe(log({ category: LOGGING_NAMESPACE, message: /* c8 ignore next */ (n) => `in: ${createNodeIdentifierForLogging(n)}` }), releaseMainThreadOnItemsCount(200), concatMap((n) => { if (n.children !== undefined) { return of(n); } return hasNodes(n).pipe(log({ category: LOGGING_NAMESPACE, message: /* c8 ignore next */ (hasChildrenFlag) => `${createNodeIdentifierForLogging(n)}: determined children: ${hasChildrenFlag}`, }), map((hasChildrenFlag) => Object.assign(n, { children: hasChildrenFlag }))); }), log({ category: LOGGING_NAMESPACE, message: /* c8 ignore next */ (n) => `out: ${createNodeIdentifierForLogging(n)}` })); }; } //# sourceMappingURL=DetermineChildren.js.map