rubico 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AggregateReducer.d.ts +10 -0
- package/Transducer.d.ts +231 -0
- package/__.d.ts +2 -0
- package/_internal/EmptyMap.d.ts +2 -0
- package/_internal/arrayFind.d.ts +15 -0
- package/_internal/asyncIteratorFind.d.ts +12 -0
- package/_internal/iteratorFind.d.ts +12 -0
- package/_internal/thunkify5.d.ts +20 -0
- package/_internal/timeInLoop.d.ts +25 -0
- package/_internal/timeInLoopAsync.d.ts +23 -0
- package/all.d.ts +100 -0
- package/always.d.ts +2 -0
- package/and.d.ts +45 -0
- package/assign.d.ts +46 -0
- package/compose.d.ts +25 -0
- package/curry.d.ts +70 -0
- package/dist/Transducer.es.js +1 -1
- package/dist/Transducer.es.min.js +1 -1
- package/dist/Transducer.js +1 -1
- package/dist/Transducer.min.js +1 -1
- package/dist/Transducer.mjs +1 -1
- package/dist/__.es.js +1 -1
- package/dist/__.es.min.js +1 -1
- package/dist/__.js +1 -1
- package/dist/__.min.js +1 -1
- package/dist/__.mjs +1 -1
- package/dist/all.es.js +1 -1
- package/dist/all.es.min.js +1 -1
- package/dist/all.js +1 -1
- package/dist/all.min.js +1 -1
- package/dist/all.mjs +1 -1
- package/dist/always.es.js +1 -1
- package/dist/always.es.min.js +1 -1
- package/dist/always.js +1 -1
- package/dist/always.min.js +1 -1
- package/dist/always.mjs +1 -1
- package/dist/and.es.js +1 -1
- package/dist/and.es.min.js +1 -1
- package/dist/and.js +1 -1
- package/dist/and.min.js +1 -1
- package/dist/and.mjs +1 -1
- package/dist/assign.es.js +1 -1
- package/dist/assign.es.min.js +1 -1
- package/dist/assign.js +1 -1
- package/dist/assign.min.js +1 -1
- package/dist/assign.mjs +1 -1
- package/dist/compose.es.js +1 -1
- package/dist/compose.es.min.js +1 -1
- package/dist/compose.js +1 -1
- package/dist/compose.min.js +1 -1
- package/dist/compose.mjs +1 -1
- package/dist/curry.es.js +1 -1
- package/dist/curry.es.min.js +1 -1
- package/dist/curry.js +1 -1
- package/dist/curry.min.js +1 -1
- package/dist/curry.mjs +1 -1
- package/dist/eq.es.js +1 -1
- package/dist/eq.es.min.js +1 -1
- package/dist/eq.js +1 -1
- package/dist/eq.min.js +1 -1
- package/dist/eq.mjs +1 -1
- package/dist/every.es.js +1 -1
- package/dist/every.es.min.js +1 -1
- package/dist/every.js +1 -1
- package/dist/every.min.js +1 -1
- package/dist/every.mjs +1 -1
- package/dist/filter.es.js +1 -1
- package/dist/filter.es.min.js +1 -1
- package/dist/filter.js +1 -1
- package/dist/filter.min.js +1 -1
- package/dist/filter.mjs +1 -1
- package/dist/flatMap.es.js +1 -1
- package/dist/flatMap.es.min.js +1 -1
- package/dist/flatMap.js +1 -1
- package/dist/flatMap.min.js +1 -1
- package/dist/flatMap.mjs +1 -1
- package/dist/forEach.es.js +1 -1
- package/dist/forEach.es.min.js +1 -1
- package/dist/forEach.js +1 -1
- package/dist/forEach.min.js +1 -1
- package/dist/forEach.mjs +1 -1
- package/dist/get.es.js +1 -1
- package/dist/get.es.min.js +1 -1
- package/dist/get.js +1 -1
- package/dist/get.min.js +1 -1
- package/dist/get.mjs +1 -1
- package/dist/gt.es.js +1 -1
- package/dist/gt.es.min.js +1 -1
- package/dist/gt.js +1 -1
- package/dist/gt.min.js +1 -1
- package/dist/gt.mjs +1 -1
- package/dist/gte.es.js +1 -1
- package/dist/gte.es.min.js +1 -1
- package/dist/gte.js +1 -1
- package/dist/gte.min.js +1 -1
- package/dist/gte.mjs +1 -1
- package/dist/lt.es.js +1 -1
- package/dist/lt.es.min.js +1 -1
- package/dist/lt.js +1 -1
- package/dist/lt.min.js +1 -1
- package/dist/lt.mjs +1 -1
- package/dist/lte.es.js +1 -1
- package/dist/lte.es.min.js +1 -1
- package/dist/lte.js +1 -1
- package/dist/lte.min.js +1 -1
- package/dist/lte.mjs +1 -1
- package/dist/map.es.js +1 -1
- package/dist/map.es.min.js +1 -1
- package/dist/map.js +1 -1
- package/dist/map.min.js +1 -1
- package/dist/map.mjs +1 -1
- package/dist/not.es.js +1 -1
- package/dist/not.es.min.js +1 -1
- package/dist/not.js +1 -1
- package/dist/not.min.js +1 -1
- package/dist/not.mjs +1 -1
- package/dist/omit.es.js +1 -1
- package/dist/omit.es.min.js +1 -1
- package/dist/omit.js +1 -1
- package/dist/omit.min.js +1 -1
- package/dist/omit.mjs +1 -1
- package/dist/or.es.js +1 -1
- package/dist/or.es.min.js +1 -1
- package/dist/or.js +1 -1
- package/dist/or.min.js +1 -1
- package/dist/or.mjs +1 -1
- package/dist/pick.es.js +1 -1
- package/dist/pick.es.min.js +1 -1
- package/dist/pick.js +1 -1
- package/dist/pick.min.js +1 -1
- package/dist/pick.mjs +1 -1
- package/dist/pipe.es.js +1 -1
- package/dist/pipe.es.min.js +1 -1
- package/dist/pipe.js +1 -1
- package/dist/pipe.min.js +1 -1
- package/dist/pipe.mjs +1 -1
- package/dist/reduce.es.js +1 -1
- package/dist/reduce.es.min.js +1 -1
- package/dist/reduce.js +1 -1
- package/dist/reduce.min.js +1 -1
- package/dist/reduce.mjs +1 -1
- package/dist/rubico.es.js +1 -1
- package/dist/rubico.es.min.js +1 -1
- package/dist/rubico.global.js +1 -1
- package/dist/rubico.global.min.js +1 -1
- package/dist/rubico.js +1 -1
- package/dist/rubico.min.js +1 -1
- package/dist/rubico.mjs +1 -1
- package/dist/set.es.js +1 -1
- package/dist/set.es.min.js +1 -1
- package/dist/set.js +1 -1
- package/dist/set.min.js +1 -1
- package/dist/set.mjs +1 -1
- package/dist/some.es.js +1 -1
- package/dist/some.es.min.js +1 -1
- package/dist/some.js +1 -1
- package/dist/some.min.js +1 -1
- package/dist/some.mjs +1 -1
- package/dist/switchCase.es.js +1 -1
- package/dist/switchCase.es.min.js +1 -1
- package/dist/switchCase.js +1 -1
- package/dist/switchCase.min.js +1 -1
- package/dist/switchCase.mjs +1 -1
- package/dist/tap.es.js +1 -1
- package/dist/tap.es.min.js +1 -1
- package/dist/tap.js +1 -1
- package/dist/tap.min.js +1 -1
- package/dist/tap.mjs +1 -1
- package/dist/thunkify.es.js +1 -1
- package/dist/thunkify.es.min.js +1 -1
- package/dist/thunkify.js +1 -1
- package/dist/thunkify.min.js +1 -1
- package/dist/thunkify.mjs +1 -1
- package/dist/transform.es.js +1 -1
- package/dist/transform.es.min.js +1 -1
- package/dist/transform.js +1 -1
- package/dist/transform.min.js +1 -1
- package/dist/transform.mjs +1 -1
- package/dist/tryCatch.es.js +1 -1
- package/dist/tryCatch.es.min.js +1 -1
- package/dist/tryCatch.js +1 -1
- package/dist/tryCatch.min.js +1 -1
- package/dist/tryCatch.mjs +1 -1
- package/dist/x/append.es.js +1 -1
- package/dist/x/append.es.min.js +1 -1
- package/dist/x/append.js +1 -1
- package/dist/x/append.min.js +1 -1
- package/dist/x/append.mjs +1 -1
- package/dist/x/callProp.es.js +1 -1
- package/dist/x/callProp.es.min.js +1 -1
- package/dist/x/callProp.js +1 -1
- package/dist/x/callProp.min.js +1 -1
- package/dist/x/callProp.mjs +1 -1
- package/dist/x/defaultsDeep.es.js +1 -1
- package/dist/x/defaultsDeep.es.min.js +1 -1
- package/dist/x/defaultsDeep.js +1 -1
- package/dist/x/defaultsDeep.min.js +1 -1
- package/dist/x/defaultsDeep.mjs +1 -1
- package/dist/x/differenceWith.es.js +1 -1
- package/dist/x/differenceWith.es.min.js +1 -1
- package/dist/x/differenceWith.js +1 -1
- package/dist/x/differenceWith.min.js +1 -1
- package/dist/x/differenceWith.mjs +1 -1
- package/dist/x/filterOut.es.js +1 -1
- package/dist/x/filterOut.es.min.js +1 -1
- package/dist/x/filterOut.js +1 -1
- package/dist/x/filterOut.min.js +1 -1
- package/dist/x/filterOut.mjs +1 -1
- package/dist/x/find.es.js +1 -1
- package/dist/x/find.es.min.js +1 -1
- package/dist/x/find.js +1 -1
- package/dist/x/find.min.js +1 -1
- package/dist/x/find.mjs +1 -1
- package/dist/x/findIndex.es.js +1 -1
- package/dist/x/findIndex.es.min.js +1 -1
- package/dist/x/findIndex.js +1 -1
- package/dist/x/findIndex.min.js +1 -1
- package/dist/x/findIndex.mjs +1 -1
- package/dist/x/first.es.js +1 -1
- package/dist/x/first.es.min.js +1 -1
- package/dist/x/first.js +1 -1
- package/dist/x/first.min.js +1 -1
- package/dist/x/first.mjs +1 -1
- package/dist/x/flatten.es.js +1 -1
- package/dist/x/flatten.es.min.js +1 -1
- package/dist/x/flatten.js +1 -1
- package/dist/x/flatten.min.js +1 -1
- package/dist/x/flatten.mjs +1 -1
- package/dist/x/groupBy.es.js +1 -1
- package/dist/x/groupBy.es.min.js +1 -1
- package/dist/x/groupBy.js +1 -1
- package/dist/x/groupBy.min.js +1 -1
- package/dist/x/groupBy.mjs +1 -1
- package/dist/x/has.es.js +1 -1
- package/dist/x/has.es.min.js +1 -1
- package/dist/x/has.js +1 -1
- package/dist/x/has.min.js +1 -1
- package/dist/x/has.mjs +1 -1
- package/dist/x/identity.es.js +1 -1
- package/dist/x/identity.es.min.js +1 -1
- package/dist/x/identity.js +1 -1
- package/dist/x/identity.min.js +1 -1
- package/dist/x/identity.mjs +1 -1
- package/dist/x/includes.es.js +1 -1
- package/dist/x/includes.es.min.js +1 -1
- package/dist/x/includes.js +1 -1
- package/dist/x/includes.min.js +1 -1
- package/dist/x/includes.mjs +1 -1
- package/dist/x/isDeepEqual.es.js +1 -1
- package/dist/x/isDeepEqual.es.min.js +1 -1
- package/dist/x/isDeepEqual.js +1 -1
- package/dist/x/isDeepEqual.min.js +1 -1
- package/dist/x/isDeepEqual.mjs +1 -1
- package/dist/x/isEmpty.es.js +1 -1
- package/dist/x/isEmpty.es.min.js +1 -1
- package/dist/x/isEmpty.js +1 -1
- package/dist/x/isEmpty.min.js +1 -1
- package/dist/x/isEmpty.mjs +1 -1
- package/dist/x/isEqual.es.js +1 -1
- package/dist/x/isEqual.es.min.js +1 -1
- package/dist/x/isEqual.js +1 -1
- package/dist/x/isEqual.min.js +1 -1
- package/dist/x/isEqual.mjs +1 -1
- package/dist/x/isFunction.es.js +1 -1
- package/dist/x/isFunction.es.min.js +1 -1
- package/dist/x/isFunction.js +1 -1
- package/dist/x/isFunction.min.js +1 -1
- package/dist/x/isFunction.mjs +1 -1
- package/dist/x/isIn.es.js +1 -1
- package/dist/x/isIn.es.min.js +1 -1
- package/dist/x/isIn.js +1 -1
- package/dist/x/isIn.min.js +1 -1
- package/dist/x/isIn.mjs +1 -1
- package/dist/x/isObject.es.js +1 -1
- package/dist/x/isObject.es.min.js +1 -1
- package/dist/x/isObject.js +1 -1
- package/dist/x/isObject.min.js +1 -1
- package/dist/x/isObject.mjs +1 -1
- package/dist/x/isString.es.js +1 -1
- package/dist/x/isString.es.min.js +1 -1
- package/dist/x/isString.js +1 -1
- package/dist/x/isString.min.js +1 -1
- package/dist/x/isString.mjs +1 -1
- package/dist/x/keys.es.js +1 -1
- package/dist/x/keys.es.min.js +1 -1
- package/dist/x/keys.js +1 -1
- package/dist/x/keys.min.js +1 -1
- package/dist/x/keys.mjs +1 -1
- package/dist/x/last.es.js +1 -1
- package/dist/x/last.es.min.js +1 -1
- package/dist/x/last.js +1 -1
- package/dist/x/last.min.js +1 -1
- package/dist/x/last.mjs +1 -1
- package/dist/x/maxBy.es.js +1 -1
- package/dist/x/maxBy.es.min.js +1 -1
- package/dist/x/maxBy.js +1 -1
- package/dist/x/maxBy.min.js +1 -1
- package/dist/x/maxBy.mjs +1 -1
- package/dist/x/noop.es.js +1 -1
- package/dist/x/noop.es.min.js +1 -1
- package/dist/x/noop.js +1 -1
- package/dist/x/noop.min.js +1 -1
- package/dist/x/noop.mjs +1 -1
- package/dist/x/pluck.es.js +1 -1
- package/dist/x/pluck.es.min.js +1 -1
- package/dist/x/pluck.js +1 -1
- package/dist/x/pluck.min.js +1 -1
- package/dist/x/pluck.mjs +1 -1
- package/dist/x/prepend.es.js +1 -1
- package/dist/x/prepend.es.min.js +1 -1
- package/dist/x/prepend.js +1 -1
- package/dist/x/prepend.min.js +1 -1
- package/dist/x/prepend.mjs +1 -1
- package/dist/x/size.es.js +1 -1
- package/dist/x/size.es.min.js +1 -1
- package/dist/x/size.js +1 -1
- package/dist/x/size.min.js +1 -1
- package/dist/x/size.mjs +1 -1
- package/dist/x/trace.es.js +1 -1
- package/dist/x/trace.es.min.js +1 -1
- package/dist/x/trace.js +1 -1
- package/dist/x/trace.min.js +1 -1
- package/dist/x/trace.mjs +1 -1
- package/dist/x/unionWith.es.js +1 -1
- package/dist/x/unionWith.es.min.js +1 -1
- package/dist/x/unionWith.js +1 -1
- package/dist/x/unionWith.min.js +1 -1
- package/dist/x/unionWith.mjs +1 -1
- package/dist/x/uniq.es.js +1 -1
- package/dist/x/uniq.es.min.js +1 -1
- package/dist/x/uniq.js +1 -1
- package/dist/x/uniq.min.js +1 -1
- package/dist/x/uniq.mjs +1 -1
- package/dist/x/unless.es.js +1 -1
- package/dist/x/unless.es.min.js +1 -1
- package/dist/x/unless.js +1 -1
- package/dist/x/unless.min.js +1 -1
- package/dist/x/unless.mjs +1 -1
- package/dist/x/values.es.js +1 -1
- package/dist/x/values.es.min.js +1 -1
- package/dist/x/values.js +1 -1
- package/dist/x/values.min.js +1 -1
- package/dist/x/values.mjs +1 -1
- package/dist/x/when.es.js +1 -1
- package/dist/x/when.es.min.js +1 -1
- package/dist/x/when.js +1 -1
- package/dist/x/when.min.js +1 -1
- package/dist/x/when.mjs +1 -1
- package/eq.d.ts +51 -0
- package/es.d.ts +80 -0
- package/es.js +1 -1
- package/every.d.ts +52 -0
- package/filter.d.ts +148 -0
- package/flatMap.d.ts +109 -0
- package/forEach.d.ts +35 -0
- package/get.d.ts +70 -0
- package/global.d.ts +1 -0
- package/gt.d.ts +49 -0
- package/gte.d.ts +51 -0
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/lt.d.ts +49 -0
- package/lte.d.ts +49 -0
- package/map.d.ts +246 -0
- package/monad/Instance.d.ts +246 -0
- package/monad/Instance.js +188 -206
- package/not.d.ts +34 -0
- package/omit.d.ts +50 -0
- package/or.d.ts +43 -0
- package/package.json +41 -4
- package/pick.d.ts +43 -0
- package/pipe.d.ts +49 -0
- package/reduce.d.ts +166 -0
- package/set.d.ts +61 -0
- package/some.d.ts +65 -0
- package/switchCase.d.ts +76 -0
- package/tap.d.ts +53 -0
- package/thunkify.d.ts +21 -0
- package/transform.d.ts +131 -0
- package/tryCatch.d.ts +47 -0
- package/x/append.d.ts +38 -0
- package/x/callProp.d.ts +20 -0
- package/x/defaultsDeep.d.ts +42 -0
- package/x/differenceWith.d.ts +25 -0
- package/x/filterOut.d.ts +39 -0
- package/x/find.d.ts +34 -0
- package/x/findIndex.d.ts +25 -0
- package/x/first.d.ts +23 -0
- package/x/flatten.d.ts +57 -0
- package/x/groupBy.d.ts +50 -0
- package/x/has.d.ts +25 -0
- package/x/heapUsedInLoop.d.ts +53 -0
- package/x/identity.d.ts +21 -0
- package/x/includes.d.ts +25 -0
- package/x/index.d.ts +34 -0
- package/x/is.d.ts +2 -0
- package/x/isEmpty.d.ts +24 -0
- package/x/isEqual.d.ts +2 -0
- package/x/isFunction.d.ts +23 -0
- package/x/isIn.d.ts +61 -0
- package/x/isObject.d.ts +2 -0
- package/x/isString.benchmarks.d.ts +1 -0
- package/x/isString.d.ts +21 -0
- package/x/keys.d.ts +23 -0
- package/x/last.d.ts +22 -0
- package/x/maxBy.d.ts +41 -0
- package/x/noop.d.ts +21 -0
- package/x/pluck.d.ts +35 -0
- package/x/prepend.d.ts +38 -0
- package/x/size.d.ts +21 -0
- package/x/test.d.ts +1 -0
- package/x/timeInLoop.d.ts +21 -0
- package/x/trace.d.ts +30 -0
- package/x/tracef.d.ts +7 -0
- package/x/unionWith.d.ts +31 -0
- package/x/uniq.d.ts +24 -0
- package/x/unless.d.ts +28 -0
- package/x/values.d.ts +23 -0
- package/x/when.d.ts +28 -0
package/transform.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export = transform;
|
|
2
|
+
/**
|
|
3
|
+
* @name transform
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* type Foldable = Iterable|AsyncIterable|Object<value any>
|
|
8
|
+
*
|
|
9
|
+
* type Reducer = (
|
|
10
|
+
* accumulator any,
|
|
11
|
+
* value any,
|
|
12
|
+
* indexOrKey? number|string,
|
|
13
|
+
* collection? Foldable,
|
|
14
|
+
* )=>(nextAccumulator Promise|any)
|
|
15
|
+
*
|
|
16
|
+
* type Transducer = Reducer=>Reducer
|
|
17
|
+
*
|
|
18
|
+
* type Transformable =
|
|
19
|
+
* Array|String|Set|TypedArray|{ concat: function }|{ write: function }|Object
|
|
20
|
+
*
|
|
21
|
+
* type TransformableResolver = (collection Foldable)=>Promise|Transformable
|
|
22
|
+
*
|
|
23
|
+
* transform(
|
|
24
|
+
* collection Foldable,
|
|
25
|
+
* transducer Transducer,
|
|
26
|
+
* initialValue? Transformable|TransformableResolver,
|
|
27
|
+
* ) -> result Promise|Transformable
|
|
28
|
+
*
|
|
29
|
+
* transform(
|
|
30
|
+
* transducer Transducer,
|
|
31
|
+
* initialValue? Transformable|TransformableResolver,
|
|
32
|
+
* )(collection Foldable) -> result Promise|Transformable
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @description
|
|
36
|
+
* Transforms a transformable collection into any other transformable collection. The type of transformation depends on the collection provided by the initial value. If the initial is a function it is used as a resolver for the provided collection. `transform` accepts transformable collections, or collections that support a concatenation operation:
|
|
37
|
+
*
|
|
38
|
+
* * `Array`; concatenation defined by `result.concat(values)`
|
|
39
|
+
* * `string`; concatenation defined by `result + values`
|
|
40
|
+
* * `Set`; concatenation defined by `result.add(...values)`
|
|
41
|
+
* * `TypedArray`; concatenation defined by `result.set(prevResult); result.set(values, offset)`
|
|
42
|
+
* * `{ concat: function }`; concatenation defined by `result.concat(values)`
|
|
43
|
+
* * `{ write: function }`; concatenation defined by `result.write(item)`
|
|
44
|
+
* * `Object`; concatenation defined by `({ ...result, ...values })`
|
|
45
|
+
*
|
|
46
|
+
* `transform` can transform any of the above collections into any of the other above collections.
|
|
47
|
+
*
|
|
48
|
+
* ```javascript [playground]
|
|
49
|
+
* const square = number => number ** 2
|
|
50
|
+
*
|
|
51
|
+
* const isOdd = number => number % 2 == 1
|
|
52
|
+
*
|
|
53
|
+
* const squaredOdds = compose([
|
|
54
|
+
* Transducer.filter(isOdd),
|
|
55
|
+
* Transducer.map(square),
|
|
56
|
+
* ])
|
|
57
|
+
*
|
|
58
|
+
* // transform arrays into arrays
|
|
59
|
+
* console.log(
|
|
60
|
+
* transform(squaredOdds, [])([1, 2, 3, 4, 5])
|
|
61
|
+
* ) // [1, 9, 25]
|
|
62
|
+
*
|
|
63
|
+
* // transform arrays into strings
|
|
64
|
+
* console.log(
|
|
65
|
+
* transform(squaredOdds, '')([1, 2, 3, 4, 5])
|
|
66
|
+
* ) // '1925'
|
|
67
|
+
*
|
|
68
|
+
* // transform arrays into sets
|
|
69
|
+
* console.log(
|
|
70
|
+
* transform(squaredOdds, new Set())([1, 2, 3, 4, 5])
|
|
71
|
+
* ) // Set (3) { 1, 9, 25 }
|
|
72
|
+
*
|
|
73
|
+
* // transform arrays into typed arrays
|
|
74
|
+
* console.log(
|
|
75
|
+
* transform(squaredOdds, new Uint8Array())([1, 2, 3, 4, 5]),
|
|
76
|
+
* ) // Uint8Array(3) [ 1, 9, 25 ]
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* `transform` arrays into objects that implement `.concat`.
|
|
80
|
+
*
|
|
81
|
+
* ```javascript [playground]
|
|
82
|
+
* const square = number => number ** 2
|
|
83
|
+
*
|
|
84
|
+
* const Stdout = {
|
|
85
|
+
* concat(...args) {
|
|
86
|
+
* console.log(...args)
|
|
87
|
+
* return this
|
|
88
|
+
* },
|
|
89
|
+
* }
|
|
90
|
+
*
|
|
91
|
+
* transform(Transducer.map(square), Stdout)([1, 2, 3, 4, 5])
|
|
92
|
+
* // 1
|
|
93
|
+
* // 4
|
|
94
|
+
* // 9
|
|
95
|
+
* // 16
|
|
96
|
+
* // 25
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* `transform` an async generator into `process.stdout`, a Node.js writable stream that implements `.write`.
|
|
100
|
+
*
|
|
101
|
+
* ```javascript [node]
|
|
102
|
+
* // this example is duplicated in rubico/examples/transformStreamRandomInts.js
|
|
103
|
+
*
|
|
104
|
+
* const { pipe, map, transform } = require('rubico')
|
|
105
|
+
*
|
|
106
|
+
* const square = number => number ** 2
|
|
107
|
+
*
|
|
108
|
+
* const toString = value => value.toString()
|
|
109
|
+
*
|
|
110
|
+
* const randomInt = () => Math.ceil(Math.random() * 100)
|
|
111
|
+
*
|
|
112
|
+
* const streamRandomInts = async function* () {
|
|
113
|
+
* while (true) {
|
|
114
|
+
* yield randomInt()
|
|
115
|
+
* }
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* transform(
|
|
119
|
+
* streamRandomInts(),
|
|
120
|
+
* Transducer.map(pipe([square, toString])),
|
|
121
|
+
* process.stdout,
|
|
122
|
+
* ) // 9216576529289484980147613249169774446246768649...
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @execution series
|
|
126
|
+
*
|
|
127
|
+
* @transducing
|
|
128
|
+
*
|
|
129
|
+
* TODO explore Semigroup = Iterator|AsyncIterator
|
|
130
|
+
*/
|
|
131
|
+
declare function transform(...args: any[]): any;
|
package/tryCatch.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export = tryCatch;
|
|
2
|
+
/**
|
|
3
|
+
* @name tryCatch
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* tryCatch(tryer function, catcher function)(...args) -> Promise|any
|
|
8
|
+
*
|
|
9
|
+
* tryCatch(...args, tryer function, catcher function) -> Promise|any
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Handles errors with a `tryer` and a `catcher` function. Calls the `tryer` function with the provided arguments and catches any errors thrown by the `tryer` function with the `catcher` function. If the `tryer` function is asynchronous and returns a rejected promise, the `catcher` function will execute with the value of the rejected promise. The `catcher` function is called with the error and all arguments supplied to the `tryer` function.
|
|
14
|
+
*
|
|
15
|
+
* ```javascript [playground]
|
|
16
|
+
* const throwsIfOdd = number => {
|
|
17
|
+
* if (number % 2 == 1) {
|
|
18
|
+
* throw new Error(`${number} is odd`)
|
|
19
|
+
* }
|
|
20
|
+
* console.log('did not throw for', number)
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* const errorHandler = tryCatch(throwsIfOdd, (error, number) => {
|
|
24
|
+
* console.log('caught error from number', number)
|
|
25
|
+
* console.log(error)
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* errorHandler(2) // did not throw for 2
|
|
29
|
+
* errorHandler(3) // caught error from number 3
|
|
30
|
+
* // Error: 3 is odd
|
|
31
|
+
*
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* `tryCatch` behaves eagerly (executes immediately with a single call and not with multiple calls like a higher order function) when passed any amount of nonfunction (primitive or object) arguments before the `tryer` and `catcher` functions.
|
|
35
|
+
*
|
|
36
|
+
* ```javascript [playground]
|
|
37
|
+
* const add = (a, b) => a + b
|
|
38
|
+
*
|
|
39
|
+
* tryCatch(1, 2, 3, function throwSum(...numbers) {
|
|
40
|
+
* const sum = numbers.reduce(add)
|
|
41
|
+
* throw new Error(`the sum is ${sum}`)
|
|
42
|
+
* }, function logErrorMessage(error) {
|
|
43
|
+
* console.error(error.message) // the sum is 6
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare function tryCatch(...args: any[]): any;
|
package/x/append.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export = append;
|
|
2
|
+
/**
|
|
3
|
+
* @name append
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* append(
|
|
8
|
+
* item string|Array,
|
|
9
|
+
* )(value string|Array) -> string|array
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Append a string or an array.
|
|
14
|
+
*
|
|
15
|
+
* ```javascript [playground]
|
|
16
|
+
* import append from 'https://unpkg.com/rubico/dist/x/append.es.js'
|
|
17
|
+
*
|
|
18
|
+
* const myArray = ['orange', 'apple']
|
|
19
|
+
*
|
|
20
|
+
* {
|
|
21
|
+
* const result = append(['ananas'])(myArray)
|
|
22
|
+
* console.log(result) // ['orange', 'apple', 'ananas']
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* {
|
|
26
|
+
* const result = append('ananas')(myArray)
|
|
27
|
+
* console.log(result) // ['orange', 'apple', 'ananas']
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* {
|
|
31
|
+
* const result = append('world')('hello ')
|
|
32
|
+
* console.log(result) // 'hello world'
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @since 1.7.3
|
|
37
|
+
*/
|
|
38
|
+
declare function append(item: any): (value: any) => string | any[];
|
package/x/callProp.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export = callProp;
|
|
2
|
+
/**
|
|
3
|
+
* @name callProp
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* callProp(property string, ...args)(object) -> object[property](...args)
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* Calls a property on an object with arguments.
|
|
12
|
+
*
|
|
13
|
+
* ```javascript [playground]
|
|
14
|
+
* import callProp from 'https://unpkg.com/rubico/dist/x/callProp.es.js'
|
|
15
|
+
*
|
|
16
|
+
* const priceRoundedDown = callProp('toFixed', 2)(5.992)
|
|
17
|
+
* console.log('priceRoundedDown:', priceRoundedDown) // '5.99'
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function callProp(property: any, ...args: any[]): (object: any) => any;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export = defaultsDeep;
|
|
2
|
+
/**
|
|
3
|
+
* @name defaultsDeep
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* var defaultCollection Array|Object,
|
|
8
|
+
* value Array|Object
|
|
9
|
+
*
|
|
10
|
+
* defaultsDeep(defaultCollection)(value) -> Array|Object
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Deeply assign default values to an array or object by an array or object of possibly nested default values.
|
|
15
|
+
*
|
|
16
|
+
* ```javascript [playground]
|
|
17
|
+
* import defaultsDeep from 'https://unpkg.com/rubico/dist/x/defaultsDeep.es.js'
|
|
18
|
+
*
|
|
19
|
+
* const defaultUser = defaultsDeep({
|
|
20
|
+
* name: 'placeholder',
|
|
21
|
+
* images: [
|
|
22
|
+
* { url: 'https://via.placeholder.com/150' },
|
|
23
|
+
* { url: 'https://via.placeholder.com/150' },
|
|
24
|
+
* { url: 'https://via.placeholder.com/150' },
|
|
25
|
+
* ],
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* console.log(defaultUser({
|
|
29
|
+
* name: 'George',
|
|
30
|
+
* images: [{ url: 'https://via.placeholder.com/150/0000FF/808080%20?Text=Digital.com' }],
|
|
31
|
+
* }))
|
|
32
|
+
* // {
|
|
33
|
+
* // name: 'George',
|
|
34
|
+
* // images: [
|
|
35
|
+
* // { url: 'https://via.placeholder.com/150/0000FF/808080%20?Text=Digital.com' },
|
|
36
|
+
* // { url: 'https://via.placeholder.com/150' },
|
|
37
|
+
* // { url: 'https://via.placeholder.com/150' },
|
|
38
|
+
* // ],
|
|
39
|
+
* // }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare function defaultsDeep(defaultCollection: any): (value: any) => any;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export = differenceWith;
|
|
2
|
+
/**
|
|
3
|
+
* @name differenceWith
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* differenceWith(
|
|
8
|
+
* comparator (any, any)=>Promise|boolean,
|
|
9
|
+
* allValues Array,
|
|
10
|
+
* )(values Array) -> someOrAllValues Array
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Create an array of all the values in an array that are not in another array as dictated by a comparator.
|
|
15
|
+
*
|
|
16
|
+
* ```javascript [playground]
|
|
17
|
+
* import differenceWith from 'https://unpkg.com/rubico/dist/x/differenceWith.es.js'
|
|
18
|
+
* import isDeepEqual from 'https://unpkg.com/rubico/dist/x/isDeepEqual.es.js'
|
|
19
|
+
*
|
|
20
|
+
* console.log(
|
|
21
|
+
* differenceWith(isDeepEqual, [{ a: 1 }, { b: 2 }, { c: 3 }])([{ b: 2 }]),
|
|
22
|
+
* ) // [{ a: 1 }, { c: 3 }]
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function differenceWith(comparator: any, allValues: any): (values: any) => any;
|
package/x/filterOut.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export = filterOut;
|
|
2
|
+
/**
|
|
3
|
+
* @name filterOut
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* filterOut(
|
|
8
|
+
* arrayPredicate (value any, index number, array Array)=>Promise|boolean
|
|
9
|
+
* )(array) -> rejectedArray Promise|Array
|
|
10
|
+
*
|
|
11
|
+
* filterOut(
|
|
12
|
+
* objectPredicate (value any, key string, object Object)=>Promise|boolean
|
|
13
|
+
* )(object) -> rejectedObject Promise|Object
|
|
14
|
+
*
|
|
15
|
+
* filterOut(
|
|
16
|
+
* setPredicate (value any, value, set Set)=>Promise|boolean
|
|
17
|
+
* )(set) -> rejectedSet Promise|Set
|
|
18
|
+
*
|
|
19
|
+
* filterOut(
|
|
20
|
+
* mapPredicate (value any, key any, map Map)=>Promise|boolean
|
|
21
|
+
* )(map) -> rejectedMap Promise|Map
|
|
22
|
+
*
|
|
23
|
+
* filterOut(
|
|
24
|
+
* predicate (value any)=>Promise|boolean
|
|
25
|
+
* )(generatorFunction GeneratorFunction) -> rejectingGeneratorFunction GeneratorFunction
|
|
26
|
+
*
|
|
27
|
+
* filterOut(
|
|
28
|
+
* predicate (value any)=>Promise|boolean
|
|
29
|
+
* )(asyncGeneratorFunction AsyncGeneratorFunction) -> rejectingAsyncGeneratorFunction AsyncGeneratorFunction
|
|
30
|
+
*
|
|
31
|
+
* filterOut(
|
|
32
|
+
* predicate (value any)=>Promise|boolean
|
|
33
|
+
* )(reducer Reducer) -> rejectingReducer Reducer
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @description
|
|
37
|
+
* The inverse of `filter`. Values that test true by the predicate are filtered out, or "rejected".
|
|
38
|
+
*/
|
|
39
|
+
declare function filterOut(predicate: any): any;
|
package/x/find.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export = find;
|
|
2
|
+
/**
|
|
3
|
+
* @name find
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* Foldable<T> = Iterable<T>|AsyncIterable<T>|{ reduce: (any, T)=>any }|Object<T>
|
|
8
|
+
*
|
|
9
|
+
* var T any,
|
|
10
|
+
* predicate T=>Promise|boolean,
|
|
11
|
+
* foldable Foldable<T>,
|
|
12
|
+
* result Promise|T|undefined
|
|
13
|
+
*
|
|
14
|
+
* find(predicate)(foldable) -> result
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @description
|
|
18
|
+
* Get the first item in a foldable collection that matches a predicate.
|
|
19
|
+
*
|
|
20
|
+
* ```javascript [playground]
|
|
21
|
+
* import find from 'https://unpkg.com/rubico/dist/x/find.es.js'
|
|
22
|
+
*
|
|
23
|
+
* const users = [
|
|
24
|
+
* { name: 'John', age: 16 },
|
|
25
|
+
* { name: 'Jill', age: 32 },
|
|
26
|
+
* { name: 'George', age: 51 },
|
|
27
|
+
* ]
|
|
28
|
+
*
|
|
29
|
+
* console.log(
|
|
30
|
+
* find(user => user.age > 50)(users),
|
|
31
|
+
* ) // { name: 'George', age: 51 }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function find(predicate: any): (value: any) => any;
|
package/x/findIndex.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export = findIndex;
|
|
2
|
+
/**
|
|
3
|
+
* @name findIndex
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* findIndex(predicate function)(array Array) -> index Promise|number
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* Returns the index of the first element in an array that satisfies the predicate. Returns -1 if no element satisfies the predicate.
|
|
12
|
+
*
|
|
13
|
+
* ```javascript [playground]
|
|
14
|
+
* import findIndex from 'https://unpkg.com/rubico/dist/x/findIndex.es.js'
|
|
15
|
+
*
|
|
16
|
+
* const oddNumberIndex = findIndex(function isOdd(number) {
|
|
17
|
+
* return number % 2 == 1
|
|
18
|
+
* })([2, 3, 5])
|
|
19
|
+
*
|
|
20
|
+
* console.log(oddNumberIndex) // 1
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @since 1.6.26
|
|
24
|
+
*/
|
|
25
|
+
declare function findIndex(predicate: any): (array: any) => any;
|
package/x/first.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export = first;
|
|
2
|
+
/**
|
|
3
|
+
* @name first
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* var value Array|string
|
|
8
|
+
*
|
|
9
|
+
* first(value) -> any
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Get the first item of a collection
|
|
14
|
+
*
|
|
15
|
+
* ```javascript [playground]
|
|
16
|
+
* import first from 'https://unpkg.com/rubico/dist/x/first.es.js'
|
|
17
|
+
*
|
|
18
|
+
* console.log(first([1, 2, 3])) // 1
|
|
19
|
+
* console.log(first('abc')) // 'a'
|
|
20
|
+
* console.log(first([])) // undefined
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare function first(value: any): any;
|
package/x/flatten.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export = flatten;
|
|
2
|
+
/**
|
|
3
|
+
* @name flatten
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* Stream<T> = { read: ()=>T, write: T=>() }
|
|
8
|
+
* Monad<T> = Array<T>|String<T>|Set<T>
|
|
9
|
+
* |TypedArray<T>|Stream<T>|Iterator<T>|AsyncIterator<T>
|
|
10
|
+
* |{ chain: T=>Monad<T> }|{ flatMap: T=>Monad<T> }|Object<T>
|
|
11
|
+
* Reducer<T> = (any, T)=>Promise|any
|
|
12
|
+
* Foldable<T> = Iterable<T>|AsyncIterable<T>|{ reduce: Reducer<T>=>any }|Object<T>
|
|
13
|
+
*
|
|
14
|
+
* var T any,
|
|
15
|
+
* monad Monad<Monad<T>|Foldable<T>|T>,
|
|
16
|
+
* args ...any,
|
|
17
|
+
* generatorFunction ...args=>Generator<Monad<T>|Foldable<T>|T>,
|
|
18
|
+
* asyncGeneratorFunction ...args=>AsyncGenerator<Monad<T>|Foldable<T>|T>,
|
|
19
|
+
* reducer Reducer<Monad<T>|Foldable<T>|T>
|
|
20
|
+
*
|
|
21
|
+
* flatten(monad) -> Monad<T>
|
|
22
|
+
*
|
|
23
|
+
* flatten(generatorFunction) -> ...args=>Generator<T>
|
|
24
|
+
*
|
|
25
|
+
* flatten(asyncGeneratorFunction) -> ...args=>AsyncGenerator<T>
|
|
26
|
+
*
|
|
27
|
+
* flatten(reducer) -> Reducer<T>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @description
|
|
31
|
+
* Flatten a collection. Works in transducer position.
|
|
32
|
+
*
|
|
33
|
+
* ```javascript [playground]
|
|
34
|
+
* import flatten from 'https://unpkg.com/rubico/dist/x/flatten.es.js'
|
|
35
|
+
*
|
|
36
|
+
* flatten([
|
|
37
|
+
* [1, 1],
|
|
38
|
+
* new Set([2, 2]),
|
|
39
|
+
* (function* () { yield 3; yield 3 })(),
|
|
40
|
+
* (async function* () { yield 4; yield 4 })(),
|
|
41
|
+
* { a: 5, b: 5 },
|
|
42
|
+
* 6,
|
|
43
|
+
* Promise.resolve(7),
|
|
44
|
+
* new Uint8Array([8]),
|
|
45
|
+
* ]).then(console.log)
|
|
46
|
+
* // [1, 1, 2, 3, 3, 5, 5, 6, 7, 8, 4, 4]
|
|
47
|
+
*
|
|
48
|
+
* const add = (a, b) => a + b
|
|
49
|
+
*
|
|
50
|
+
* console.log(
|
|
51
|
+
* [[1], [2], [3], [4], [5]].reduce(flatten(add), 0),
|
|
52
|
+
* ) // 15
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @TODO flatten for each type
|
|
56
|
+
*/
|
|
57
|
+
declare function flatten(value: any): any;
|
package/x/groupBy.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export = groupBy;
|
|
2
|
+
/**
|
|
3
|
+
* @name groupBy
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* Reducer<T> = (any, T)=>Promise|any
|
|
8
|
+
* Foldable<T> = Iterable<T>|AsyncIterable<T>|{ reduce: Reducer<T>=>any }|Object<T>
|
|
9
|
+
*
|
|
10
|
+
* var property any,
|
|
11
|
+
* resolver any=>Promise|any,
|
|
12
|
+
* value Foldable
|
|
13
|
+
*
|
|
14
|
+
* groupBy(property)(value) -> groupedByProperty Map<any=>Array>
|
|
15
|
+
*
|
|
16
|
+
* groupBy(resolver)(value) -> groupedByResolver Promise|Map<any=>Array>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @description
|
|
20
|
+
* Group a foldable collection into a Map of arrays by a property on each of its elements.
|
|
21
|
+
*
|
|
22
|
+
* ```javascript [playground]
|
|
23
|
+
* import groupBy from 'https://unpkg.com/rubico/dist/x/groupBy.es.js'
|
|
24
|
+
*
|
|
25
|
+
* console.log(
|
|
26
|
+
* groupBy('age')([
|
|
27
|
+
* { name: 'George', age: 22 },
|
|
28
|
+
* { name: 'Jane', age: 22 },
|
|
29
|
+
* { name: 'Henry', age: 23 },
|
|
30
|
+
* ]),
|
|
31
|
+
* )
|
|
32
|
+
* // Map {
|
|
33
|
+
* // 22 => [{ name: 'George', age: 22 }, { name: 'Jane', age: 22 }],
|
|
34
|
+
* // 23 => [{ name: 'Henry', age: 23 }],
|
|
35
|
+
* // }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Additionally, pass a resolver in property position to resolve a value for group membership for each item.
|
|
39
|
+
*
|
|
40
|
+
* ```javascript [playground]
|
|
41
|
+
* import groupBy from 'https://unpkg.com/rubico/dist/x/groupBy.es.js'
|
|
42
|
+
*
|
|
43
|
+
* console.log(
|
|
44
|
+
* groupBy(
|
|
45
|
+
* word => word.toLowerCase(),
|
|
46
|
+
* )(['Hello', 'hello', 'Hey']),
|
|
47
|
+
* ) // Map { 'hello' => ['Hello', 'hello'], 'hey' => ['Hey'] }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function groupBy(propertyOrResolver: any): any;
|
package/x/has.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export = has;
|
|
2
|
+
/**
|
|
3
|
+
* @name has
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* has(key any)(container Set|Map|{ has: function }|Object) -> Promise|boolean
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* Check if a collection has a key.
|
|
12
|
+
*
|
|
13
|
+
* ```javascript [playground]
|
|
14
|
+
* import has from 'https://unpkg.com/rubico/dist/x/has.es.js'
|
|
15
|
+
*
|
|
16
|
+
* console.log(
|
|
17
|
+
* has('a')({ a: 1, b: 2, c: 3 }),
|
|
18
|
+
* ) // true
|
|
19
|
+
*
|
|
20
|
+
* console.log(
|
|
21
|
+
* has('a')({}),
|
|
22
|
+
* ) // false
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function has(key: any): (container: any) => any;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export = heapUsedInLoop;
|
|
2
|
+
/**
|
|
3
|
+
* @name heapUsedInLoop
|
|
4
|
+
*
|
|
5
|
+
* @catchphrase
|
|
6
|
+
* max and avg heap used in loop
|
|
7
|
+
*
|
|
8
|
+
* @synopsis
|
|
9
|
+
* heapUsedInLoop(
|
|
10
|
+
* desc string,
|
|
11
|
+
* loopCount number,
|
|
12
|
+
* func (loop number)=>any
|
|
13
|
+
* ) -> ()
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* **heapUsedInLoop** is a memory usage measurement function. Supply `description`, `loopCount`, and a function `func` for that function to be run `loopCount` times, finally logging average and max heap used per loop in terms of megabytes MiB.
|
|
17
|
+
*
|
|
18
|
+
* ```javascript
|
|
19
|
+
* heapUsedInLoop('my-description', 1e5, function () {
|
|
20
|
+
* return 1 + 1
|
|
21
|
+
* }) /*
|
|
22
|
+
* 0 5.88 MiB
|
|
23
|
+
* 1 5.92 MiB
|
|
24
|
+
* ...
|
|
25
|
+
* 99997 7.34 MiB
|
|
26
|
+
* 99998 7.34 MiB
|
|
27
|
+
* 99999 7.35 MiB
|
|
28
|
+
* my-description: 1e+5: {
|
|
29
|
+
* "max": "7.15 MiB",
|
|
30
|
+
* "avg": "5.50 MiB"
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @node-only
|
|
35
|
+
*/
|
|
36
|
+
declare function heapUsedInLoop(desc: any, loopCount: any, func: any): void;
|
|
37
|
+
declare namespace heapUsedInLoop {
|
|
38
|
+
function skip(): void;
|
|
39
|
+
/**
|
|
40
|
+
* @name heapUsedInLoop.async
|
|
41
|
+
*
|
|
42
|
+
* @synopsis
|
|
43
|
+
* heapUsedInLoop.async(
|
|
44
|
+
* desc string,
|
|
45
|
+
* loopCount number,
|
|
46
|
+
* func (loop number)=>Promise|any
|
|
47
|
+
* ) -> ()
|
|
48
|
+
*/
|
|
49
|
+
function async(desc: any, loopCount: any, func: any): Promise<void>;
|
|
50
|
+
namespace async {
|
|
51
|
+
function skip(): void;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/x/identity.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export = identity;
|
|
2
|
+
/**
|
|
3
|
+
* @name identity
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* identity(value any) -> value
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* Pass a value and receive the same value back.
|
|
12
|
+
*
|
|
13
|
+
* ```javascript [playground]
|
|
14
|
+
* import identity from 'https://unpkg.com/rubico/dist/x/identity.es.js'
|
|
15
|
+
*
|
|
16
|
+
* console.log(
|
|
17
|
+
* identity(1),
|
|
18
|
+
* ) // 1
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare function identity(value: any): any;
|
package/x/includes.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export = includes;
|
|
2
|
+
/**
|
|
3
|
+
* @name includes
|
|
4
|
+
*
|
|
5
|
+
* @synopsis
|
|
6
|
+
* ```coffeescript [specscript]
|
|
7
|
+
* includes(value any)(container Array|String|Object) -> boolean
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* Check if a collection includes another value by [SameValueZero](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero).
|
|
12
|
+
*
|
|
13
|
+
* ```javascript [playground]
|
|
14
|
+
* import includes from 'https://unpkg.com/rubico/dist/x/includes.es.js'
|
|
15
|
+
*
|
|
16
|
+
* console.log(
|
|
17
|
+
* includes(5)([1, 2, 3, 4, 5])
|
|
18
|
+
* ) // true
|
|
19
|
+
*
|
|
20
|
+
* console.log(
|
|
21
|
+
* includes(5)([1, 2, 3])
|
|
22
|
+
* ) // false
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function includes(value: any): (container: any) => any;
|