import { NodeDefinition, NodeLike, StatelessGraphNode, StatelessNodeDefinition, StatelessNodeType } from '../../types/graph'; /** * An instance of the [[and]] node. * See the [[and]] documentation to find out more. */ export interface AndNode extends StatelessGraphNode<'and', AndNodeProperties> { } /** * A definition of the [[and]] node. * See the [[and]] documentation to find out more. */ export interface AndNodeDefinition extends StatelessNodeDefinition<'and', AndNodeProperties> { } export interface AndNodeProperties { operands: Array; } /** * The implementation of the [[and]] node. * See the [[and]] documentation to learn more. */ export declare const AndNodeType: StatelessNodeType<'and', AndNodeProperties>; /** * Creates a new instance of an [[and]] node, which introduces the `and` expression. It checks if every operand of * this [[and]] is truthy. The conversion to boolean is done with the help of the `Boolean` JS * function. It requires every operand to resolve to a [[value]]. It throws an error if an * operand resolves to a graph node other than a [[value]]. * * * @example **Different variants of `and` operands** * ```js * import muster, { and, computed, value } from '@dws/muster'; * * const app = muster({}); * await app.resolve(and(true)) // === true * await app.resolve(and(false)) // === false * await app.resolve(and(value(true))) // === true - it is equivalent to and(true) * await app.resolve(and('hello world')) // === true * await app.resolve(and(true, false)) // === false * await app.resolve(and(computed([], () => false))) // === false * await app.resolve(and(computed([], () => true))) // === true * await app.resolve(and(computed([], () => true), true)) // === true * await app.resolve(and(computed([], () => true), false)) // === false * ``` * * * @example **Dynamic operands** * ```ts * import muster, { and, gt, lte, ref, set, variable } from '@dws/muster'; * * const app = muster({ * balance: variable(100), * stake: variable(51), * canPlaceBet: and( * gt(ref('stake'), 0), * lte(ref('stake'), ref('balance')), * ), * }); * * app.resolve(ref('canPlaceBet')).subscribe((res) => { * console.log(`Can place bet: ${res}`); * }); * * console.log('Changing stake to 150'); * await app.resolve(set('stake', 150)); * * console.log('Changing balance to 150'); * await app.resolve(set('balance', 150)); * * // Console output: * // Can place bet: true * // Changing stake to 150 * // Can place bet: false * // Changing balance to 150 * // Can place bet: true * ``` * This example shows how the [[and]] can be used in conjunction with other logic graph * nodes to produce expected results. The `canPlaceBet` node checks if the stake is greater than * zero and if the stake can be covered by user's balance. This is done thanks to [[gt]] and * [[lte]]. */ export declare function and(...operands: Array): AndNodeDefinition; export declare function isAndNodeDefinition(value: NodeDefinition): value is AndNodeDefinition;