UNPKG

@itwin/presentation-common

Version:

Common pieces for iModel.js presentation packages

147 lines 4.43 kB
/** @packageDocumentation * @module Core */ import { GuidString } from "@itwin/core-bentley"; import { EntityProps } from "@itwin/core-common"; import { InstanceId, InstanceKey } from "./EC.js"; import { NodeKey } from "./hierarchy/Key.js"; /** * A single key that identifies something in an iTwin.js application * @public */ export type Key = Readonly<NodeKey> | Readonly<InstanceKey> | Readonly<EntityProps>; /** @public */ export declare namespace Key { /** Check if the supplied key is a `NodeKey` */ function isNodeKey(key: Key): key is NodeKey; /** Check if the supplied key is an `InstanceKey` */ function isInstanceKey(key: Key): key is InstanceKey; /** Check if the supplied key is an `EntityProps` */ function isEntityProps(key: Key): key is EntityProps; } /** * A type for multiple keys that identify something in iModel.js application * @public */ export type Keys = ReadonlyArray<Key> | Readonly<KeySet>; /** * A data structure of serialized [[KeySet]] * @public */ export interface KeySetJSON { /** JSON representation of a list of instance keys */ instanceKeys: Array<[string, string]>; /** An array of serialized node keys */ nodeKeys: NodeKey[]; } /** * A class that holds multiple [[Key]] objects. It's basically * used as a container that holds multiple keys of different types. * * @public */ export declare class KeySet { private _instanceKeys; private _lowerCaseMap; private _nodeKeys; private _guid; /** * Creates an instance of KeySet. * @param source Optional source to initialize from. */ constructor(source?: Keys); private recalculateGuid; /** * Get a GUID that identifies changes in this keyset. The value * does not uniquely identify contents of the keyset, but it can be * used to check whether keyset has changed. */ get guid(): GuidString; /** * Get a map of instance keys stored in this KeySet * * **Warning**: getting instance keys might be expensive for * large KeySets. */ get instanceKeys(): Map<string, Set<InstanceId>>; /** * Get instance keys count */ get instanceKeysCount(): number; /** * Get a set of node keys stored in this KeySet * * **Warning**: getting node keys might be expensive for * large KeySets. */ get nodeKeys(): Set<NodeKey>; /** * Get node keys count */ get nodeKeysCount(): number; private isKeySet; private isKeysArray; /** * Clear this KeySet. * @returns itself */ clear(): KeySet; private addKeySet; private addKeySetJSON; /** * Add a key or keys to this KeySet. * @param value A key or keys to add. * @param pred An optional predicate function that indicates whether a key should be added * @returns itself */ add(value: Keys | Key, pred?: (key: Key) => boolean): KeySet; private deleteKeySet; /** * Deletes a key or keys from this KeySet. * @param value A key or keys to delete. * @returns itself */ delete(value: Keys | Key): KeySet; /** * Check if this KeySet contains the specified key. * @param value The key to check. */ has(value: Key): boolean; private hasKeySet; private hasKeysArray; /** * Check if this KeySet contains all the specified keys. * @param keys The keys to check. */ hasAll(keys: Keys): boolean; /** * Check if this KeySet contains any of the specified keys. * @param keys The keys to check. */ hasAny(keys: Keys): boolean; /** * Get the number of keys stored in this KeySet. */ get size(): number; /** * Is this KeySet currently empty. */ get isEmpty(): boolean; /** Iterate over all keys in this keyset. */ some(callback: (key: Key) => boolean): boolean; /** Iterate over all keys in this keyset. */ forEach(callback: (key: InstanceKey | NodeKey, index: number) => void): void; /** Iterate over all keys in this keyset in batches */ forEachBatch(batchSize: number, callback: (batch: KeySet, index: number) => void): void; /** * Serializes this KeySet to JSON * @public */ toJSON(): KeySetJSON; /** * Creates a KeySet from JSON * @public */ static fromJSON(json: KeySetJSON): KeySet; } //# sourceMappingURL=KeySet.d.ts.map