import { CallArgumentArray, CallArgumentMap, NodeLikeCallArgumentArray, NodeLikeCallArgumentMap } from '../../operations/call'; import { NodeDefinition, StatelessGraphNode, StatelessNodeDefinition, StatelessNodeType } from '../../types/graph'; /** * An instance of the [[partial]] node. * See the [[partial]] documentation to find out more. */ export interface PartialNode extends StatelessGraphNode<'partial', PartialNodeProperties> { } /** * A definition of the [[partial]] node. * See the [[partial]] documentation to find out more. */ export interface PartialNodeDefinition extends StatelessNodeDefinition<'partial', PartialNodeProperties> { } export interface PartialNodeProperties { args: CallArgumentArray | CallArgumentMap; target: NodeDefinition; } /** * The implementation of the [[partial]] node. * See the [[partial]] documentation to learn more. */ export declare const PartialNodeType: StatelessNodeType<'partial', PartialNodeProperties>; /** * Creates a new instance if the [[partial]] node, which can be used to create a partially applied * functions. This node works with both named and positional arguments. * * * @example **Bind positional arguments** * ```js * import muster, { action, call, partial, ref } from '@dws/muster'; * * const app = muster({ * greet: action((name) => `Hello, ${name}!`), * greetBob: partial(ref('greet'), ['Bob']), * }); * * await app.resolve(call('greetBob')); * // === 'Hello, Bob!' * * await app.resolve(call('greet', ['Alice'])); * // === 'Hello, Alice!' * * await app.resolve(call('greetBob', ['Alice'])); * // === 'Hello, Bob!' * ``` * This example shows how to use the [[partial]] node to partially apply the positional arguments. * This method works with any node supporting the `call` operation (e.g. [[fn]], [[apply]], etc.). * * * @example **Bind named argument** * ```js * import muster, { action, call, partial, ref } from '@dws/muster'; * * const app = muster({ * greet: action(({ name }) => `Hello, ${name}!`), * greetBob: partial(ref('greet'), { name: 'Bob' }), * }); * * await app.resolve(call('greetBob')); * // === 'Hello, Bob!' * * await app.resolve(call('greet', { name: 'Alice' })); * // === 'Hello, Alice!' * * await app.resolve(call('greetBob', { name: 'Alice' })); * // === 'Hello, Bob!' * ``` * This example shows how to use the [[partial]] node to partially apply named arguments. * This method works with any node supporting the `call` operation (e.g. [[fn]], [[apply]], etc.). */ export declare function partial(target: NodeDefinition, args: NodeLikeCallArgumentArray | NodeLikeCallArgumentMap): PartialNodeDefinition; export declare function isPartialNodeDefinition(value: NodeDefinition): value is PartialNodeDefinition;