Socket
Socket
Sign inDemoInstall

@rimbu/common

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rimbu/common - npm Package Compare versions

Comparing version 0.8.2 to 0.9.0

4

dist/main/async-optlazy.js

@@ -11,2 +11,3 @@ "use strict";

* @example
* ```ts
* AsyncOptLazy.toMaybePromise(1) // => 1

@@ -17,2 +18,3 @@ * AsyncOptLazy.toMaybePromise(() => 1) // => 1

* AsyncOptLazy.toMaybePromise(Promise.resolve(1)) // => Promise(1)
* ```
*/

@@ -29,2 +31,3 @@ function toMaybePromise(optLazy) {

* @example
* ```ts
* AsyncOptLazy.toPromise(1) // => Promise(1)

@@ -35,2 +38,3 @@ * AsyncOptLazy.toPromise(() => 1) // => Promise(1)

* AsyncOptLazy.toPromise(Promise.resolve(1)) // => Promise(1)
* ```
*/

@@ -37,0 +41,0 @@ function toPromise(optLazy) {

24

dist/main/async-reducer.js

@@ -143,6 +143,6 @@ "use strict";

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -162,6 +162,6 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -181,6 +181,6 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -187,0 +187,0 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

@@ -46,5 +46,7 @@ "use strict";

* @example
* ```ts
* const c = Comp.numberComp();
* console.log(c.compare(3, 5))
* // => -2
* ```
*/

@@ -66,2 +68,3 @@ function numberComp() {

* @example
* ```ts
* const c = Comp.booleanComp();

@@ -72,2 +75,3 @@ * console.log(c.compare(false, true) < 0)

* // => 0
* ```
*/

@@ -238,2 +242,3 @@ function booleanComp() {

* @example
* ```ts
* const c = Comp.iterableComp();

@@ -244,2 +249,3 @@ * console.log(c.compare([1, 3, 2], [1, 3, 2]))

* // => true
* ```
*/

@@ -311,10 +317,12 @@ function iterableComp(itemComp) {

* Returns a Comp instance for objects that orders the object keys according to the given `keyComp`, and then compares the corresponding
* values using the given `valueComp`. Objects are then compared as follows:
* - starting with the smallest key of either object:
* - if only one of the objects has the key, the object with the key is considered to be larger than the other
* - if both objects have the key, the values are compared with `valueComp`. If the values are not equal, this result is returned.
* - if the objects have the same keys with the same values, they are considered equal
* values using the given `valueComp`. Objects are then compared as follows:<br/>
* starting with the smallest key of either object:<br/>
* - if only one of the objects has the key, the object with the key is considered to be larger than the other<br/>
* - if both objects have the key, the values are compared with `valueComp`. If the values are not equal, this result is returned.<br/>
*
* if the objects have the same keys with the same values, they are considered equal<br/>
* @param keyComp - (optional) the Comp instance used to order the object keys
* @param valueComp - (optional) the Comp instance used to order the object values
* @example
* ```ts
* const c = Comp.objectComp();

@@ -331,2 +339,3 @@ * console.log(c.compare({ a: 1 }, { a: 1 }))

* // => 0
* ```
*/

@@ -397,2 +406,3 @@ function objectComp(options) {

* @example
* ```ts
* const c = Comp.anyFlatComp();

@@ -402,2 +412,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }) < 0)

* // First object is smaller because the objects are converted to a string with and then compares the resulting string.
* ```
*/

@@ -412,2 +423,3 @@ function anyFlatComp() {

* @example
* ```ts
* const c = Comp.anyShallowComp();

@@ -419,2 +431,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))

* // First object is smaller because the objects are converted to a string and then compares the resulting string.
* ```
*/

@@ -430,2 +443,3 @@ function anyShallowComp() {

* @example
* ```ts
* const c = Comp.anyDeepComp();

@@ -436,2 +450,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))

* // => 0
* ```
*/

@@ -447,2 +462,3 @@ function anyDeepComp() {

* @example
* ```ts
* const c = Comp.withUndefined(Comp.numberComp())

@@ -453,2 +469,3 @@ * console.log(c.compare(undefined, 5) < 0)

* // => 0
* ```
*/

@@ -478,2 +495,3 @@ function withUndefined(comp) {

* @example
* ```ts
* const c = Comp.withNull(Comp.numberComp())

@@ -484,2 +502,3 @@ * console.log(c.compare(null, 5) < 0)

* // => 0
* ```
*/

@@ -508,2 +527,3 @@ function withNull(comp) {

* @example
* ```ts
* const c = Comp.invert(Comp.numberComp())

@@ -514,2 +534,3 @@ * console.log(c.compare(3, 5) > 0)

* // => 0
* ```
*/

@@ -529,5 +550,7 @@ function invert(comp) {

* @example
* ```ts
* const eq = Comp.toEq(Comp.objectComp())
* console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
* // => true
* ```
*/

@@ -534,0 +557,0 @@ function toEq(comp) {

@@ -31,2 +31,3 @@ "use strict";

* @example
* ```ts
* const eq = Eq.objectIs

@@ -37,2 +38,3 @@ * console.log(eq(5, 5))

* // => false
* ```
*/

@@ -48,2 +50,3 @@ Eq.objectIs = Object.is;

* @example
* ```ts
* const eq = Eq.valueOfEq()

@@ -54,2 +57,3 @@ * console.log(eq(new Number(5), new Number(5)))

* // => false
* ```
*/

@@ -63,2 +67,3 @@ function valueOfEq() {

* @example
* ```ts
* const eq = Eq.dateEq()

@@ -69,2 +74,3 @@ * console.log(eq(new Date(2020, 1, 1), new Date(2020, 1, 1))

* // => false
* ```
*/

@@ -97,2 +103,3 @@ function dateEq() {

* @example
* ```ts
* const eq = Eq.iterableEq();

@@ -103,2 +110,3 @@ * console.log(eq([1, 2, 3], [1, 2, 3])

* // => false
* ```
*/

@@ -141,2 +149,3 @@ function iterableEq(itemEq) {

* @example
* ```ts
* const eq = Eq.objectEq()

@@ -147,2 +156,3 @@ * console.log(eq({ a: 1, b: { c: 2 }}, { b: { c: 2 }, a: 1 }))

* // => false
* ```
*/

@@ -208,2 +218,3 @@ function objectEq(valueEq) {

* @example
* ```ts
* const eq = anyFlatEq()

@@ -214,2 +225,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -226,2 +238,3 @@ function anyFlatEq() {

* @example
* ```ts
* const eq = anyFlatEq()

@@ -234,2 +247,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -247,2 +261,3 @@ function anyShallowEq() {

* @example
* ```ts
* const eq = anyFlatEq()

@@ -255,2 +270,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -270,2 +286,3 @@ function anyDeepEq() {

* @example
* ```ts
* const eq = Eq.createStringCollatorEq()

@@ -276,2 +293,3 @@ * console.log(eq('a', 'a'))

* // => false
* ```
*/

@@ -295,2 +313,3 @@ function createStringCollatorEq() {

* @example
* ```ts
* const eq = Eq.stringCaseInsentitiveEq()

@@ -301,2 +320,3 @@ * console.log(eq('aB', 'Ab'))

* // => false
* ```
*/

@@ -321,2 +341,3 @@ function stringCaseInsentitiveEq() {

* @example
* ```ts
* const eq = Eq.stringCharCodeEq()

@@ -327,2 +348,3 @@ * console.log(eq('a', 'a'))

* // => false
* ```
*/

@@ -346,2 +368,3 @@ function stringCharCodeEq() {

* @example
* ```ts
* const eq = Eq.anyJsonEq()

@@ -352,2 +375,3 @@ * console.log(eq({ a: 1, b: 2 }, { a: 1, b: 2 }))

* // => false
* ```
*/

@@ -363,2 +387,3 @@ function anyJsonEq() {

* @example
* ```ts
* const eq = Eq.tupleSymmetric()

@@ -371,2 +396,3 @@ * console.log(eq([1, 2], [1, 2]))

* // => false
* ```
*/

@@ -373,0 +399,0 @@ function tupleSymmetric(eq) {

@@ -8,5 +8,7 @@ "use strict";

* @example
* ```ts
* const emptyMap = HashMap.empty<number, string>()
* emptyMap.get(5, Err);
* // throws: Err.CustomError(message: 'Err: forced to throw error')
* ```
*/

@@ -13,0 +15,0 @@ function Err() {

"use strict";
/**
* @packageDocumentation
*
* The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
*/
Object.defineProperty(exports, "__esModule", { value: true });

@@ -3,0 +8,0 @@ var tslib_1 = require("tslib");

@@ -8,5 +8,7 @@ "use strict";

* @example
* ```ts
* OptLazy(1) // => 1
* OptLazy(() => 1) // => 1
* OptLazy(() => () => 1) // => () => 1
* ```
*/

@@ -25,5 +27,7 @@ function OptLazy(optLazy) {

* @example
* ```ts
* OptLazyOr(1, 'a') // => 1
* OptLazyOr(() => 1, 'a') // => 1
* OptLazyOr((none) => none, 'a') // => 'a'
* ```
*/

@@ -30,0 +34,0 @@ function OptLazyOr(optLazyOr, otherValue) {

@@ -99,6 +99,6 @@ "use strict";

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -110,2 +110,3 @@ * @param stateToResult - a function that converts the current state to an output value

* @example
* ```ts
* const evenNumberOfOnes = Reducer

@@ -119,2 +120,3 @@ * .create(

* // => 'even'
* ```
*/

@@ -128,9 +130,11 @@ function create(init, next, stateToResult) {

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer
* @param stateToResult - (optional) a function that converts the current state to an output value
* @typeparam T - the overall value type
* @example
* ```ts
* const sum = Reducer

@@ -144,2 +148,3 @@ * .createMono(

* // => 9
* ```
*/

@@ -153,6 +158,6 @@ function createMono(init, next, stateToResult) {

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -162,2 +167,4 @@ * @param stateToResult - (optional) a function that converts the current state to an output value

* @typeparam O - the output value type
* @example
* ```ts
* const boolToString = Reducer

@@ -171,2 +178,3 @@ * .createOutput(

* // => 'TFT'
* ```
*/

@@ -180,4 +188,6 @@ function createOutput(init, next, stateToResult) {

* @example
* ```ts
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.sum))
* // => 10
* ```
*/

@@ -188,4 +198,6 @@ Reducer.sum = createMono(0, function (state, next) { return state + next; });

* @example
* ```ts
* console.log(Stream.range({ start: 1, amount: 5 }).reduce(product))
* // => 120
* ```
*/

@@ -200,4 +212,6 @@ Reducer.product = createMono(1, function (state, next, _, halt) {

* @example
* ```ts
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.average));
* // => 2
* ```
*/

@@ -210,5 +224,7 @@ Reducer.average = createMono(0, function (avg, value, index) { return avg + (value - avg) / (index + 1); });

* @example
* ```ts
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
* console.log(stream.minBy((s1, s2) => s1.length - s2.length))
* // 'a'
* ```
*/

@@ -227,4 +243,6 @@ Reducer.minBy = function (compFun, otherwise) {

* @example
* ```ts
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.min()))
* // => 3
* ```
*/

@@ -241,5 +259,7 @@ Reducer.min = function (otherwise) {

* @example
* ```ts
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
* console.log(stream.maxBy((s1, s2) => s1.length - s2.length))
* // 'abcde'
* ```
*/

@@ -258,4 +278,6 @@ Reducer.maxBy = function (compFun, otherwise) {

* @example
* ```ts
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.max()))
* // => 7
* ```
*/

@@ -268,10 +290,12 @@ Reducer.max = function (otherwise) {

/**
* Returns a `Reducer` that joins the given input values into a string using the given options.
* @options - an object containing:
* - sep: (optional) a seperator string value between values in the output
* - start: (optional) a start string to prepend to the output
* - end: (optional) an end string to append to the output
* Returns a `yaReducer` that joins the given input values into a string using the given options.
* @param options - an object containing:<br/>
* - sep: (optional) a seperator string value between values in the output<br/>
* - start: (optional) a start string to prepend to the output<br/>
* - end: (optional) an end string to append to the output<br/>
* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.join({ sep: '-' })))
* // => '1-2-3'
* ```
*/

@@ -292,6 +316,7 @@ function join(_a) {

* Returns a `Reducer` that remembers the amount of input items provided.
* @param pred - (optional) a predicate that returns false if the item should not be counted given:
* - value: the current input value
* @param pred - (optional) a predicate that returns false if the item should not be counted given:<br/>
* - value: the current input value<br/>
* - index: the input value index
* @example
* ```ts
* const stream = Stream.range({ amount: 10 })

@@ -302,2 +327,3 @@ * console.log(stream.reduce(Reducer.count()))

* // => 5
* ```
*/

@@ -320,4 +346,6 @@ Reducer.count = function (pred) {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.firstWhere(v => v > 5)))
* // => 6
* ```
*/

@@ -340,4 +368,6 @@ Reducer.firstWhere = function (pred, otherwise) {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
* // => 0
* ```
*/

@@ -360,4 +390,6 @@ Reducer.first = function (otherwise) {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.lastWhere(v => v > 5)))
* // => 9
* ```
*/

@@ -378,4 +410,6 @@ Reducer.lastWhere = function (pred, otherwise) {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
* // => 0
* ```
*/

@@ -390,4 +424,6 @@ Reducer.last = function (otherwise) {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.some(v => v > 5))
* // => true
* ```
*/

@@ -410,4 +446,6 @@ function some(pred) {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.every(v => v < 5))
* // => false
* ```
*/

@@ -431,4 +469,6 @@ function every(pred) {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.contains(5)))
* // => true
* ```
*/

@@ -451,4 +491,6 @@ function contains(elem, eq) {

* @example
* ```ts
* console.log(Stream.of(true, false, true)).reduce(Reducer.and))
* // => false
* ```
*/

@@ -465,4 +507,6 @@ Reducer.and = createMono(true, function (state, next, _, halt) {

* @example
* ```ts
* console.log(Stream.of(true, false, true)).reduce(Reducer.or))
* // => true
* ```
*/

@@ -479,4 +523,6 @@ Reducer.or = createMono(false, function (state, next, _, halt) {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.isEmpty))
* // => false
* ```
*/

@@ -490,4 +536,6 @@ Reducer.isEmpty = createOutput(true, function (_, __, ___, halt) {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.nonEmpty))
* // => true
* ```
*/

@@ -501,4 +549,6 @@ Reducer.nonEmpty = createOutput(false, function (_, __, ___, halt) {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toArray()))
* // => [1, 2, 3]
* ```
*/

@@ -516,4 +566,6 @@ function toArray() {

* @example
* ```ts
* console.log(Stream.of([1, 'a'], [2, 'b']).reduce(Reducer.toJSMap()))
* // Map { 1 => 'a', 2 => 'b' }
* ```
*/

@@ -531,4 +583,6 @@ function toJSMap() {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toJSSet()))
* // Set {1, 2, 3}
* ```
*/

@@ -546,5 +600,7 @@ function toJSSet() {

* @example
* ```ts
* const red = Reducer.combine(Reducer.sum, Reducer.average)
* console.log(Stream.range({amount: 9 }).reduce(red))
* // => [36, 4]
* ```
*/

@@ -551,0 +607,0 @@ function combine() {

@@ -11,5 +11,7 @@ "use strict";

* @example
* ```ts
* Update(1, 2) // => 2
* Update(1, () => 10) // => 10
* Update(1, v => v + 1) // => 2
* ```
*/

@@ -16,0 +18,0 @@ function Update(value, update) {

@@ -8,2 +8,3 @@ import { __awaiter } from "tslib";

* @example
* ```ts
* AsyncOptLazy.toMaybePromise(1) // => 1

@@ -14,2 +15,3 @@ * AsyncOptLazy.toMaybePromise(() => 1) // => 1

* AsyncOptLazy.toMaybePromise(Promise.resolve(1)) // => Promise(1)
* ```
*/

@@ -26,2 +28,3 @@ function toMaybePromise(optLazy) {

* @example
* ```ts
* AsyncOptLazy.toPromise(1) // => Promise(1)

@@ -32,2 +35,3 @@ * AsyncOptLazy.toPromise(() => 1) // => Promise(1)

* AsyncOptLazy.toPromise(Promise.resolve(1)) // => Promise(1)
* ```
*/

@@ -34,0 +38,0 @@ function toPromise(optLazy) {

@@ -84,6 +84,6 @@ import { __awaiter } from "tslib";

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -103,6 +103,6 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -122,6 +122,6 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -128,0 +128,0 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

@@ -42,5 +42,7 @@ import { Eq } from './internal';

* @example
* ```ts
* const c = Comp.numberComp();
* console.log(c.compare(3, 5))
* // => -2
* ```
*/

@@ -62,2 +64,3 @@ function numberComp() {

* @example
* ```ts
* const c = Comp.booleanComp();

@@ -68,2 +71,3 @@ * console.log(c.compare(false, true) < 0)

* // => 0
* ```
*/

@@ -229,2 +233,3 @@ function booleanComp() {

* @example
* ```ts
* const c = Comp.iterableComp();

@@ -235,2 +240,3 @@ * console.log(c.compare([1, 3, 2], [1, 3, 2]))

* // => true
* ```
*/

@@ -300,10 +306,12 @@ function iterableComp(itemComp) {

* Returns a Comp instance for objects that orders the object keys according to the given `keyComp`, and then compares the corresponding
* values using the given `valueComp`. Objects are then compared as follows:
* - starting with the smallest key of either object:
* - if only one of the objects has the key, the object with the key is considered to be larger than the other
* - if both objects have the key, the values are compared with `valueComp`. If the values are not equal, this result is returned.
* - if the objects have the same keys with the same values, they are considered equal
* values using the given `valueComp`. Objects are then compared as follows:<br/>
* starting with the smallest key of either object:<br/>
* - if only one of the objects has the key, the object with the key is considered to be larger than the other<br/>
* - if both objects have the key, the values are compared with `valueComp`. If the values are not equal, this result is returned.<br/>
*
* if the objects have the same keys with the same values, they are considered equal<br/>
* @param keyComp - (optional) the Comp instance used to order the object keys
* @param valueComp - (optional) the Comp instance used to order the object values
* @example
* ```ts
* const c = Comp.objectComp();

@@ -320,2 +328,3 @@ * console.log(c.compare({ a: 1 }, { a: 1 }))

* // => 0
* ```
*/

@@ -386,2 +395,3 @@ function objectComp(options) {

* @example
* ```ts
* const c = Comp.anyFlatComp();

@@ -391,2 +401,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }) < 0)

* // First object is smaller because the objects are converted to a string with and then compares the resulting string.
* ```
*/

@@ -401,2 +412,3 @@ function anyFlatComp() {

* @example
* ```ts
* const c = Comp.anyShallowComp();

@@ -408,2 +420,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))

* // First object is smaller because the objects are converted to a string and then compares the resulting string.
* ```
*/

@@ -419,2 +432,3 @@ function anyShallowComp() {

* @example
* ```ts
* const c = Comp.anyDeepComp();

@@ -425,2 +439,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))

* // => 0
* ```
*/

@@ -436,2 +451,3 @@ function anyDeepComp() {

* @example
* ```ts
* const c = Comp.withUndefined(Comp.numberComp())

@@ -442,2 +458,3 @@ * console.log(c.compare(undefined, 5) < 0)

* // => 0
* ```
*/

@@ -467,2 +484,3 @@ function withUndefined(comp) {

* @example
* ```ts
* const c = Comp.withNull(Comp.numberComp())

@@ -473,2 +491,3 @@ * console.log(c.compare(null, 5) < 0)

* // => 0
* ```
*/

@@ -497,2 +516,3 @@ function withNull(comp) {

* @example
* ```ts
* const c = Comp.invert(Comp.numberComp())

@@ -503,2 +523,3 @@ * console.log(c.compare(3, 5) > 0)

* // => 0
* ```
*/

@@ -518,5 +539,7 @@ function invert(comp) {

* @example
* ```ts
* const eq = Comp.toEq(Comp.objectComp())
* console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
* // => true
* ```
*/

@@ -523,0 +546,0 @@ function toEq(comp) {

@@ -27,2 +27,3 @@ export var Eq;

* @example
* ```ts
* const eq = Eq.objectIs

@@ -33,2 +34,3 @@ * console.log(eq(5, 5))

* // => false
* ```
*/

@@ -42,2 +44,3 @@ Eq.objectIs = Object.is;

* @example
* ```ts
* const eq = Eq.valueOfEq()

@@ -48,2 +51,3 @@ * console.log(eq(new Number(5), new Number(5)))

* // => false
* ```
*/

@@ -57,2 +61,3 @@ function valueOfEq() {

* @example
* ```ts
* const eq = Eq.dateEq()

@@ -63,2 +68,3 @@ * console.log(eq(new Date(2020, 1, 1), new Date(2020, 1, 1))

* // => false
* ```
*/

@@ -91,2 +97,3 @@ function dateEq() {

* @example
* ```ts
* const eq = Eq.iterableEq();

@@ -97,2 +104,3 @@ * console.log(eq([1, 2, 3], [1, 2, 3])

* // => false
* ```
*/

@@ -135,2 +143,3 @@ function iterableEq(itemEq) {

* @example
* ```ts
* const eq = Eq.objectEq()

@@ -141,2 +150,3 @@ * console.log(eq({ a: 1, b: { c: 2 }}, { b: { c: 2 }, a: 1 }))

* // => false
* ```
*/

@@ -202,2 +212,3 @@ function objectEq(valueEq) {

* @example
* ```ts
* const eq = anyFlatEq()

@@ -208,2 +219,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -220,2 +232,3 @@ function anyFlatEq() {

* @example
* ```ts
* const eq = anyFlatEq()

@@ -228,2 +241,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -241,2 +255,3 @@ function anyShallowEq() {

* @example
* ```ts
* const eq = anyFlatEq()

@@ -249,2 +264,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -262,2 +278,3 @@ function anyDeepEq() {

* @example
* ```ts
* const eq = Eq.createStringCollatorEq()

@@ -268,2 +285,3 @@ * console.log(eq('a', 'a'))

* // => false
* ```
*/

@@ -283,2 +301,3 @@ function createStringCollatorEq(...args) {

* @example
* ```ts
* const eq = Eq.stringCaseInsentitiveEq()

@@ -289,2 +308,3 @@ * console.log(eq('aB', 'Ab'))

* // => false
* ```
*/

@@ -309,2 +329,3 @@ function stringCaseInsentitiveEq() {

* @example
* ```ts
* const eq = Eq.stringCharCodeEq()

@@ -315,2 +336,3 @@ * console.log(eq('a', 'a'))

* // => false
* ```
*/

@@ -330,2 +352,3 @@ function stringCharCodeEq() {

* @example
* ```ts
* const eq = Eq.anyJsonEq()

@@ -336,2 +359,3 @@ * console.log(eq({ a: 1, b: 2 }, { a: 1, b: 2 }))

* // => false
* ```
*/

@@ -347,2 +371,3 @@ function anyJsonEq() {

* @example
* ```ts
* const eq = Eq.tupleSymmetric()

@@ -355,2 +380,3 @@ * console.log(eq([1, 2], [1, 2]))

* // => false
* ```
*/

@@ -357,0 +383,0 @@ function tupleSymmetric(eq = defaultEq()) {

/**
* Throws an `Err.ForcedError` error when called.
* @example
* ```ts
* const emptyMap = HashMap.empty<number, string>()
* emptyMap.get(5, Err);
* // throws: Err.CustomError(message: 'Err: forced to throw error')
* ```
*/

@@ -8,0 +10,0 @@ export function Err() {

@@ -0,2 +1,7 @@

/**
* @packageDocumentation
*
* The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
*/
export * from './internal';
//# sourceMappingURL=index.js.map

@@ -5,5 +5,7 @@ /**

* @example
* ```ts
* OptLazy(1) // => 1
* OptLazy(() => 1) // => 1
* OptLazy(() => () => 1) // => () => 1
* ```
*/

@@ -21,5 +23,7 @@ export function OptLazy(optLazy) {

* @example
* ```ts
* OptLazyOr(1, 'a') // => 1
* OptLazyOr(() => 1, 'a') // => 1
* OptLazyOr((none) => none, 'a') // => 'a'
* ```
*/

@@ -26,0 +30,0 @@ export function OptLazyOr(optLazyOr, otherValue) {

@@ -88,6 +88,6 @@ import { CollectFun, OptLazy } from './internal';

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -99,2 +99,3 @@ * @param stateToResult - a function that converts the current state to an output value

* @example
* ```ts
* const evenNumberOfOnes = Reducer

@@ -108,2 +109,3 @@ * .create(

* // => 'even'
* ```
*/

@@ -117,9 +119,11 @@ function create(init, next, stateToResult) {

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer
* @param stateToResult - (optional) a function that converts the current state to an output value
* @typeparam T - the overall value type
* @example
* ```ts
* const sum = Reducer

@@ -133,2 +137,3 @@ * .createMono(

* // => 9
* ```
*/

@@ -142,6 +147,6 @@ function createMono(init, next, stateToResult) {

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -151,2 +156,4 @@ * @param stateToResult - (optional) a function that converts the current state to an output value

* @typeparam O - the output value type
* @example
* ```ts
* const boolToString = Reducer

@@ -160,2 +167,3 @@ * .createOutput(

* // => 'TFT'
* ```
*/

@@ -169,4 +177,6 @@ function createOutput(init, next, stateToResult) {

* @example
* ```ts
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.sum))
* // => 10
* ```
*/

@@ -177,4 +187,6 @@ Reducer.sum = createMono(0, (state, next) => state + next);

* @example
* ```ts
* console.log(Stream.range({ start: 1, amount: 5 }).reduce(product))
* // => 120
* ```
*/

@@ -189,4 +201,6 @@ Reducer.product = createMono(1, (state, next, _, halt) => {

* @example
* ```ts
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.average));
* // => 2
* ```
*/

@@ -199,5 +213,7 @@ Reducer.average = createMono(0, (avg, value, index) => avg + (value - avg) / (index + 1));

* @example
* ```ts
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
* console.log(stream.minBy((s1, s2) => s1.length - s2.length))
* // 'a'
* ```
*/

@@ -216,4 +232,6 @@ Reducer.minBy = (compFun, otherwise) => {

* @example
* ```ts
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.min()))
* // => 3
* ```
*/

@@ -228,5 +246,7 @@ Reducer.min = (otherwise) => {

* @example
* ```ts
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
* console.log(stream.maxBy((s1, s2) => s1.length - s2.length))
* // 'abcde'
* ```
*/

@@ -245,4 +265,6 @@ Reducer.maxBy = (compFun, otherwise) => {

* @example
* ```ts
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.max()))
* // => 7
* ```
*/

@@ -253,10 +275,12 @@ Reducer.max = (otherwise) => {

/**
* Returns a `Reducer` that joins the given input values into a string using the given options.
* @options - an object containing:
* - sep: (optional) a seperator string value between values in the output
* - start: (optional) a start string to prepend to the output
* - end: (optional) an end string to append to the output
* Returns a `yaReducer` that joins the given input values into a string using the given options.
* @param options - an object containing:<br/>
* - sep: (optional) a seperator string value between values in the output<br/>
* - start: (optional) a start string to prepend to the output<br/>
* - end: (optional) an end string to append to the output<br/>
* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.join({ sep: '-' })))
* // => '1-2-3'
* ```
*/

@@ -276,6 +300,7 @@ function join({ sep = '', start = '', end = '', valueToString = String, } = {}) {

* Returns a `Reducer` that remembers the amount of input items provided.
* @param pred - (optional) a predicate that returns false if the item should not be counted given:
* - value: the current input value
* @param pred - (optional) a predicate that returns false if the item should not be counted given:<br/>
* - value: the current input value<br/>
* - index: the input value index
* @example
* ```ts
* const stream = Stream.range({ amount: 10 })

@@ -286,2 +311,3 @@ * console.log(stream.reduce(Reducer.count()))

* // => 5
* ```
*/

@@ -304,4 +330,6 @@ Reducer.count = (pred) => {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.firstWhere(v => v > 5)))
* // => 6
* ```
*/

@@ -324,4 +352,6 @@ Reducer.firstWhere = (pred, otherwise) => {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
* // => 0
* ```
*/

@@ -344,4 +374,6 @@ Reducer.first = (otherwise) => {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.lastWhere(v => v > 5)))
* // => 9
* ```
*/

@@ -362,4 +394,6 @@ Reducer.lastWhere = (pred, otherwise) => {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
* // => 0
* ```
*/

@@ -374,4 +408,6 @@ Reducer.last = (otherwise) => {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.some(v => v > 5))
* // => true
* ```
*/

@@ -394,4 +430,6 @@ function some(pred) {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.every(v => v < 5))
* // => false
* ```
*/

@@ -415,4 +453,6 @@ function every(pred) {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.contains(5)))
* // => true
* ```
*/

@@ -434,4 +474,6 @@ function contains(elem, eq = Object.is) {

* @example
* ```ts
* console.log(Stream.of(true, false, true)).reduce(Reducer.and))
* // => false
* ```
*/

@@ -448,4 +490,6 @@ Reducer.and = createMono(true, (state, next, _, halt) => {

* @example
* ```ts
* console.log(Stream.of(true, false, true)).reduce(Reducer.or))
* // => true
* ```
*/

@@ -462,4 +506,6 @@ Reducer.or = createMono(false, (state, next, _, halt) => {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.isEmpty))
* // => false
* ```
*/

@@ -473,4 +519,6 @@ Reducer.isEmpty = createOutput(true, (_, __, ___, halt) => {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.nonEmpty))
* // => true
* ```
*/

@@ -484,4 +532,6 @@ Reducer.nonEmpty = createOutput(false, (_, __, ___, halt) => {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toArray()))
* // => [1, 2, 3]
* ```
*/

@@ -499,4 +549,6 @@ function toArray() {

* @example
* ```ts
* console.log(Stream.of([1, 'a'], [2, 'b']).reduce(Reducer.toJSMap()))
* // Map { 1 => 'a', 2 => 'b' }
* ```
*/

@@ -514,4 +566,6 @@ function toJSMap() {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toJSSet()))
* // Set {1, 2, 3}
* ```
*/

@@ -529,5 +583,7 @@ function toJSSet() {

* @example
* ```ts
* const red = Reducer.combine(Reducer.sum, Reducer.average)
* console.log(Stream.range({amount: 9 }).reduce(red))
* // => [36, 4]
* ```
*/

@@ -534,0 +590,0 @@ function combine(...reducers) {

@@ -8,5 +8,7 @@ /**

* @example
* ```ts
* Update(1, 2) // => 2
* Update(1, () => 10) // => 10
* Update(1, v => v + 1) // => 2
* ```
*/

@@ -13,0 +15,0 @@ export function Update(value, update) {

@@ -17,2 +17,3 @@ import type { OptLazy } from './internal';

* @example
* ```ts
* AsyncOptLazy.toMaybePromise(1) // => 1

@@ -23,2 +24,3 @@ * AsyncOptLazy.toMaybePromise(() => 1) // => 1

* AsyncOptLazy.toMaybePromise(Promise.resolve(1)) // => Promise(1)
* ```
*/

@@ -30,2 +32,3 @@ function toMaybePromise<T>(optLazy: AsyncOptLazy<T>): MaybePromise<T>;

* @example
* ```ts
* AsyncOptLazy.toPromise(1) // => Promise(1)

@@ -36,4 +39,5 @@ * AsyncOptLazy.toPromise(() => 1) // => Promise(1)

* AsyncOptLazy.toPromise(Promise.resolve(1)) // => Promise(1)
* ```
*/
function toPromise<T>(optLazy: AsyncOptLazy<T>): Promise<T>;
}

@@ -36,7 +36,8 @@ import { AsyncCollectFun, AsyncOptLazy, MaybePromise, Reducer } from './internal';

* Returns an `AsyncReducer` instance that only passes values to the reducer that satisy the given `pred` predicate.
* @param pred - a potaentially asynchronous function that returns true if the value should be passed to the reducer based on the following inputs:
* - value: the current input value
* - index: the current input index
* @param pred - a potaentially asynchronous function that returns true if the value should be passed to the reducer based on the following inputs:<br/>
* - value: the current input value<br/>
* - index: the current input index<br/>
* - halt: function that, when called, ensures no more new values are passed to the reducer
* @example
* ```ts
* AsyncReducer

@@ -46,2 +47,3 @@ * .createMono(0, async (c, v) => c + v)

* // this reducer will only sum values larger than 10
* ```
*/

@@ -51,6 +53,7 @@ filterInput(pred: (value: I, index: number, halt: () => void) => MaybePromise<boolean>): AsyncReducer<I, O>;

* Returns an `AsyncReducer` instance that converts its input values using given `mapFun` before passing them to the reducer.
* @param mapFun - a potentially asynchronous function that returns a new value to pass to the reducer based on the following inputs:
* - value: the current input value
* @param mapFun - a potentially asynchronous function that returns a new value to pass to the reducer based on the following inputs:<br/>
* - value: the current input value<br/>
* - index: the current input index
* @example
* ```ts
* AsyncReducer

@@ -60,2 +63,3 @@ * .createMono(0, async (c, v) => c + v)

* // this reducer will double all input values before summing them
* ```
*/

@@ -65,8 +69,9 @@ mapInput<I2>(mapFun: (value: I2, index: number) => MaybePromise<I>): AsyncReducer<I2, O>;

* Returns an `AsyncReducer` instance that converts or filters its input values using given `collectFun` before passing them to the reducer.
* @param collectFun - a function receiving
* * `value`: the next value
* * `index`: the value index
* * `skip`: a token that, when returned, will not add a value to the resulting collection
* * `halt`: a function that, when called, ensures no next elements are passed
* @param collectFun - a function receiving<br/>
* - `value`: the next value<br/>
* - `index`: the value index<br/>
* - `skip`: a token that, when returned, will not add a value to the resulting collection<br/>
* - `halt`: a function that, when called, ensures no next elements are passed
* @example
* ```ts
* AsyncReducer

@@ -77,2 +82,3 @@ * .createMono(0, async (c, v) => c + v)

* // and will skip all values smaller than 10
* ```
*/

@@ -83,2 +89,4 @@ collectInput<I2>(collectFun: AsyncCollectFun<I2, I>): AsyncReducer<I2, O>;

* @param mapFun - a potentially asynchronous function that takes the current output value and converts it to a new output value
* @example
* ```ts
* AsyncReducer

@@ -88,2 +96,3 @@ * .createMono(0, async (c, v) => c + v)

* // this reducer will convert all its results to string before returning them
* ```
*/

@@ -95,2 +104,3 @@ mapOutput<O2>(mapFun: (value: O) => MaybePromise<O2>): AsyncReducer<I, O2>;

* @example
* ```ts
* await AsyncStream

@@ -104,2 +114,3 @@ * .from(Stream.range({ end: 10 }))

* // => 1
* ```
*/

@@ -111,2 +122,3 @@ takeInput(amount: number): AsyncReducer<I, O>;

* @example
* ```ts
* await AsyncStream

@@ -120,2 +132,3 @@ * .from(Stream.range({ end: 10 }))

* // => 19
* ```
*/

@@ -128,2 +141,3 @@ dropInput(amount: number): AsyncReducer<I, O>;

* @example
* ```ts
* await AsyncStream

@@ -137,2 +151,3 @@ * .from(Stream.range({ end: 10 }))

* // => 3
* ```
*/

@@ -164,6 +179,6 @@ sliceInput(from?: number, amount?: number): AsyncReducer<I, O>;

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -180,6 +195,6 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -196,6 +211,6 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -202,0 +217,0 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

@@ -13,2 +13,3 @@ import { Eq } from './internal';

* @example
* ```ts
* const c = Comp.numberComp()

@@ -21,2 +22,3 @@ * console.log(c.compare(5, 5))

* // => 2
* ```
*/

@@ -28,2 +30,3 @@ compare(value1: K, value2: K): number;

* @example
* ```ts
* const c = Comp.numberComp()

@@ -34,2 +37,3 @@ * console.log(c.isComparable(5))

* // => false
* ```
*/

@@ -46,5 +50,7 @@ isComparable(obj: any): obj is K;

* @example
* ```ts
* const c = Comp.numberComp();
* console.log(c.compare(3, 5))
* // => -2
* ```
*/

@@ -55,2 +61,3 @@ function numberComp(): Comp<number>;

* @example
* ```ts
* const c = Comp.booleanComp();

@@ -61,2 +68,3 @@ * console.log(c.compare(false, true) < 0)

* // => 0
* ```
*/

@@ -108,2 +116,3 @@ function booleanComp(): Comp<boolean>;

* @example
* ```ts
* const c = Comp.iterableComp();

@@ -114,2 +123,3 @@ * console.log(c.compare([1, 3, 2], [1, 3, 2]))

* // => true
* ```
*/

@@ -119,10 +129,12 @@ function iterableComp<T>(itemComp?: Comp<T>): Comp<Iterable<T>>;

* Returns a Comp instance for objects that orders the object keys according to the given `keyComp`, and then compares the corresponding
* values using the given `valueComp`. Objects are then compared as follows:
* - starting with the smallest key of either object:
* - if only one of the objects has the key, the object with the key is considered to be larger than the other
* - if both objects have the key, the values are compared with `valueComp`. If the values are not equal, this result is returned.
* - if the objects have the same keys with the same values, they are considered equal
* values using the given `valueComp`. Objects are then compared as follows:<br/>
* starting with the smallest key of either object:<br/>
* - if only one of the objects has the key, the object with the key is considered to be larger than the other<br/>
* - if both objects have the key, the values are compared with `valueComp`. If the values are not equal, this result is returned.<br/>
*
* if the objects have the same keys with the same values, they are considered equal<br/>
* @param keyComp - (optional) the Comp instance used to order the object keys
* @param valueComp - (optional) the Comp instance used to order the object values
* @example
* ```ts
* const c = Comp.objectComp();

@@ -139,2 +151,3 @@ * console.log(c.compare({ a: 1 }, { a: 1 }))

* // => 0
* ```
*/

@@ -149,2 +162,3 @@ function objectComp(options?: {

* @example
* ```ts
* const c = Comp.anyFlatComp();

@@ -154,2 +168,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }) < 0)

* // First object is smaller because the objects are converted to a string with and then compares the resulting string.
* ```
*/

@@ -161,2 +176,3 @@ function anyFlatComp<T>(): Comp<T>;

* @example
* ```ts
* const c = Comp.anyShallowComp();

@@ -168,2 +184,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))

* // First object is smaller because the objects are converted to a string and then compares the resulting string.
* ```
*/

@@ -176,2 +193,3 @@ function anyShallowComp<T>(): Comp<T>;

* @example
* ```ts
* const c = Comp.anyDeepComp();

@@ -182,2 +200,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))

* // => 0
* ```
*/

@@ -190,2 +209,3 @@ function anyDeepComp<T>(): Comp<T>;

* @example
* ```ts
* const c = Comp.withUndefined(Comp.numberComp())

@@ -196,2 +216,3 @@ * console.log(c.compare(undefined, 5) < 0)

* // => 0
* ```
*/

@@ -204,2 +225,3 @@ function withUndefined<T>(comp: Comp<T>): Comp<T | undefined>;

* @example
* ```ts
* const c = Comp.withNull(Comp.numberComp())

@@ -210,2 +232,3 @@ * console.log(c.compare(null, 5) < 0)

* // => 0
* ```
*/

@@ -217,2 +240,3 @@ function withNull<T>(comp: Comp<T>): Comp<T | null>;

* @example
* ```ts
* const c = Comp.invert(Comp.numberComp())

@@ -223,2 +247,3 @@ * console.log(c.compare(3, 5) > 0)

* // => 0
* ```
*/

@@ -230,7 +255,9 @@ function invert<T>(comp: Comp<T>): Comp<T>;

* @example
* ```ts
* const eq = Comp.toEq(Comp.objectComp())
* console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
* // => true
* ```
*/
function toEq<T>(comp: Comp<T>): Eq<T>;
}

@@ -14,2 +14,3 @@ /**

* @example
* ```ts
* const eq = Eq.objectIs

@@ -20,2 +21,3 @@ * console.log(eq(5, 5))

* // => false
* ```
*/

@@ -28,2 +30,3 @@ const objectIs: Eq<any>;

* @example
* ```ts
* const eq = Eq.valueOfEq()

@@ -34,2 +37,3 @@ * console.log(eq(new Number(5), new Number(5)))

* // => false
* ```
*/

@@ -42,2 +46,3 @@ function valueOfEq<T extends {

* @example
* ```ts
* const eq = Eq.dateEq()

@@ -48,2 +53,3 @@ * console.log(eq(new Date(2020, 1, 1), new Date(2020, 1, 1))

* // => false
* ```
*/

@@ -56,2 +62,3 @@ function dateEq(): Eq<Date>;

* @example
* ```ts
* const eq = Eq.iterableEq();

@@ -62,2 +69,3 @@ * console.log(eq([1, 2, 3], [1, 2, 3])

* // => false
* ```
*/

@@ -71,2 +79,3 @@ function iterableEq<T>(itemEq?: Eq<T>): Eq<Iterable<T>>;

* @example
* ```ts
* const eq = Eq.objectEq()

@@ -77,2 +86,3 @@ * console.log(eq({ a: 1, b: { c: 2 }}, { b: { c: 2 }, a: 1 }))

* // => false
* ```
*/

@@ -85,2 +95,3 @@ function objectEq<V = any>(valueEq?: Eq<V>): Eq<Record<any, V>>;

* @example
* ```ts
* const eq = anyFlatEq()

@@ -91,2 +102,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -100,2 +112,3 @@ function anyFlatEq<T = any>(): Eq<T>;

* @example
* ```ts
* const eq = anyFlatEq()

@@ -108,2 +121,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -118,2 +132,3 @@ function anyShallowEq<T = any>(): Eq<T>;

* @example
* ```ts
* const eq = anyFlatEq()

@@ -126,2 +141,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -134,2 +150,3 @@ function anyDeepEq<T = any>(): Eq<T>;

* @example
* ```ts
* const eq = Eq.createStringCollatorEq()

@@ -140,2 +157,3 @@ * console.log(eq('a', 'a'))

* // => false
* ```
*/

@@ -146,2 +164,3 @@ function createStringCollatorEq(...args: ConstructorParameters<typeof Intl.Collator>): Eq<string>;

* @example
* ```ts
* const eq = Eq.stringCaseInsentitiveEq()

@@ -152,2 +171,3 @@ * console.log(eq('aB', 'Ab'))

* // => false
* ```
*/

@@ -158,2 +178,3 @@ function stringCaseInsentitiveEq(): Eq<string>;

* @example
* ```ts
* const eq = Eq.stringCharCodeEq()

@@ -164,2 +185,3 @@ * console.log(eq('a', 'a'))

* // => false
* ```
*/

@@ -171,2 +193,3 @@ function stringCharCodeEq(): Eq<string>;

* @example
* ```ts
* const eq = Eq.anyJsonEq()

@@ -177,2 +200,3 @@ * console.log(eq({ a: 1, b: 2 }, { a: 1, b: 2 }))

* // => false
* ```
*/

@@ -185,2 +209,3 @@ function anyJsonEq(): Eq<any>;

* @example
* ```ts
* const eq = Eq.tupleSymmetric()

@@ -193,4 +218,5 @@ * console.log(eq([1, 2], [1, 2]))

* // => false
* ```
*/
function tupleSymmetric<T>(eq?: Eq<T>): Eq<readonly [T, T]>;
}
/**
* Throws an `Err.ForcedError` error when called.
* @example
* ```ts
* const emptyMap = HashMap.empty<number, string>()
* emptyMap.get(5, Err);
* // throws: Err.CustomError(message: 'Err: forced to throw error')
* ```
*/

@@ -8,0 +10,0 @@ export declare function Err(): never;

@@ -5,15 +5,16 @@ import type { Range } from './internal';

* If a start or end is defined, a tuple can be used where the second item is a boolean
* indicating whether that end is inclusive or exclusive.
* An IndexRange can have one of the following forms:
* - { amount: number }
* - { start: number }
* - { start: number, amount: number }
* - { start: number, end: number }
* - { start: number, end: [number, boolean] }
* - { start: [number, boolean] }
* - { start: [number, boolean], amount: number }
* - { start: [number, boolean], end: number }
* - { start: [number, boolean], end: [number, boolean] }
* - { end: number }
* - { end: [number, boolean] }
* indicating whether that end is inclusive or exclusive.<br/>
* An IndexRange can have one of the following forms:<br/>
* <br/>
* - { amount: number }<br/>
* - { start: number }<br/>
* - { start: number, amount: number }<br/>
* - { start: number, end: number }<br/>
* - { start: number, end: [number, boolean] }<br/>
* - { start: [number, boolean] }<br/>
* - { start: [number, boolean], amount: number }<br/>
* - { start: [number, boolean], end: number }<br/>
* - { start: [number, boolean], end: [number, boolean] }<br/>
* - { end: number }<br/>
* - { end: [number, boolean] }<br/>
*/

@@ -20,0 +21,0 @@ export declare type IndexRange = {

@@ -0,1 +1,6 @@

/**
* @packageDocumentation
*
* The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
*/
export * from './internal';

@@ -10,5 +10,7 @@ /**

* @example
* ```ts
* OptLazy(1) // => 1
* OptLazy(() => 1) // => 1
* OptLazy(() => () => 1) // => () => 1
* ```
*/

@@ -29,6 +31,8 @@ export declare function OptLazy<T>(optLazy: OptLazy<T>): T;

* @example
* ```ts
* OptLazyOr(1, 'a') // => 1
* OptLazyOr(() => 1, 'a') // => 1
* OptLazyOr((none) => none, 'a') // => 'a'
* ```
*/
export declare function OptLazyOr<T, O>(optLazyOr: OptLazyOr<T, O>, otherValue: O): T | O;
/**
* A range definition for any type of (orderable) value.
* If a start or end is defined, a tuple can be used where the second item is a boolean
* indicating whether that end is inclusive or exclusive.
* An Range of type T can have one of the following forms:
* - { end: T }
* - { end: [T, boolean] }
* - { start: T }
* - { start: T, end: T }
* - { start: T, end: [T, boolean] }
* - { start: [T, boolean] }
* - { start: [T, boolean], end: T }
* - { start: [T, boolean], end: [T, boolean] }
* indicating whether that end is inclusive (true) or exclusive (false).<br/>
* A Range of type T can have one of the following forms:<br/>
* <br/>
* - { end: T }<br/>
* - { end: [T, boolean] }<br/>
* - { start: T }<br/>
* - { start: T, end: T }<br/>
* - { start: T, end: [T, boolean] }<br/>
* - { start: [T, boolean] }<br/>
* - { start: [T, boolean], end: T }<br/>
* - { start: [T, boolean], end: [T, boolean] }<br/>
*/

@@ -15,0 +16,0 @@ export declare type Range<T> = {

@@ -44,9 +44,11 @@ import { CollectFun, Eq, OptLazy } from './internal';

* Returns a `Reducer` instance that only passes values to the reducer that satisy the given `pred` predicate.
* @param pred - a function that returns true if the value should be passed to the reducer based on the following inputs:
* - value: the current input value
* - index: the current input index
* @param pred - a function that returns true if the value should be passed to the reducer based on the following inputs:<br/>
* - value: the current input value<br/>
* - index: the current input index<br/>
* - halt: function that, when called, ensures no more new values are passed to the reducer
* @example
* ```ts
* Reducer.sum.filterInput(v => v > 10)
* // this reducer will only sum values larger than 10
* ```
*/

@@ -56,8 +58,10 @@ filterInput(pred: (value: I, index: number, halt: () => void) => boolean): Reducer<I, O>;

* Returns a `Reducer` instance that converts its input values using given `mapFun` before passing them to the reducer.
* @param mapFun - a function that returns a new value to pass to the reducer based on the following inputs:
* - value: the current input value
* @param mapFun - a function that returns a new value to pass to the reducer based on the following inputs:<br/>
* - value: the current input value<br/>
* - index: the current input index
* @example
* ```ts
* Reducer.sum.mapInput(v => v * 2)
* // this reducer will double all input values before summing them
* ```
*/

@@ -67,11 +71,13 @@ mapInput<I2>(mapFun: (value: I2, index: number) => I): Reducer<I2, O>;

* Returns a `Reducer` instance that converts or filters its input values using given `collectFun` before passing them to the reducer.
* @param collectFun - a function receiving
* * `value`: the next value
* * `index`: the value index
* * `skip`: a token that, when returned, will not add a value to the resulting collection
* * `halt`: a function that, when called, ensures no next elements are passed
* @param collectFun - a function receiving<br/>
* - `value`: the next value<br/>
* - `index`: the value index<br/>
* - `skip`: a token that, when returned, will not add a value to the resulting collection<br/>
* - `halt`: a function that, when called, ensures no next elements are passed
* @example
* ```ts
* Reducer.sum.collectInput((v, _, skip) => v <= 10 ? skip : v * 2)
* // this reducer will double all input values larger thant 10 before summing them,
* // and will skip all values smaller than 10
* ```
*/

@@ -82,4 +88,7 @@ collectInput<I2>(collectFun: CollectFun<I2, I>): Reducer<I2, O>;

* @param mapFun - a function that takes the current output value and converts it to a new output value
* @example
* ```ts
* Reducer.sum.mapOutput(String)
* // this reducer will convert all its results to string before returning them
* ```
*/

@@ -91,4 +100,6 @@ mapOutput<O2>(mapFun: (value: O) => O2): Reducer<I, O2>;

* @example
* ```ts
* Stream.range({ end: 10 }).reduce(Reducer.sum.takeInput(2))
* // => 1
* ```
*/

@@ -100,4 +111,6 @@ takeInput(amount: number): Reducer<I, O>;

* @example
* ```ts
* Stream.range({ end: 10 }).reduce(Reducer.sum.dropInput(9))
* // => 19
* ```
*/

@@ -110,4 +123,6 @@ dropInput(amount: number): Reducer<I, O>;

* @example
* ```ts
* Stream.range({ end: 10 }).reduce(Reducer.sum.sliceInput(1, 2))
* // => 3
* ```
*/

@@ -138,6 +153,6 @@ sliceInput(from?: number, amount?: number): Reducer<I, O>;

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -149,2 +164,3 @@ * @param stateToResult - a function that converts the current state to an output value

* @example
* ```ts
* const evenNumberOfOnes = Reducer

@@ -158,2 +174,3 @@ * .create(

* // => 'even'
* ```
*/

@@ -164,9 +181,11 @@ function create<I, O = I, S = O>(init: Reducer.Init<S>, next: (current: S, next: I, index: number, halt: () => void) => S, stateToResult: (state: S) => O): Reducer<I, O>;

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer
* @param stateToResult - (optional) a function that converts the current state to an output value
* @typeparam T - the overall value type
* @example
* ```ts
* const sum = Reducer

@@ -180,2 +199,3 @@ * .createMono(

* // => 9
* ```
*/

@@ -186,6 +206,6 @@ function createMono<T>(init: Reducer.Init<T>, next: (current: T, next: T, index: number, halt: () => void) => T, stateToResult?: (state: T) => T): Reducer<T>;

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -195,2 +215,4 @@ * @param stateToResult - (optional) a function that converts the current state to an output value

* @typeparam O - the output value type
* @example
* ```ts
* const boolToString = Reducer

@@ -204,2 +226,3 @@ * .createOutput(

* // => 'TFT'
* ```
*/

@@ -210,4 +233,6 @@ function createOutput<I, O = I>(init: Reducer.Init<O>, next: (current: O, next: I, index: number, halt: () => void) => O, stateToResult?: (state: O) => O): Reducer<I, O>;

* @example
* ```ts
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.sum))
* // => 10
* ```
*/

@@ -218,4 +243,6 @@ const sum: Reducer<number, number>;

* @example
* ```ts
* console.log(Stream.range({ start: 1, amount: 5 }).reduce(product))
* // => 120
* ```
*/

@@ -226,4 +253,6 @@ const product: Reducer<number, number>;

* @example
* ```ts
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.average));
* // => 2
* ```
*/

@@ -236,5 +265,7 @@ const average: Reducer<number, number>;

* @example
* ```ts
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
* console.log(stream.minBy((s1, s2) => s1.length - s2.length))
* // 'a'
* ```
*/

@@ -249,4 +280,6 @@ const minBy: {

* @example
* ```ts
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.min()))
* // => 3
* ```
*/

@@ -262,5 +295,7 @@ const min: {

* @example
* ```ts
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
* console.log(stream.maxBy((s1, s2) => s1.length - s2.length))
* // 'abcde'
* ```
*/

@@ -275,4 +310,6 @@ const maxBy: {

* @example
* ```ts
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.max()))
* // => 7
* ```
*/

@@ -284,10 +321,12 @@ const max: {

/**
* Returns a `Reducer` that joins the given input values into a string using the given options.
* @options - an object containing:
* - sep: (optional) a seperator string value between values in the output
* - start: (optional) a start string to prepend to the output
* - end: (optional) an end string to append to the output
* Returns a `yaReducer` that joins the given input values into a string using the given options.
* @param options - an object containing:<br/>
* - sep: (optional) a seperator string value between values in the output<br/>
* - start: (optional) a start string to prepend to the output<br/>
* - end: (optional) an end string to append to the output<br/>
* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.join({ sep: '-' })))
* // => '1-2-3'
* ```
*/

@@ -302,6 +341,7 @@ function join<T>({ sep, start, end, valueToString, }?: {

* Returns a `Reducer` that remembers the amount of input items provided.
* @param pred - (optional) a predicate that returns false if the item should not be counted given:
* - value: the current input value
* @param pred - (optional) a predicate that returns false if the item should not be counted given:<br/>
* - value: the current input value<br/>
* - index: the input value index
* @example
* ```ts
* const stream = Stream.range({ amount: 10 })

@@ -312,2 +352,3 @@ * console.log(stream.reduce(Reducer.count()))

* // => 5
* ```
*/

@@ -325,4 +366,6 @@ const count: {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.firstWhere(v => v > 5)))
* // => 6
* ```
*/

@@ -339,4 +382,6 @@ const firstWhere: {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
* // => 0
* ```
*/

@@ -354,4 +399,6 @@ const first: {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.lastWhere(v => v > 5)))
* // => 9
* ```
*/

@@ -368,4 +415,6 @@ const lastWhere: {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
* // => 0
* ```
*/

@@ -380,4 +429,6 @@ const last: {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.some(v => v > 5))
* // => true
* ```
*/

@@ -389,4 +440,6 @@ function some<T>(pred: (value: T, index: number) => boolean): Reducer<T, boolean>;

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.every(v => v < 5))
* // => false
* ```
*/

@@ -399,4 +452,6 @@ function every<T>(pred: (value: T, index: number) => boolean): Reducer<T, boolean>;

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.contains(5)))
* // => true
* ```
*/

@@ -407,4 +462,6 @@ function contains<T>(elem: T, eq?: Eq<T>): Reducer<T, boolean>;

* @example
* ```ts
* console.log(Stream.of(true, false, true)).reduce(Reducer.and))
* // => false
* ```
*/

@@ -415,4 +472,6 @@ const and: Reducer<boolean, boolean>;

* @example
* ```ts
* console.log(Stream.of(true, false, true)).reduce(Reducer.or))
* // => true
* ```
*/

@@ -423,4 +482,6 @@ const or: Reducer<boolean, boolean>;

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.isEmpty))
* // => false
* ```
*/

@@ -431,4 +492,6 @@ const isEmpty: Reducer<any, boolean>;

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.nonEmpty))
* // => true
* ```
*/

@@ -439,4 +502,6 @@ const nonEmpty: Reducer<any, boolean>;

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toArray()))
* // => [1, 2, 3]
* ```
*/

@@ -448,4 +513,6 @@ function toArray<T>(): Reducer<T, T[]>;

* @example
* ```ts
* console.log(Stream.of([1, 'a'], [2, 'b']).reduce(Reducer.toJSMap()))
* // Map { 1 => 'a', 2 => 'b' }
* ```
*/

@@ -457,4 +524,6 @@ function toJSMap<K, V>(): Reducer<[K, V], Map<K, V>>;

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toJSSet()))
* // Set {1, 2, 3}
* ```
*/

@@ -466,5 +535,7 @@ function toJSSet<T>(): Reducer<T, Set<T>>;

* @example
* ```ts
* const red = Reducer.combine(Reducer.sum, Reducer.average)
* console.log(Stream.range({amount: 9 }).reduce(red))
* // => [36, 4]
* ```
*/

@@ -471,0 +542,0 @@ function combine<T, R extends readonly [unknown, unknown, ...unknown[]]>(...reducers: {

@@ -24,6 +24,2 @@ /**

/**
* A stronger version of `Omit`, which only accepts keys that are in type T.
*/
export declare type OmitStrong<T, K extends keyof T> = Omit<T, K>;
/**
* Utility type to convert some object to a JSON serializable format.

@@ -30,0 +26,0 @@ * @typeparam V - the `value` type

@@ -12,6 +12,8 @@ /**

* @example
* ```ts
* Update(1, 2) // => 2
* Update(1, () => 10) // => 10
* Update(1, v => v + 1) // => 2
* ```
*/
export declare function Update<T>(value: T, update: Update<T>): T;
{
"name": "@rimbu/common",
"version": "0.8.2",
"version": "0.9.0",
"description": "Common types and objects used in many other Rimbu packages",

@@ -41,3 +41,3 @@ "keywords": [

"build": "yarn clean && yarn bundle",
"build:deno": "rimraf deno_dist ../../deno_dist/common && denoify && cp ../../config/mod_ts_template deno_dist/mod.ts && mv deno_dist ../../deno_dist/common",
"build:deno": "rimraf deno_dist ../../deno_dist/common && denoify && mv deno_dist ../../deno_dist/common",
"bundle": "yarn bundle:main && yarn bundle:module && yarn bundle:types",

@@ -48,2 +48,3 @@ "bundle:main": "tsc --p tsconfig.main.json",

"clean": "rimraf dist",
"extract-api": "api-extractor run --local --verbose",
"format": "yarn format:base --write",

@@ -61,2 +62,3 @@ "format:base": "prettier \"{!CHANGELOG.md}|**/**/*.{ts,tsx,js,json,md}\"",

"denoify": {
"index": "src/index.ts",
"replacer": "../../config/denoify-rimbu-replacer.js"

@@ -67,3 +69,3 @@ },

},
"gitHead": "1594b907f4dbbd994a52f0e2e94ffd9217420ff5"
"gitHead": "7c60bf40f3479524fa9d603a75b33f914d2feb28"
}

@@ -20,2 +20,3 @@ import type { OptLazy } from './internal';

* @example
* ```ts
* AsyncOptLazy.toMaybePromise(1) // => 1

@@ -26,2 +27,3 @@ * AsyncOptLazy.toMaybePromise(() => 1) // => 1

* AsyncOptLazy.toMaybePromise(Promise.resolve(1)) // => Promise(1)
* ```
*/

@@ -37,2 +39,3 @@ export function toMaybePromise<T>(optLazy: AsyncOptLazy<T>): MaybePromise<T> {

* @example
* ```ts
* AsyncOptLazy.toPromise(1) // => Promise(1)

@@ -43,2 +46,3 @@ * AsyncOptLazy.toPromise(() => 1) // => Promise(1)

* AsyncOptLazy.toPromise(Promise.resolve(1)) // => Promise(1)
* ```
*/

@@ -45,0 +49,0 @@ export async function toPromise<T>(optLazy: AsyncOptLazy<T>): Promise<T> {

@@ -48,7 +48,8 @@ import {

* Returns an `AsyncReducer` instance that only passes values to the reducer that satisy the given `pred` predicate.
* @param pred - a potaentially asynchronous function that returns true if the value should be passed to the reducer based on the following inputs:
* - value: the current input value
* - index: the current input index
* @param pred - a potaentially asynchronous function that returns true if the value should be passed to the reducer based on the following inputs:<br/>
* - value: the current input value<br/>
* - index: the current input index<br/>
* - halt: function that, when called, ensures no more new values are passed to the reducer
* @example
* ```ts
* AsyncReducer

@@ -58,2 +59,3 @@ * .createMono(0, async (c, v) => c + v)

* // this reducer will only sum values larger than 10
* ```
*/

@@ -65,6 +67,7 @@ filterInput(

* Returns an `AsyncReducer` instance that converts its input values using given `mapFun` before passing them to the reducer.
* @param mapFun - a potentially asynchronous function that returns a new value to pass to the reducer based on the following inputs:
* - value: the current input value
* @param mapFun - a potentially asynchronous function that returns a new value to pass to the reducer based on the following inputs:<br/>
* - value: the current input value<br/>
* - index: the current input index
* @example
* ```ts
* AsyncReducer

@@ -74,2 +77,3 @@ * .createMono(0, async (c, v) => c + v)

* // this reducer will double all input values before summing them
* ```
*/

@@ -81,8 +85,9 @@ mapInput<I2>(

* Returns an `AsyncReducer` instance that converts or filters its input values using given `collectFun` before passing them to the reducer.
* @param collectFun - a function receiving
* * `value`: the next value
* * `index`: the value index
* * `skip`: a token that, when returned, will not add a value to the resulting collection
* * `halt`: a function that, when called, ensures no next elements are passed
* @param collectFun - a function receiving<br/>
* - `value`: the next value<br/>
* - `index`: the value index<br/>
* - `skip`: a token that, when returned, will not add a value to the resulting collection<br/>
* - `halt`: a function that, when called, ensures no next elements are passed
* @example
* ```ts
* AsyncReducer

@@ -93,2 +98,3 @@ * .createMono(0, async (c, v) => c + v)

* // and will skip all values smaller than 10
* ```
*/

@@ -99,2 +105,4 @@ collectInput<I2>(collectFun: AsyncCollectFun<I2, I>): AsyncReducer<I2, O>;

* @param mapFun - a potentially asynchronous function that takes the current output value and converts it to a new output value
* @example
* ```ts
* AsyncReducer

@@ -104,2 +112,3 @@ * .createMono(0, async (c, v) => c + v)

* // this reducer will convert all its results to string before returning them
* ```
*/

@@ -111,2 +120,3 @@ mapOutput<O2>(mapFun: (value: O) => MaybePromise<O2>): AsyncReducer<I, O2>;

* @example
* ```ts
* await AsyncStream

@@ -120,2 +130,3 @@ * .from(Stream.range({ end: 10 }))

* // => 1
* ```
*/

@@ -127,2 +138,3 @@ takeInput(amount: number): AsyncReducer<I, O>;

* @example
* ```ts
* await AsyncStream

@@ -136,2 +148,3 @@ * .from(Stream.range({ end: 10 }))

* // => 19
* ```
*/

@@ -144,2 +157,3 @@ dropInput(amount: number): AsyncReducer<I, O>;

* @example
* ```ts
* await AsyncStream

@@ -153,2 +167,3 @@ * .from(Stream.range({ end: 10 }))

* // => 3
* ```
*/

@@ -286,6 +301,6 @@ sliceInput(from?: number, amount?: number): AsyncReducer<I, O>;

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -315,6 +330,6 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -344,6 +359,6 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

* @param init - the optionally lazy and/or promised initial state value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns (potentially asynchronously) the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -350,0 +365,0 @@ * @param stateToResult - a potentially asynchronous function that converts the current state to an output value

@@ -14,2 +14,3 @@ import { Eq } from './internal';

* @example
* ```ts
* const c = Comp.numberComp()

@@ -22,2 +23,3 @@ * console.log(c.compare(5, 5))

* // => 2
* ```
*/

@@ -29,2 +31,3 @@ compare(value1: K, value2: K): number;

* @example
* ```ts
* const c = Comp.numberComp()

@@ -35,2 +38,3 @@ * console.log(c.isComparable(5))

* // => false
* ```
*/

@@ -80,5 +84,7 @@ isComparable(obj: any): obj is K;

* @example
* ```ts
* const c = Comp.numberComp();
* console.log(c.compare(3, 5))
* // => -2
* ```
*/

@@ -101,2 +107,3 @@ export function numberComp(): Comp<number> {

* @example
* ```ts
* const c = Comp.booleanComp();

@@ -107,2 +114,3 @@ * console.log(c.compare(false, true) < 0)

* // => 0
* ```
*/

@@ -243,3 +251,3 @@ export function booleanComp(): Comp<boolean> {

},
compare(v1, v2) {
compare(v1, v2): number {
return valueComp.compare(v1.valueOf(), v2.valueOf());

@@ -267,3 +275,3 @@ },

},
compare(v1, v2) {
compare(v1, v2): number {
const iter1 = v1[Symbol.iterator]();

@@ -295,2 +303,3 @@ const iter2 = v2[Symbol.iterator]();

* @example
* ```ts
* const c = Comp.iterableComp();

@@ -301,2 +310,3 @@ * console.log(c.compare([1, 3, 2], [1, 3, 2]))

* // => true
* ```
*/

@@ -343,3 +353,3 @@ export function iterableComp<T>(itemComp?: Comp<T>): Comp<Iterable<T>> {

},
compare(v1, v2) {
compare(v1, v2): number {
const keys1 = Object.keys(v1);

@@ -386,10 +396,12 @@ const keys2 = Object.keys(v2);

* Returns a Comp instance for objects that orders the object keys according to the given `keyComp`, and then compares the corresponding
* values using the given `valueComp`. Objects are then compared as follows:
* - starting with the smallest key of either object:
* - if only one of the objects has the key, the object with the key is considered to be larger than the other
* - if both objects have the key, the values are compared with `valueComp`. If the values are not equal, this result is returned.
* - if the objects have the same keys with the same values, they are considered equal
* values using the given `valueComp`. Objects are then compared as follows:<br/>
* starting with the smallest key of either object:<br/>
* - if only one of the objects has the key, the object with the key is considered to be larger than the other<br/>
* - if both objects have the key, the values are compared with `valueComp`. If the values are not equal, this result is returned.<br/>
*
* if the objects have the same keys with the same values, they are considered equal<br/>
* @param keyComp - (optional) the Comp instance used to order the object keys
* @param valueComp - (optional) the Comp instance used to order the object values
* @example
* ```ts
* const c = Comp.objectComp();

@@ -406,2 +418,3 @@ * console.log(c.compare({ a: 1 }, { a: 1 }))

* // => 0
* ```
*/

@@ -422,3 +435,3 @@ export function objectComp(options?: {

},
compare(v1, v2) {
compare(v1, v2): number {
if (Object.is(v1, v2)) return 0;

@@ -490,2 +503,3 @@

* @example
* ```ts
* const c = Comp.anyFlatComp();

@@ -495,2 +509,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }) < 0)

* // First object is smaller because the objects are converted to a string with and then compares the resulting string.
* ```
*/

@@ -505,2 +520,3 @@ export function anyFlatComp<T>(): Comp<T> {

* @example
* ```ts
* const c = Comp.anyShallowComp();

@@ -512,2 +528,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))

* // First object is smaller because the objects are converted to a string and then compares the resulting string.
* ```
*/

@@ -523,2 +540,3 @@ export function anyShallowComp<T>(): Comp<T> {

* @example
* ```ts
* const c = Comp.anyDeepComp();

@@ -529,2 +547,3 @@ * console.log(c.compare({ a: 1, b: 1 }, { b: 1, a: 1 }))

* // => 0
* ```
*/

@@ -540,2 +559,3 @@ export function anyDeepComp<T>(): Comp<T> {

* @example
* ```ts
* const c = Comp.withUndefined(Comp.numberComp())

@@ -546,2 +566,3 @@ * console.log(c.compare(undefined, 5) < 0)

* // => 0
* ```
*/

@@ -553,3 +574,3 @@ export function withUndefined<T>(comp: Comp<T>): Comp<T | undefined> {

},
compare(v1, v2) {
compare(v1, v2): number {
if (undefined === v1) {

@@ -570,2 +591,3 @@ if (undefined === v2) return 0;

* @example
* ```ts
* const c = Comp.withNull(Comp.numberComp())

@@ -576,2 +598,3 @@ * console.log(c.compare(null, 5) < 0)

* // => 0
* ```
*/

@@ -583,3 +606,3 @@ export function withNull<T>(comp: Comp<T>): Comp<T | null> {

},
compare(v1, v2) {
compare(v1, v2): number {
if (null === v1) {

@@ -599,2 +622,3 @@ if (null === v2) return 0;

* @example
* ```ts
* const c = Comp.invert(Comp.numberComp())

@@ -605,6 +629,7 @@ * console.log(c.compare(3, 5) > 0)

* // => 0
* ```
*/
export function invert<T>(comp: Comp<T>): Comp<T> {
return {
compare(v1, v2) {
compare(v1, v2): number {
return comp.compare(v2, v1);

@@ -620,9 +645,11 @@ },

* @example
* ```ts
* const eq = Comp.toEq(Comp.objectComp())
* console.log(eq({ a: 1, b: 2 }, { b: 2, a: 1 }))
* // => true
* ```
*/
export function toEq<T>(comp: Comp<T>): Eq<T> {
return (v1, v2) => comp.compare(v1, v2) === 0;
return (v1: T, v2: T): boolean => comp.compare(v1, v2) === 0;
}
}

@@ -35,2 +35,3 @@ /**

* @example
* ```ts
* const eq = Eq.objectIs

@@ -41,2 +42,3 @@ * console.log(eq(5, 5))

* // => false
* ```
*/

@@ -53,2 +55,3 @@ export const objectIs: Eq<any> = Object.is;

* @example
* ```ts
* const eq = Eq.valueOfEq()

@@ -59,2 +62,3 @@ * console.log(eq(new Number(5), new Number(5)))

* // => false
* ```
*/

@@ -68,2 +72,3 @@ export function valueOfEq<T extends { valueOf(): V }, V>(): Eq<T> {

* @example
* ```ts
* const eq = Eq.dateEq()

@@ -74,2 +79,3 @@ * console.log(eq(new Date(2020, 1, 1), new Date(2020, 1, 1))

* // => false
* ```
*/

@@ -105,2 +111,3 @@ export function dateEq(): Eq<Date> {

* @example
* ```ts
* const eq = Eq.iterableEq();

@@ -111,2 +118,3 @@ * console.log(eq([1, 2, 3], [1, 2, 3])

* // => false
* ```
*/

@@ -152,2 +160,3 @@ export function iterableEq<T>(itemEq?: Eq<T>): Eq<Iterable<T>> {

* @example
* ```ts
* const eq = Eq.objectEq()

@@ -158,2 +167,3 @@ * console.log(eq({ a: 1, b: { c: 2 }}, { b: { c: 2 }, a: 1 }))

* // => false
* ```
*/

@@ -230,2 +240,3 @@ export function objectEq<V = any>(valueEq?: Eq<V>): Eq<Record<any, V>> {

* @example
* ```ts
* const eq = anyFlatEq()

@@ -236,2 +247,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -248,2 +260,3 @@ export function anyFlatEq<T = any>(): Eq<T> {

* @example
* ```ts
* const eq = anyFlatEq()

@@ -256,2 +269,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -269,2 +283,3 @@ export function anyShallowEq<T = any>(): Eq<T> {

* @example
* ```ts
* const eq = anyFlatEq()

@@ -277,2 +292,3 @@ * console.log(eq(1, 'a'))

* // => false
* ```
*/

@@ -293,2 +309,3 @@ export function anyDeepEq<T = any>(): Eq<T> {

* @example
* ```ts
* const eq = Eq.createStringCollatorEq()

@@ -299,2 +316,3 @@ * console.log(eq('a', 'a'))

* // => false
* ```
*/

@@ -318,2 +336,3 @@ export function createStringCollatorEq(

* @example
* ```ts
* const eq = Eq.stringCaseInsentitiveEq()

@@ -324,2 +343,3 @@ * console.log(eq('aB', 'Ab'))

* // => false
* ```
*/

@@ -347,2 +367,3 @@ export function stringCaseInsentitiveEq(): Eq<string> {

* @example
* ```ts
* const eq = Eq.stringCharCodeEq()

@@ -353,2 +374,3 @@ * console.log(eq('a', 'a'))

* // => false
* ```
*/

@@ -372,2 +394,3 @@ export function stringCharCodeEq(): Eq<string> {

* @example
* ```ts
* const eq = Eq.anyJsonEq()

@@ -378,2 +401,3 @@ * console.log(eq({ a: 1, b: 2 }, { a: 1, b: 2 }))

* // => false
* ```
*/

@@ -389,2 +413,3 @@ export function anyJsonEq(): Eq<any> {

* @example
* ```ts
* const eq = Eq.tupleSymmetric()

@@ -397,2 +422,3 @@ * console.log(eq([1, 2], [1, 2]))

* // => false
* ```
*/

@@ -399,0 +425,0 @@ export function tupleSymmetric<T>(

/**
* Throws an `Err.ForcedError` error when called.
* @example
* ```ts
* const emptyMap = HashMap.empty<number, string>()
* emptyMap.get(5, Err);
* // throws: Err.CustomError(message: 'Err: forced to throw error')
* ```
*/

@@ -8,0 +10,0 @@ export function Err(): never {

@@ -6,15 +6,16 @@ import type { Range } from './internal';

* If a start or end is defined, a tuple can be used where the second item is a boolean
* indicating whether that end is inclusive or exclusive.
* An IndexRange can have one of the following forms:
* - { amount: number }
* - { start: number }
* - { start: number, amount: number }
* - { start: number, end: number }
* - { start: number, end: [number, boolean] }
* - { start: [number, boolean] }
* - { start: [number, boolean], amount: number }
* - { start: [number, boolean], end: number }
* - { start: [number, boolean], end: [number, boolean] }
* - { end: number }
* - { end: [number, boolean] }
* indicating whether that end is inclusive or exclusive.<br/>
* An IndexRange can have one of the following forms:<br/>
* <br/>
* - { amount: number }<br/>
* - { start: number }<br/>
* - { start: number, amount: number }<br/>
* - { start: number, end: number }<br/>
* - { start: number, end: [number, boolean] }<br/>
* - { start: [number, boolean] }<br/>
* - { start: [number, boolean], amount: number }<br/>
* - { start: [number, boolean], end: number }<br/>
* - { start: [number, boolean], end: [number, boolean] }<br/>
* - { end: number }<br/>
* - { end: [number, boolean] }<br/>
*/

@@ -21,0 +22,0 @@ export type IndexRange =

@@ -0,1 +1,7 @@

/**
* @packageDocumentation
*
* The `@rimbu/common` package provides many commonly used types and utilities that can also be of use to Rimbu users.<br/>
*/
export * from './internal';

@@ -11,5 +11,7 @@ /**

* @example
* ```ts
* OptLazy(1) // => 1
* OptLazy(() => 1) // => 1
* OptLazy(() => () => 1) // => () => 1
* ```
*/

@@ -35,5 +37,7 @@ export function OptLazy<T>(optLazy: OptLazy<T>): T {

* @example
* ```ts
* OptLazyOr(1, 'a') // => 1
* OptLazyOr(() => 1, 'a') // => 1
* OptLazyOr((none) => none, 'a') // => 'a'
* ```
*/

@@ -40,0 +44,0 @@ export function OptLazyOr<T, O>(

/**
* A range definition for any type of (orderable) value.
* If a start or end is defined, a tuple can be used where the second item is a boolean
* indicating whether that end is inclusive or exclusive.
* An Range of type T can have one of the following forms:
* - { end: T }
* - { end: [T, boolean] }
* - { start: T }
* - { start: T, end: T }
* - { start: T, end: [T, boolean] }
* - { start: [T, boolean] }
* - { start: [T, boolean], end: T }
* - { start: [T, boolean], end: [T, boolean] }
* indicating whether that end is inclusive (true) or exclusive (false).<br/>
* A Range of type T can have one of the following forms:<br/>
* <br/>
* - { end: T }<br/>
* - { end: [T, boolean] }<br/>
* - { start: T }<br/>
* - { start: T, end: T }<br/>
* - { start: T, end: [T, boolean] }<br/>
* - { start: [T, boolean] }<br/>
* - { start: [T, boolean], end: T }<br/>
* - { start: [T, boolean], end: [T, boolean] }<br/>
*/

@@ -15,0 +16,0 @@ export type Range<T> =

@@ -56,9 +56,11 @@ import { CollectFun, Eq, OptLazy } from './internal';

* Returns a `Reducer` instance that only passes values to the reducer that satisy the given `pred` predicate.
* @param pred - a function that returns true if the value should be passed to the reducer based on the following inputs:
* - value: the current input value
* - index: the current input index
* @param pred - a function that returns true if the value should be passed to the reducer based on the following inputs:<br/>
* - value: the current input value<br/>
* - index: the current input index<br/>
* - halt: function that, when called, ensures no more new values are passed to the reducer
* @example
* ```ts
* Reducer.sum.filterInput(v => v > 10)
* // this reducer will only sum values larger than 10
* ```
*/

@@ -70,8 +72,10 @@ filterInput(

* Returns a `Reducer` instance that converts its input values using given `mapFun` before passing them to the reducer.
* @param mapFun - a function that returns a new value to pass to the reducer based on the following inputs:
* - value: the current input value
* @param mapFun - a function that returns a new value to pass to the reducer based on the following inputs:<br/>
* - value: the current input value<br/>
* - index: the current input index
* @example
* ```ts
* Reducer.sum.mapInput(v => v * 2)
* // this reducer will double all input values before summing them
* ```
*/

@@ -81,11 +85,13 @@ mapInput<I2>(mapFun: (value: I2, index: number) => I): Reducer<I2, O>;

* Returns a `Reducer` instance that converts or filters its input values using given `collectFun` before passing them to the reducer.
* @param collectFun - a function receiving
* * `value`: the next value
* * `index`: the value index
* * `skip`: a token that, when returned, will not add a value to the resulting collection
* * `halt`: a function that, when called, ensures no next elements are passed
* @param collectFun - a function receiving<br/>
* - `value`: the next value<br/>
* - `index`: the value index<br/>
* - `skip`: a token that, when returned, will not add a value to the resulting collection<br/>
* - `halt`: a function that, when called, ensures no next elements are passed
* @example
* ```ts
* Reducer.sum.collectInput((v, _, skip) => v <= 10 ? skip : v * 2)
* // this reducer will double all input values larger thant 10 before summing them,
* // and will skip all values smaller than 10
* ```
*/

@@ -96,4 +102,7 @@ collectInput<I2>(collectFun: CollectFun<I2, I>): Reducer<I2, O>;

* @param mapFun - a function that takes the current output value and converts it to a new output value
* @example
* ```ts
* Reducer.sum.mapOutput(String)
* // this reducer will convert all its results to string before returning them
* ```
*/

@@ -105,4 +114,6 @@ mapOutput<O2>(mapFun: (value: O) => O2): Reducer<I, O2>;

* @example
* ```ts
* Stream.range({ end: 10 }).reduce(Reducer.sum.takeInput(2))
* // => 1
* ```
*/

@@ -114,4 +125,6 @@ takeInput(amount: number): Reducer<I, O>;

* @example
* ```ts
* Stream.range({ end: 10 }).reduce(Reducer.sum.dropInput(9))
* // => 19
* ```
*/

@@ -124,4 +137,6 @@ dropInput(amount: number): Reducer<I, O>;

* @example
* ```ts
* Stream.range({ end: 10 }).reduce(Reducer.sum.sliceInput(1, 2))
* // => 3
* ```
*/

@@ -232,6 +247,6 @@ sliceInput(from?: number, amount?: number): Reducer<I, O>;

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -243,2 +258,3 @@ * @param stateToResult - a function that converts the current state to an output value

* @example
* ```ts
* const evenNumberOfOnes = Reducer

@@ -252,2 +268,3 @@ * .create(

* // => 'even'
* ```
*/

@@ -265,9 +282,11 @@ export function create<I, O = I, S = O>(

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer
* @param stateToResult - (optional) a function that converts the current state to an output value
* @typeparam T - the overall value type
* @example
* ```ts
* const sum = Reducer

@@ -281,2 +300,3 @@ * .createMono(

* // => 9
* ```
*/

@@ -294,6 +314,6 @@ export function createMono<T>(

* @param init - the initial state value
* @param next - returns the next state value based on the given inputs:
* - current: the current state
* - next: the current input value
* - index: the input index value
* @param next - returns the next state value based on the given inputs:<br/>
* - current: the current state<br/>
* - next: the current input value<br/>
* - index: the input index value<br/>
* - halt: function that, when called, ensures no more elements are passed to the reducer

@@ -303,2 +323,4 @@ * @param stateToResult - (optional) a function that converts the current state to an output value

* @typeparam O - the output value type
* @example
* ```ts
* const boolToString = Reducer

@@ -312,2 +334,3 @@ * .createOutput(

* // => 'TFT'
* ```
*/

@@ -325,4 +348,6 @@ export function createOutput<I, O = I>(

* @example
* ```ts
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.sum))
* // => 10
* ```
*/

@@ -334,4 +359,6 @@ export const sum = createMono(0, (state, next): number => state + next);

* @example
* ```ts
* console.log(Stream.range({ start: 1, amount: 5 }).reduce(product))
* // => 120
* ```
*/

@@ -346,4 +373,6 @@ export const product = createMono(1, (state, next, _, halt): number => {

* @example
* ```ts
* console.log(Stream.range({ amount: 5 }).reduce(Reducer.average));
* // => 2
* ```
*/

@@ -360,5 +389,7 @@ export const average = createMono(

* @example
* ```ts
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
* console.log(stream.minBy((s1, s2) => s1.length - s2.length))
* // 'a'
* ```
*/

@@ -387,4 +418,6 @@ export const minBy: {

* @example
* ```ts
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.min()))
* // => 3
* ```
*/

@@ -408,5 +441,7 @@ export const min: {

* @example
* ```ts
* const stream = Stream.of('abc', 'a', 'abcde', 'ab')
* console.log(stream.maxBy((s1, s2) => s1.length - s2.length))
* // 'abcde'
* ```
*/

@@ -438,4 +473,6 @@ export const maxBy: {

* @example
* ```ts
* console.log(Stream.of(5, 3, 7, 4).reduce(Reducer.max()))
* // => 7
* ```
*/

@@ -455,10 +492,12 @@ export const max: {

/**
* Returns a `Reducer` that joins the given input values into a string using the given options.
* @options - an object containing:
* - sep: (optional) a seperator string value between values in the output
* - start: (optional) a start string to prepend to the output
* - end: (optional) an end string to append to the output
* Returns a `yaReducer` that joins the given input values into a string using the given options.
* @param options - an object containing:<br/>
* - sep: (optional) a seperator string value between values in the output<br/>
* - start: (optional) a start string to prepend to the output<br/>
* - end: (optional) an end string to append to the output<br/>
* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.join({ sep: '-' })))
* // => '1-2-3'
* ```
*/

@@ -487,6 +526,7 @@ export function join<T>({

* Returns a `Reducer` that remembers the amount of input items provided.
* @param pred - (optional) a predicate that returns false if the item should not be counted given:
* - value: the current input value
* @param pred - (optional) a predicate that returns false if the item should not be counted given:<br/>
* - value: the current input value<br/>
* - index: the input value index
* @example
* ```ts
* const stream = Stream.range({ amount: 10 })

@@ -497,2 +537,3 @@ * console.log(stream.reduce(Reducer.count()))

* // => 5
* ```
*/

@@ -518,4 +559,6 @@ export const count: {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.firstWhere(v => v > 5)))
* // => 6
* ```
*/

@@ -553,4 +596,6 @@ export const firstWhere: {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
* // => 0
* ```
*/

@@ -581,4 +626,6 @@ export const first: {

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.lastWhere(v => v > 5)))
* // => 9
* ```
*/

@@ -613,4 +660,6 @@ export const lastWhere: {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.first())
* // => 0
* ```
*/

@@ -634,4 +683,6 @@ export const last: {

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.some(v => v > 5))
* // => true
* ```
*/

@@ -657,4 +708,6 @@ export function some<T>(

* @example
* ```ts
* console.log(Stream.range{ amount: 10 }).reduce(Reducer.every(v => v < 5))
* // => false
* ```
*/

@@ -682,4 +735,6 @@ export function every<T>(

* @example
* ```ts
* console.log(Stream.range({ amount: 10 }).reduce(Reducer.contains(5)))
* // => true
* ```
*/

@@ -705,4 +760,6 @@ export function contains<T>(

* @example
* ```ts
* console.log(Stream.of(true, false, true)).reduce(Reducer.and))
* // => false
* ```
*/

@@ -718,4 +775,6 @@ export const and = createMono(true, (state, next, _, halt): boolean => {

* @example
* ```ts
* console.log(Stream.of(true, false, true)).reduce(Reducer.or))
* // => true
* ```
*/

@@ -731,4 +790,6 @@ export const or = createMono(false, (state, next, _, halt): boolean => {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.isEmpty))
* // => false
* ```
*/

@@ -746,4 +807,6 @@ export const isEmpty = createOutput<any, boolean>(

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.nonEmpty))
* // => true
* ```
*/

@@ -761,4 +824,6 @@ export const nonEmpty = createOutput<any, boolean>(

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toArray()))
* // => [1, 2, 3]
* ```
*/

@@ -780,4 +845,6 @@ export function toArray<T>(): Reducer<T, T[]> {

* @example
* ```ts
* console.log(Stream.of([1, 'a'], [2, 'b']).reduce(Reducer.toJSMap()))
* // Map { 1 => 'a', 2 => 'b' }
* ```
*/

@@ -799,4 +866,6 @@ export function toJSMap<K, V>(): Reducer<[K, V], Map<K, V>> {

* @example
* ```ts
* console.log(Stream.of(1, 2, 3).reduce(Reducer.toJSSet()))
* // Set {1, 2, 3}
* ```
*/

@@ -818,5 +887,7 @@ export function toJSSet<T>(): Reducer<T, Set<T>> {

* @example
* ```ts
* const red = Reducer.combine(Reducer.sum, Reducer.average)
* console.log(Stream.range({amount: 9 }).reduce(red))
* // => [36, 4]
* ```
*/

@@ -829,3 +900,8 @@ export function combine<

): Reducer<T, R> {
const createState = () => {
const createState = (): {
reducer: Reducer<T, unknown>;
halted: boolean;
halt(): void;
state: unknown;
}[] => {
return reducers.map((reducer) => {

@@ -835,3 +911,3 @@ const result = {

halted: false,
halt() {
halt(): void {
result.halted = true;

@@ -838,0 +914,0 @@ },

@@ -33,7 +33,2 @@ /**

/**
* A stronger version of `Omit`, which only accepts keys that are in type T.
*/
export type OmitStrong<T, K extends keyof T> = Omit<T, K>;
/**
* Utility type to convert some object to a JSON serializable format.

@@ -40,0 +35,0 @@ * @typeparam V - the `value` type

@@ -13,5 +13,7 @@ /**

* @example
* ```ts
* Update(1, 2) // => 2
* Update(1, () => 10) // => 10
* Update(1, v => v + 1) // => 2
* ```
*/

@@ -18,0 +20,0 @@ export function Update<T>(value: T, update: Update<T>): T {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc