import { Operator } from '../core/types'; /** * @short * Breaks the iterable into *segments* whose items project into the same value. * * @categories * operator * * @description * Applies the given projection function to each value of the source iterable. As long as these projections are * equal (using `SameValue` equality, i.e. `Object.is`), values are collected into sub-arrays, which are yielded * together whenever the result of the projection function changes. * * This is a generalization of {@link segmentize} and {@link chunk}. * * @since * 0.0.1 * * @parameter * project: (item: T, index: number) => unknown * * @returns * Operator> * * @example * j.pipe( * [1, 5, 3, -1, -2, 1, -4], * j.segmentizeBy(n => Math.sign(n)), * ) * // => [ * // [1, 5, 3], * // [-1, -2], * // [1], * // [-4], * // ] * * @example * j.pipe( * ['foo', 'bar', 'Foo', 'bar', 'Bar'], * j.segmentizeBy(n => n[0] == n[0].toUpperCase()), * ) * // => [ * // ['foo', 'bar'], * // ['Foo'], * // ['bar'], * // ['Bar'], * // ] * * @example * j.pipe( * [10, 20, 30, 40, 50, 60, 70, 80, 90], * j.segmentizeBy((n, i) => Math.floor(i / 4)), * ) * // => [ * // [10, 20, 30, 40], * // [50, 60, 70, 80], * // [90], * // ] */ export declare function segmentizeBy(project: (item: T, index: number) => unknown): Operator>; /** * @short * Breaks the iterable into *segments* with equal items. * * @categories * operator * * @description * As long as items from the source iterable are equal (using `SameValue` equality, i.e. `Object.is`), * they will be collected into sub-arrays, which are yielded together whenever a different value * is encountered. * * This is a specialization of {@link segmentizeBy}. * * @since * 0.0.1 * * @parameter * project: (item: T, index: number) => unknown * * @returns * Operator> * * @example * j.pipe( * [1, 1, 2, 2, 2, 3], * j.segmentize(), * ) * // => [ * // [1, 1], * // [2, 2, 2], * // [3], * // ] */ export declare function segmentize(): (iterable: Iterable) => IterableIterator;