1 | export function isIterableObject(value) {
|
2 | return value != null && typeof value === 'object' && Symbol.iterator in value;
|
3 | }
|
4 | export function isObjectLike(value) {
|
5 | return typeof value === 'object' && value !== null;
|
6 | }
|
7 | export function isPromise(value) {
|
8 | return value?.then != null;
|
9 | }
|
10 | export function promiseReduce(values, callbackFn, initialValue) {
|
11 | let accumulator = initialValue;
|
12 | for (const value of values) {
|
13 | accumulator = isPromise(accumulator)
|
14 | ? accumulator.then(resolved => callbackFn(resolved, value))
|
15 | : callbackFn(accumulator, value);
|
16 | }
|
17 | return accumulator;
|
18 | }
|
19 | export function hasOwnProperty(obj, prop) {
|
20 | return Object.prototype.hasOwnProperty.call(obj, prop);
|
21 | }
|