[d24f17c] | 1 | import type { Schema } from '../schema/Schema.js';
|
---|
| 2 | import { NODE_TYPE } from './identity.js';
|
---|
| 3 | import { NodeBase } from './Node.js';
|
---|
| 4 | export declare function collectionFromPath(schema: Schema, path: unknown[], value: unknown): import("./Node.js").Node;
|
---|
| 5 | export declare const isEmptyPath: (path: Iterable<unknown> | null | undefined) => path is null | undefined;
|
---|
| 6 | export declare abstract class Collection extends NodeBase {
|
---|
| 7 | static maxFlowStringSingleLineLength: number;
|
---|
| 8 | schema: Schema | undefined;
|
---|
| 9 | [NODE_TYPE]: symbol;
|
---|
| 10 | items: unknown[];
|
---|
| 11 | /** An optional anchor on this node. Used by alias nodes. */
|
---|
| 12 | anchor?: string;
|
---|
| 13 | /**
|
---|
| 14 | * If true, stringify this and all child nodes using flow rather than
|
---|
| 15 | * block styles.
|
---|
| 16 | */
|
---|
| 17 | flow?: boolean;
|
---|
| 18 | constructor(type: symbol, schema?: Schema);
|
---|
| 19 | /**
|
---|
| 20 | * Create a copy of this collection.
|
---|
| 21 | *
|
---|
| 22 | * @param schema - If defined, overwrites the original's schema
|
---|
| 23 | */
|
---|
| 24 | clone(schema?: Schema): Collection;
|
---|
| 25 | /** Adds a value to the collection. */
|
---|
| 26 | abstract add(value: unknown): void;
|
---|
| 27 | /**
|
---|
| 28 | * Removes a value from the collection.
|
---|
| 29 | * @returns `true` if the item was found and removed.
|
---|
| 30 | */
|
---|
| 31 | abstract delete(key: unknown): boolean;
|
---|
| 32 | /**
|
---|
| 33 | * Returns item at `key`, or `undefined` if not found. By default unwraps
|
---|
| 34 | * scalar values from their surrounding node; to disable set `keepScalar` to
|
---|
| 35 | * `true` (collections are always returned intact).
|
---|
| 36 | */
|
---|
| 37 | abstract get(key: unknown, keepScalar?: boolean): unknown;
|
---|
| 38 | /**
|
---|
| 39 | * Checks if the collection includes a value with the key `key`.
|
---|
| 40 | */
|
---|
| 41 | abstract has(key: unknown): boolean;
|
---|
| 42 | /**
|
---|
| 43 | * Sets a value in this collection. For `!!set`, `value` needs to be a
|
---|
| 44 | * boolean to add/remove the item from the set.
|
---|
| 45 | */
|
---|
| 46 | abstract set(key: unknown, value: unknown): void;
|
---|
| 47 | /**
|
---|
| 48 | * Adds a value to the collection. For `!!map` and `!!omap` the value must
|
---|
| 49 | * be a Pair instance or a `{ key, value }` object, which may not have a key
|
---|
| 50 | * that already exists in the map.
|
---|
| 51 | */
|
---|
| 52 | addIn(path: Iterable<unknown>, value: unknown): void;
|
---|
| 53 | /**
|
---|
| 54 | * Removes a value from the collection.
|
---|
| 55 | * @returns `true` if the item was found and removed.
|
---|
| 56 | */
|
---|
| 57 | deleteIn(path: Iterable<unknown>): boolean;
|
---|
| 58 | /**
|
---|
| 59 | * Returns item at `key`, or `undefined` if not found. By default unwraps
|
---|
| 60 | * scalar values from their surrounding node; to disable set `keepScalar` to
|
---|
| 61 | * `true` (collections are always returned intact).
|
---|
| 62 | */
|
---|
| 63 | getIn(path: Iterable<unknown>, keepScalar?: boolean): unknown;
|
---|
| 64 | hasAllNullValues(allowScalar?: boolean): boolean;
|
---|
| 65 | /**
|
---|
| 66 | * Checks if the collection includes a value with the key `key`.
|
---|
| 67 | */
|
---|
| 68 | hasIn(path: Iterable<unknown>): boolean;
|
---|
| 69 | /**
|
---|
| 70 | * Sets a value in this collection. For `!!set`, `value` needs to be a
|
---|
| 71 | * boolean to add/remove the item from the set.
|
---|
| 72 | */
|
---|
| 73 | setIn(path: Iterable<unknown>, value: unknown): void;
|
---|
| 74 | }
|
---|