Skip to content

Commit 2042ad3

Browse files
committed
build
1 parent 25979c9 commit 2042ad3

File tree

334 files changed

+2212
-883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

334 files changed

+2212
-883
lines changed

dist/Transducer.es.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* rubico v2.6.1
2+
* rubico v2.6.2
33
* https://github.com/a-synchronous/rubico
44
* (c) 2019-2024 Richard Tong
55
* rubico may be freely distributed under the MIT license.

dist/Transducer.es.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Transducer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* rubico v2.6.1
2+
* rubico v2.6.2
33
* https://github.com/a-synchronous/rubico
44
* (c) 2019-2024 Richard Tong
55
* rubico may be freely distributed under the MIT license.

dist/Transducer.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Transducer.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* rubico v2.6.1
2+
* rubico v2.6.2
33
* https://github.com/a-synchronous/rubico
44
* (c) 2019-2024 Richard Tong
55
* rubico may be freely distributed under the MIT license.

dist/__.es.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* rubico v2.6.1
2+
* rubico v2.6.2
33
* https://github.com/a-synchronous/rubico
44
* (c) 2019-2024 Richard Tong
55
* rubico may be freely distributed under the MIT license.

dist/__.es.min.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* rubico v2.6.1
2+
* rubico v2.6.2
33
* https://github.com/a-synchronous/rubico
44
* (c) 2019-2024 Richard Tong
55
* rubico may be freely distributed under the MIT license.

dist/__.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* rubico v2.6.1
2+
* rubico v2.6.2
33
* https://github.com/a-synchronous/rubico
44
* (c) 2019-2024 Richard Tong
55
* rubico may be freely distributed under the MIT license.

dist/__.min.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* rubico v2.6.1
2+
* rubico v2.6.2
33
* https://github.com/a-synchronous/rubico
44
* (c) 2019-2024 Richard Tong
55
* rubico may be freely distributed under the MIT license.

dist/__.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* rubico v2.6.1
2+
* rubico v2.6.2
33
* https://github.com/a-synchronous/rubico
44
* (c) 2019-2024 Richard Tong
55
* rubico may be freely distributed under the MIT license.

dist/all.es.js

+107-8
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,82 @@
11
/**
2-
* rubico v2.6.1
2+
* rubico v2.6.2
33
* https://github.com/a-synchronous/rubico
44
* (c) 2019-2024 Richard Tong
55
* rubico may be freely distributed under the MIT license.
66
*/
77

88
const isPromise = value => value != null && typeof value.then == 'function'
99

10+
const isArray = Array.isArray
11+
1012
const areAnyValuesPromises = function (values) {
11-
const length = values.length
12-
let index = -1
13-
while (++index < length) {
14-
const value = values[index]
13+
if (isArray(values)) {
14+
const length = values.length
15+
let index = -1
16+
while (++index < length) {
17+
const value = values[index]
18+
if (isPromise(value)) {
19+
return true
20+
}
21+
}
22+
return false
23+
}
24+
25+
for (const key in values) {
26+
const value = values[key]
1527
if (isPromise(value)) {
1628
return true
1729
}
1830
}
1931
return false
2032
}
2133

34+
const areAllValuesNonfunctions = function (values) {
35+
if (isArray(values)) {
36+
const length = values.length
37+
let index = -1
38+
while (++index < length) {
39+
if (typeof values[index] == 'function') {
40+
return false
41+
}
42+
}
43+
return true
44+
}
45+
46+
for (const key in values) {
47+
if (typeof values[key] == 'function') {
48+
return false
49+
}
50+
}
51+
return true
52+
}
53+
2254
const promiseAll = Promise.all.bind(Promise)
2355

24-
const isArray = Array.isArray
56+
const promiseObjectAllExecutor = object => function executor(resolve) {
57+
const result = {}
58+
let numPromises = 0
59+
for (const key in object) {
60+
const value = object[key]
61+
if (isPromise(value)) {
62+
numPromises += 1
63+
value.then((key => function (res) {
64+
result[key] = res
65+
numPromises -= 1
66+
if (numPromises == 0) {
67+
resolve(result)
68+
}
69+
})(key))
70+
} else {
71+
result[key] = value
72+
}
73+
}
74+
if (numPromises == 0) {
75+
resolve(result)
76+
}
77+
}
78+
79+
const promiseObjectAll = object => new Promise(promiseObjectAllExecutor(object))
2580

2681
const __ = Symbol.for('placeholder')
2782

@@ -71,7 +126,8 @@ const functionArrayAll = function (funcs, args) {
71126
result = Array(funcsLength)
72127
let funcsIndex = -1, isAsync = false
73128
while (++funcsIndex < funcsLength) {
74-
const resultItem = funcs[funcsIndex](...args)
129+
const f = funcs[funcsIndex]
130+
const resultItem = typeof f == 'function' ? f(...args) : f
75131
if (isPromise(resultItem)) {
76132
isAsync = true
77133
}
@@ -195,7 +251,8 @@ const always = value => function getter() { return value }
195251
const functionObjectAll = function (funcs, args) {
196252
const result = {}, promises = []
197253
for (const key in funcs) {
198-
const resultItem = funcs[key](...args)
254+
const f = funcs[key]
255+
const resultItem = typeof f == 'function' ? f(...args) : f
199256
if (isPromise(resultItem)) {
200257
promises.push(resultItem.then(curry3(objectSet, result, key, __)))
201258
} else {
@@ -205,7 +262,48 @@ const functionObjectAll = function (funcs, args) {
205262
return promises.length == 0 ? result : promiseAll(promises).then(always(result))
206263
}
207264

265+
const _allValues = function (values) {
266+
if (isArray(values)) {
267+
return areAnyValuesPromises(values)
268+
? promiseAll(values)
269+
: values
270+
}
271+
return areAnyValuesPromises(values)
272+
? promiseObjectAll(values)
273+
: values
274+
}
275+
208276
const all = function (...args) {
277+
if (args.length == 1) {
278+
const resolversOrValues = args[0]
279+
if (isPromise(resolversOrValues)) {
280+
return resolversOrValues.then(_allValues)
281+
}
282+
if (areAllValuesNonfunctions(resolversOrValues)) {
283+
return _allValues(resolversOrValues)
284+
}
285+
return isArray(resolversOrValues)
286+
? curryArgs2(functionArrayAll, resolversOrValues, __)
287+
: curryArgs2(functionObjectAll, resolversOrValues, __)
288+
}
289+
290+
const resolversOrValues = args[args.length - 1]
291+
const argValues = args.slice(0, -1)
292+
293+
if (areAnyValuesPromises(argValues)) {
294+
return isArray(resolversOrValues)
295+
? promiseAll(argValues)
296+
.then(curry2(functionArrayAll, resolversOrValues, __))
297+
: promiseAll(argValues)
298+
.then(curry2(functionObjectAll, resolversOrValues, __))
299+
}
300+
301+
return isArray(resolversOrValues)
302+
? functionArrayAll(resolversOrValues, argValues)
303+
: functionObjectAll(resolversOrValues, argValues)
304+
305+
/*
306+
////////////////////////////////////////////////////////////////
209307
const funcs = args.pop()
210308
if (args.length == 0) {
211309
return isArray(funcs)
@@ -222,6 +320,7 @@ const all = function (...args) {
222320
return isArray(funcs)
223321
? functionArrayAll(funcs, args)
224322
: functionObjectAll(funcs, args)
323+
*/
225324
}
226325

227326
all.series = function allSeries(...args) {

dist/all.es.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)