import { Either } from 'fp-ts/lib/Either'; import { Filterable1 } from 'fp-ts/lib/Filterable'; import { FilterableWithIndex1, RefinementWithIndex } from 'fp-ts/lib/FilterableWithIndex'; import { Option } from 'fp-ts/lib/Option'; import { Refinement } from 'fp-ts/lib/Refinement'; import { Separated } from 'fp-ts/lib/Separated'; import { AsyncStream, URI } from './uri'; import { AsyncPredicate, AsyncPredicateWithIndex } from './utils/async-predicate'; import { MaybeAsync } from './utils/maybe-async'; /** * Returns an {@link AsyncStream} that produces values that passes from the * refinement function. * * @export * @template A The value type. * @template B The refined output value type. * @param {Refinement} refinement The refinement function. * @return {(fa: AsyncStream) => AsyncStream} A function that takes an * async stream and returns another async stream passing the filter. * * @category filtering * @__PURE__ */ export declare function filter(refinement: Refinement): (fa: AsyncStream) => AsyncStream; /** * Returns an {@link AsyncStream} that produces values that passes from the * predicate function. * * @export * @template A The value type. * @param {AsyncPredicate} predicate The predicate function. * @return {(fa: AsyncStream) => AsyncStream} A function * that takes an async stream and returns another async stream passing the * filter. * * @category filtering * @__PURE__ */ export declare function filter(predicate: AsyncPredicate): (fa: AsyncStream) => AsyncStream; /** * Maps an {@link AsyncStream} with an iterating function that takes the * index and the value of each element and returns an {@link Option}. * * It keeps only the `Some` values dicarding the `None`s. * * Same as [`filterMap`](#filterMap), but with an iterating function which takes * also the index as input. * * @export * @template A The value type. * @template B The mapped type. * @param {(i: number, a: A) => Option | Promise>} f The mapper * function. * * @return {(fa: AsyncStream) => AsyncStream} A function that takes an * async stream of type `A` values and returns an async stream of type `B` * values. * * @__PURE__ */ export declare function filterMapWithIndex(f: (i: number, a: A) => MaybeAsync>): (fa: AsyncStream) => AsyncStream; /** * Maps an {@link AsyncStream} with an iterating function that takes * the value of each element and returns an {@link Option}. It keeps only the * `Some` values dicarding the `None`s. * * @export * @template A The value type. * @template B The mapped type. * @param {(a: A) => Option | Promise>} f The mapper function. * @return {(fa: AsyncStream) => AsyncStream} A function that takes an * async stream of type `A` values and returns an async stream of type `B` * values. * * @__PURE__ */ export declare function filterMap(f: (a: A) => MaybeAsync>): (fa: AsyncStream) => AsyncStream; /** * Maps an {@link AsyncStream} with an iterating function that takes the index * and the value of each element and returns an boolean. * * It keeps only the elements returning `true` and discards the others. * * @export * @template A The value type. * @template B The refined new value type. * @param {RefinementWithIndex} refinementWithIndex The refinement * function with index. * * @return {(fa: AsyncStream) => AsyncStream} A function that takes an * async stream to filter. * * @category filtering * @__PURE__ */ export declare function filterWithIndex(refinementWithIndex: RefinementWithIndex): (fa: AsyncStream) => AsyncStream; /** * Maps an {@link AsyncStream} with an iterating function that takes the index * and the value of each element and returns an boolean. * * It keeps only the elements returning `true` and discards the others. * * @export * @template A The value type. * @template B The refined new value type. * @param {AsyncPredicateWithIndex} predicateWithIndex The predicate * function with index. * * @return {(fa: AsyncStream) => AsyncStream} A function * that takes an async stream to filter. * * @category filtering * @__PURE__ */ export declare function filterWithIndex(predicateWithIndex: AsyncPredicateWithIndex): (fa: AsyncStream) => AsyncStream; /** * Maps an {@link AsyncStream} with an iterating function that takes the index * and the value of each element and returns an boolean. * * It keeps only the elements returning `true` and discards the others. * * @export * @template A The value type. * @template B The refined new value type. * @param {AsyncPredicateWithIndex} predicateWithIndex The predicate * function with index. * * @return {(fa: AsyncStream) => AsyncStream} A function that takes an * async stream to filter. * * @category filtering * @__PURE__ */ export declare function filterWithIndex(predicateWithIndex: AsyncPredicateWithIndex): (fa: AsyncStream) => AsyncStream; /** * Given an iterating function that is a {@link Predicate} or * a {@link Refinement}, `partition` creates two new {@link AsyncStream}s where * the `right` contains the original {@link AsyncStream} for which the * iterating function is `true`, `left` contains the elements for which it * is `false`. * * @export * @template A The value type. * @template B The refined value type. * @param {Refinement} refinement The refinement function. * @return {(fa: AsyncStream) => Separated, AsyncStream>} A function * that takes an async stream to separate it based on a given condition function. * * @category filtering * @__PURE__ */ export declare function partition(refinement: Refinement): (fa: AsyncStream) => Separated, AsyncStream>; /** * Given an iterating function that is a {@link Predicate} or * a {@link Refinement}, `partition` creates two new {@link AsyncStream}s * where the `right` contains the original {@link Stream} for which the * iterating function is `true`, `left` contains the elements for which it * is `false`. * * @export * @template A The value type. * @template B The refined value type. * @param {AsyncPredicate} predicate The predicate function. * @return {(fa: AsyncStream) => Separated, AsyncStream>} A * function that takes an async stream to separate it based on a given condition * function. * * @category filtering * @__PURE__ */ export declare function partition(predicate: AsyncPredicate): (fb: AsyncStream) => Separated, AsyncStream>; /** * Given an iterating function that is a {@link Predicate} or * a {@link Refinement}, `partition` creates two new {@link AsyncStream}s * where the `right` contains the original {@link Stream} for which the * iterating function is `true`, `left` contains the elements for which it * is `false`. * * @export * @template A The value type. * @param {AsyncPredicate} predicate The predicate function. * @return {(fa: AsyncStream) => Separated, AsyncStream>} A * function that takes an async stream to separate it based on a given condition * function. * * @category filtering * @__PURE__ */ export declare function partition(predicate: AsyncPredicate): (fb: AsyncStream) => Separated, AsyncStream>; /** * Same as [`partition`](#partition), but passing also the index to the * iterating function. * * @export * @template A The value type. * @template B The refined value type. * @param {RefinementWithIndex} refinementWithIndex The refinement * function. * @return {( * fa: AsyncStream * ) => Separated, AsyncStream>} A function that takes an * async stream to separate it based on a given condition function. * * @category filtering * @__PURE__ */ export declare function partitionWithIndex(refinementWithIndex: RefinementWithIndex): (fa: AsyncStream) => Separated, AsyncStream>; /** * Same as [`partition`](#partition), but passing also the index to the * iterating function. * * @export * @template A The value type. * @template B The refined value type. * @param {AsyncPredicateWithIndex} predicateWithIndex The predicate * function. * @return {( * fa: AsyncStream * ) => Separated, AsyncStream>} A function that takes an * async stream to separate it based on a given condition function. * * @category filtering * @__PURE__ */ export declare function partitionWithIndex(predicateWithIndex: AsyncPredicateWithIndex): (fb: AsyncStream) => Separated, AsyncStream>; /** * Same as [`partition`](#partition), but passing also the index to the * iterating function. * * @export * @template A The value type. * @param {AsyncPredicateWithIndex} predicateWithIndex The predicate * function. * @return {(fa: AsyncStream) => Separated, AsyncStream>} A * function that takes an async stream to separate it based on a given * condition function. * * @category filtering * @__PURE__ */ export declare function partitionWithIndex(predicateWithIndex: AsyncPredicateWithIndex): (fa: AsyncStream) => Separated, AsyncStream>; /** * Given an iterating function that returns an {@link Either}, * `partitionMap` applies the iterating function to each element and it creates * two {@link AsyncStream}s where the `right` contains the values of `Right` * results and the `left` contains the values of `Left` results. * * @export * @template A The value type. * @template B The left type. * @template C The right type. * @param {(a: A) => Either | Promise>} f The iterating * function. * * @return {(fa: AsyncStream) => Separated, AsyncStream>} A * function that takes an async stream and returns a separate async streams. * * @category filtering * @__PURE__ */ export declare function partitionMap(f: (a: A) => MaybeAsync>): (fa: AsyncStream) => Separated, AsyncStream>; /** * Same as [`partitionMap`](#partitionMap), but passing also the index to the * iterating function. * * @export * @template A The value type. * @template B The left type. * @template C The right type. * @param {(i: number, a: A) => Either | Promise>} f The * iterating function. * * @return {(fa: AsyncStream) => Separated, AsyncStream>} A * function that takes an async stream and returns a separate async streams. * * @category filtering * @__PURE__ */ export declare function partitionMapWithIndex(f: (i: number, a: A) => MaybeAsync>): (fa: AsyncStream) => Separated, AsyncStream>; /** * The `Filterable` category instance for {@link AsyncStream}. */ export declare const Filterable: Filterable1; /** * The `FilterableWithIndex` category instance for {@link AsyncStream}. */ export declare const FilterableWithIndex: FilterableWithIndex1;