Skip to content

Commit a4af938

Browse files
committed
core operators promise arguments docs
1 parent 5a1fd2d commit a4af938

26 files changed

+252
-2
lines changed

all.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const functionObjectAll = require('./_internal/functionObjectAll')
2323
* ```
2424
*
2525
* @description
26-
* Function executor and composer. Accepts either an array of functions or an object of functions as the values. Calls each function of the provided array or object in parallel with the provided arguments. Returns either an array or object of the results of the function executions.
26+
* Function executor and composer. Accepts either an array of functions or an object of functions. Calls each function of the provided array or object in parallel with the provided arguments. Returns either an array or object of the execution results.
2727
*
2828
* ```javascript [playground]
2929
* const createArrayOfGreetingsFor = all([
@@ -72,6 +72,16 @@ const functionObjectAll = require('./_internal/functionObjectAll')
7272
* getAndLogUserById('1') // Got user {"_id":1,"name":"George"} by id 1
7373
* ```
7474
*
75+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
76+
*
77+
* ```javascript [playground]
78+
* all(Promise.resolve({ a: 1 }), [
79+
* obj => obj.a + 1,
80+
* obj => obj.a + 2,
81+
* obj => obj.a + 3,
82+
* ]).then(console.log) // [2, 3, 4]
83+
* ```
84+
*
7585
* @execution concurrent
7686
*/
7787

and.js

+9
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ const areAllPredicatesTruthy = function (args, predicates) {
131131
* ) // true
132132
* ```
133133
*
134+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
135+
*
136+
* ```javascript [playground]
137+
* and(Promise.resolve(5), [
138+
* n => n > 0,
139+
* n => n < 10,
140+
* ]).then(console.log) // true
141+
* ```
142+
*
134143
* @execution series
135144
*
136145
* @note ...args slows down here by an order of magnitude

assign.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const _assign = function (object, funcs) {
1818
*
1919
* @synopsis
2020
* ```coffeescript [specscript]
21-
* assign(object Object, resolvers Object<function>) -> result Promise|Object
21+
* assign(object Promise|Object, resolvers Object<function>) -> result Promise|Object
2222
*
2323
* assign(resolvers Object<function>)(object Object) -> result Promise|Object
2424
* ```
@@ -55,6 +55,19 @@ const _assign = function (object, funcs) {
5555
* // { numbers: [1, 2, 3, 4, 5], total: 15 }
5656
* ```
5757
*
58+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
59+
*
60+
* ```javascript [playground]
61+
* assign(Promise.resolve({}), {
62+
* a() {
63+
* return 1
64+
* },
65+
* b() {
66+
* return 2
67+
* },
68+
* }).then(console.log)
69+
* ```
70+
*
5871
* @execution concurrent
5972
*/
6073
const assign = function (arg0, arg1) {

compose.js

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ const funcConcat = require('./_internal/funcConcat')
2727
* compose(5, [f, g]),
2828
* ) // 16
2929
* ```
30+
*
31+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
32+
*
33+
* ```javascript [playground]
34+
* compose(Promise.resolve(1), 2, Promise.resolve(3), [
35+
* console.log, // [1, 2, 3]
36+
* ])
37+
* ```
3038
*/
3139
const compose = function (...args) {
3240
const funcs = args.pop()

eq.js

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ const equals = require('./_internal/equals')
4848
* ])
4949
* ```
5050
*
51+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
52+
*
53+
* ```javascript [playground]
54+
* eq(Promise.resolve({ a: 1, b: 1 }), get('a'), get('b')).then(console.log) // true
55+
* ```
56+
*
5157
* @execution concurrent
5258
*/
5359

every.js

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ const _every = function (collection, predicate) {
8282
* ])
8383
* ```
8484
*
85+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
86+
*
87+
* ```javascript [playground]
88+
* every(Promise.resolve([1, 2, 3, 4, 5]), n => n < 6).then(console.log) // true
89+
* ```
90+
*
8591
* @execution concurrent
8692
*
8793
* @muxing

filter.js

+9
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,15 @@ const _filter = function (value, predicate) {
226226
* }
227227
* ```
228228
*
229+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
230+
*
231+
* ```javascript [playground]
232+
* const isOdd = number => number % 2 == 1
233+
*
234+
* filter(Promise.resolve([1, 2, 3, 4, 5]), isOdd).then(console.log)
235+
* // [1, 3, 5]
236+
* ```
237+
*
229238
* @execution concurrent
230239
*
231240
* @transducing

flatMap.js

+7
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ const _flatMap = function (value, flatMapper) {
157157
* ) // Set(10) { 1, 101, 2, 102, 3, 103, 4, 104, 5, 105 }
158158
* ```
159159
*
160+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
161+
*
162+
* ```javascript [playground]
163+
* flatMap(Promise.resolve([1, 2, 3, 4, 5]), n => [n, n]).then(console.log)
164+
* // [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]
165+
* ```
166+
*
160167
* @execution concurrent
161168
*
162169
* @transducing

forEach.js

+18
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ const _forEach = function (collection, callback) {
7272
* // 25
7373
* ])
7474
* ```
75+
*
76+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
77+
*
78+
* ```javascript [playground]
79+
* forEach(Promise.resolve([1, 2, 3]), console.log)
80+
* // 1
81+
* // 2
82+
* // 3
83+
* ```
7584
*/
7685
const forEach = function (arg0, arg1) {
7786
if (typeof arg0 == 'function') {
@@ -131,6 +140,15 @@ const _forEachSeries = function (collection, callback) {
131140
*
132141
* forEach.series({ a: 1, b: 2, c: 3 }, console.log) // 1 2 3
133142
* ```
143+
*
144+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
145+
*
146+
* ```javascript [playground]
147+
* forEach.series(Promise.resolve([1, 2, 3]), console.log)
148+
* // 1
149+
* // 2
150+
* // 3
151+
* ```
134152
*/
135153
forEach.series = function forEachSeries(arg0, arg1) {
136154
if (typeof arg0 == 'function') {

get.js

+6
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ const _get = function (object, path, defaultValue) {
8080
* console.log(get00000BracketNotation([[[[['foo']]]]])) // foo
8181
* console.log(get00000ArrayNotation([[[[['foo']]]]])) // foo
8282
* ```
83+
*
84+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
85+
*
86+
* ```javascript [playground]
87+
* get(Promise.resolve({ a: 1 }), 'a').then(console.log) // 1
88+
* ```
8389
*/
8490

8591
const get = function (arg0, arg1, arg2) {

gt.js

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ const greaterThan = require('./_internal/greaterThan')
4747
* console.log, // true
4848
* ])
4949
* ```
50+
*
51+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
52+
*
53+
* ```javascript [playground]
54+
* gt(Promise.resolve({ a: 2, b: 1 }), get('a'), get('b')).then(console.log) // true
55+
* ```
5056
*/
5157
const gt = ComparisonOperator(greaterThan)
5258

gte.js

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ const greaterThanOrEqual = require('./_internal/greaterThanOrEqual')
4949
* console.log, // true
5050
* ])
5151
* ```
52+
*
53+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
54+
*
55+
* ```javascript [playground]
56+
* gte(Promise.resolve({ a: 1, b: 1 }), get('a'), get('b')).then(console.log) // true
57+
* ```
5258
*/
5359
const gte = ComparisonOperator(greaterThanOrEqual)
5460

lt.js

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ const lessThan = require('./_internal/lessThan')
4747
* console.log, // true
4848
* ])
4949
* ```
50+
*
51+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
52+
*
53+
* ```javascript [playground]
54+
* lt(Promise.resolve({ a: 1, b: 2 }), get('a'), get('b')).then(console.log) // true
55+
* ```
5056
*/
5157
const lt = ComparisonOperator(lessThan)
5258

lte.js

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ const lessThanOrEqual = require('./_internal/lessThanOrEqual')
4747
* console.log, // true
4848
* ])
4949
* ```
50+
*
51+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
52+
*
53+
* ```javascript [playground]
54+
* lte(Promise.resolve({ a: 1, b: 1 }), get('a'), get('b')).then(console.log) // true
55+
* ```
5056
*/
5157
const lte = ComparisonOperator(lessThanOrEqual)
5258

map.js

+39
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ const _map = function (value, mapper) {
236236
* })()
237237
* ```
238238
*
239+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
240+
*
241+
* ```javascript [playground]
242+
* const asyncSquare = async n => n ** 2
243+
*
244+
* map(Promise.resolve([1, 2, 3, 4, 5]), asyncSquare).then(console.log)
245+
* // [1, 4, 9, 16, 25]
246+
* ```
247+
*
239248
* @execution concurrent
240249
*
241250
* @TODO streamMap
@@ -297,6 +306,18 @@ const _mapEntries = (value, mapper) => {
297306
* // Map(3) { 'A' => 1, 'B' => 4, 'C' => 9 }
298307
* ```
299308
*
309+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
310+
*
311+
* ```javascript [playground]
312+
* const asyncSquareEntries = async ([k, v]) => [k, v ** 2]
313+
*
314+
* map.entries(
315+
* Promise.resolve({ a: 1, b: 2, c: 3 }),
316+
* asyncSquareEntries,
317+
* ).then(console.log)
318+
* // { a: 1, b: 4, c: 9 }
319+
* ```
320+
*
300321
* @since v1.7.0
301322
*/
302323
map.entries = function mapEntries(arg0, arg1) {
@@ -379,6 +400,15 @@ const _mapSeries = function (collection, f) {
379400
* map.series([1, 2, 3, 4, 5], delayedLog)
380401
* ```
381402
*
403+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
404+
*
405+
* ```javascript [playground]
406+
* const asyncSquare = async n => n ** 2
407+
*
408+
* map.series(Promise.resolve([1, 2, 3, 4, 5]), asyncSquare).then(console.log)
409+
* // [1, 4, 9, 16, 25]
410+
* ```
411+
*
382412
* @execution series
383413
*/
384414
map.series = function mapSeries(arg0, arg1) {
@@ -460,6 +490,15 @@ const _mapPool = function (collection, concurrency, f) {
460490
* ]))(ids)
461491
* ```
462492
*
493+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
494+
*
495+
* ```javascript [playground]
496+
* const asyncSquare = async n => n ** 2
497+
*
498+
* map.pool(Promise.resolve([1, 2, 3, 4, 5]), 5, asyncSquare).then(console.log)
499+
* // [1, 4, 9, 16, 25]
500+
* ```
501+
*
463502
* @TODO objectMapPool
464503
*
465504
* @execution concurrent

not.js

+8
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ const _not = function (args, predicate) {
4545
* not(isOdd)(3),
4646
* ) // false
4747
* ```
48+
*
49+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
50+
*
51+
* ```javascript [playground]
52+
* const isOdd = number => number % 2 == 1
53+
*
54+
* not(Promise.resolve(3), isOdd).then(console.log) // false
55+
* ```
4856
*/
4957

5058
const not = function (...args) {

omit.js

+7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ const _omit = function (source, paths) {
6262
* console.log, // { c: 9 }
6363
* ])
6464
* ```
65+
*
66+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
67+
*
68+
* ```javascript [playground]
69+
* omit(Promise.resolve({ a: 1, b: 2, c: 3 }), ['a', 'b']).then(console.log)
70+
* // { c: 3 }
71+
* ```
6572
*/
6673
const omit = function (arg0, arg1) {
6774
if (arg1 == null) {

or.js

+9
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ const areAnyPredicatesTruthy = function (args, predicates) {
129129
* ) // true
130130
* ```
131131
*
132+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
133+
*
134+
* ```javascript [playground]
135+
* or(Promise.resolve('aaa'), [
136+
* s => s.startsWith('b'),
137+
* s => s.endsWith('a'),
138+
* ]).then(console.log) // true
139+
* ```
140+
*
132141
* @execution series
133142
*
134143
* @note ...args slows down here by an order of magnitude

pick.js

+7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ const _pick = function (source, keys) {
6262
* console.log, // { a: 1, c: 9 }
6363
* ])
6464
* ```
65+
*
66+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
67+
*
68+
* ```javascript [playground]
69+
* pick(Promise.resolve({ a: 1, b: 2, c: 3 }), ['a', 'b']).then(console.log)
70+
* // { a: 1, b: 2 }
71+
* ```
6572
*/
6673
const pick = function (arg0, arg1) {
6774
if (arg1 == null) {

pipe.js

+8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ const __ = require('./_internal/placeholder')
4646
* ])
4747
* ```
4848
*
49+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
50+
*
51+
* ```javascript [playground]
52+
* pipe(Promise.resolve(1), 2, Promise.resolve(3), [
53+
* console.log, // [1, 2, 3]
54+
* ])
55+
* ```
56+
*
4957
* @execution series
5058
*
5159
* @transducing

reduce.js

+8
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ const _reduce = function (collection, reducer, initialValue) {
172172
* reduce(asyncAdd)(asyncGenerate12345()).then(console.log) // 15
173173
* ```
174174
*
175+
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
176+
*
177+
* ```javascript [playground]
178+
* const add = (a, b) => a + b
179+
*
180+
* reduce(Promise.resolve([1, 2, 3, 4, 5]), add, 0).then(console.log) // 15
181+
* ```
182+
*
175183
* @execution series
176184
*
177185
* @transducing

0 commit comments

Comments
 (0)