import { GraphNode, NodeDefinition, NodeLike, StatefulNodeType } from '../../types/graph'; import { ItemWithIdNode } from './item-with-id'; import { NodeListNodeDefinition } from './node-list'; /** * An instance of the [[arrayList]] node. * See the [[arrayList]] documentation to find out more. */ export interface ArrayListNode extends GraphNode<'arrayList', ArrayListNodeProperties, ArrayListNodeState, ArrayListNodeData> { } /** * A definition of the [[arrayList]] node. * See the [[arrayList]] documentation to find out more. */ export interface ArrayListNodeDefinition extends NodeDefinition<'arrayList', ArrayListNodeProperties, ArrayListNodeState, ArrayListNodeData> { } export interface ArrayListNodeProperties { items: Array; } export interface ArrayListNodeState { items: NodeListNodeDefinition | undefined; poppedItem: GraphNode | undefined; shiftedItem: GraphNode | undefined; unshiftedItem: GraphNode | undefined; removeItems: { [key: string]: NodeDefinition; }; } export interface ArrayListNodeData { } /** * The implementation of the [[arrayList]] node. * See the [[arrayList]] documentation to learn more. */ export declare const ArrayListNodeType: StatefulNodeType<'arrayList', ArrayListNodeProperties, ArrayListNodeState, ArrayListNodeData>; /** * Creates a new instance of an [[arrayList]] node, which is a type of a [[NodeDefinition]] used when creating * a mutable in-memory array. This array allows for a following operations: * - push(item) - [[push]] * - pop() - [[pop]] * - shift() - [[shift]] * - unshift(item) - [[unshift]] * - addItemAt(item, index) - [[addItemAt]] * - removeItemAt(index) - [[removeItemAt]] * - length() - [[length]] * - clear() - [[clear]] * * When modified in any way this array retains the state for as long as the parent scope exists, or * until a `reset` operation is executed on the array. This behaviour resembles the behaviour of a * [[variable]] node. * * * @example **Create a simple array** * ```js * import muster, { arrayList, entries, push, pop, query, ref } from '@dws/muster'; * * const app = muster({ * numbers: arrayList([1, 3, 2]), * }); * * app.resolve(query(ref('numbers'), entries())).subscribe((numbers) => { * console.log(numbers); * }); * * await app.resolve(push(ref('numbers'), 4)); * await app.resolve(pop(ref('numbers'))); // === 4 * await app.resolve(pop(ref('numbers'))); // === 2 * await app.resolve(pop(ref('numbers'))); // === 3 * await app.resolve(pop(ref('numbers'))); // === 1 * await app.resolve(pop(ref('numbers'))); // === null * await app.resolve(pop(ref('numbers'))); // === null * * // Console output: * // [1, 3, 2] * // [1, 3, 2, 4] * // [1, 3, 2] * // [1, 3] * // [1] * // [] * ``` * This example shows how to create a simple mutable array and use a few operations on it. */ export declare function arrayList(items: Array): ArrayListNodeDefinition; export declare function isArrayListNodeDefinition(value: NodeDefinition): value is ArrayListNodeDefinition;