/** * A stream of elements offering a functional interface to manipulate elements. * Typically the elements are generated/retrieved lazily. */ export declare abstract class Stream implements AsyncIterable { [Symbol.asyncIterator](): AsyncIterator; iterator(): AsyncIterator; /** * Collects all the answers from this stream into an array * ### Examples * * ```ts * results = transaction.query.match(query).collect().await; * ``` */ collect(): Promise; /** * Checks whether a condition is satisfied by ALL answers in this stream. * @param callbackFn: The condition to evaluate. * ### Examples * * ```ts * // For a query "match $a isa age;", check if all results for $a are positive. * results = transaction.query.match(query).every(cm => cm.get("a").value > 0).await; * ``` */ every(callbackFn: (value: T) => unknown): Promise; /** * Checks whether a condition is satisfied by ANY answer in this stream. * @param callbackFn: The condition to evaluate. * ### Examples * * ```ts * // For a query "match $a isa age;", check if any results for $a are negative. * results = transaction.query.match(query).some(cm => cm.get("a").value < 0).await; * ``` */ some(callbackFn: (value: T) => unknown): Promise; /** * Returns a new stream from this stream consisting only of elements which satisfy a given condition. * @param filter - The condition to evaluate. * ### Examples * * ```ts * // For a query "match $p isa person, has age $a;", only retrieve results having $a >= 60. * results = transaction.query.match(query).filter(cm => cm.get("a").value > 60).collect(); * ``` */ filter(filter: (value: T) => boolean): Stream; /** * @param mapper - The mapping function to apply. * Returns a new stream from this stream by applying the mapper function to each element. */ map(mapper: (value: T) => U): Stream; /** * Given a function which accepts a single element of this stream and returns a new stream, * This function returns a new stream obtained by applying the function to each element in the stream, * and concatenating each result thus obtained * @param mapper - The mapping function to apply. Must return a stream. */ flatMap(mapper: (value: T) => Stream): Stream; /** * Executes the given function for each element in the stream. * @param fn - The function to evaluate for each element. */ forEach(fn: (value: T) => void): Promise; /** * Returns the first element in the stream. */ first(): Promise; } /** @ignore */ export declare namespace Stream { export function iterable(iterable: AsyncIterable): Iterable; export function promises(items: Promise[]): PromiseArray; export function array(items: T[]): Array; class Iterable extends Stream { private _provider; constructor(provider: AsyncIterable); [Symbol.asyncIterator](): AsyncIterator; } class Array extends Stream { private readonly _array; constructor(array: T[]); [Symbol.asyncIterator](): AsyncIterator; } class PromiseArray extends Stream { private readonly _array; constructor(array: Promise[]); [Symbol.asyncIterator](): AsyncIterator; } export class Filtered extends Stream { private _filter; private _source; constructor(source: Stream, filter: (value: T) => boolean); [Symbol.asyncIterator](): AsyncIterator; } export class Mapped extends Stream { private _source; private _mapper; constructor(source: Stream, mapper: (value: T) => U); [Symbol.asyncIterator](): AsyncIterator; } export class FlatMapped> extends Stream { private _source; private _flatMapper; constructor(source: Stream, flatMapper: (value: T) => Stream); [Symbol.asyncIterator](): AsyncIterator; } export {}; }