import { NodeDefinition, NodeLike, StatelessGraphNode, StatelessNodeDefinition, StatelessNodeType } from '../../../types/graph'; /** * An instance of the [[nthItem]] node. * See the [[nthItem]] documentation to find out more. */ export interface NthItemNode extends StatelessGraphNode<'nthItem', NthItemNodeProperties> { } /** * A definition of the [[nthItem]] node. * See the [[nthItem]] documentation to find out more. */ export interface NthItemNodeDefinition extends StatelessNodeDefinition<'nthItem', NthItemNodeProperties> { } export interface NthItemNodeProperties { index: NodeDefinition; } /** * The implementation of the [[nthItem]] node. * See the [[nthItem]] documentation to learn more. */ export declare const NthItemNodeType: StatelessNodeType<'nthItem', NthItemNodeProperties>; /** * Creates a new instance of a [[nthItem]] node, which is a type of collection transform used to take a specific item out of a collection. * The items are zero-index based so in order to take the first item you have to call `nthItem(0)`, * second item is `nthItem(1)` and so on. * As with most nodes, a value will be implicitly mapped to a value node if it isn't * a [[NodeDefinition]] already. This means the index can be a reference to another node in the graph. * It also comes with a shorthand version to be used in the [ref](_utils_ref_.html#ref). See the **References to * items in collections** example from the [ref](_utils_ref_.html#ref) documentation. * * * @example **Take third item (using transform)** * ```js * import muster, { entries, query, ref, nthItem, withTransforms } from '@dws/muster'; * * const app = muster({ * numbers: [1, 2, 3, 4, 5], * }); * * const thirdItem = await app.resolve(query(ref('numbers'), withTransforms([ * nthItem(2), * ], entries()))); * // thirdItem === [3] * ``` * This example shows how to use a [[nthItem]] transform to take the third item out of a * collection. */ export declare function nthItem(index: NodeDefinition | NodeLike): NthItemNodeDefinition;