1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.hasOwnProperty = exports.promiseReduce = exports.isPromise = exports.isObjectLike = exports.isIterableObject = void 0;
|
4 | function isIterableObject(value) {
|
5 | return value != null && typeof value === 'object' && Symbol.iterator in value;
|
6 | }
|
7 | exports.isIterableObject = isIterableObject;
|
8 | function isObjectLike(value) {
|
9 | return typeof value === 'object' && value !== null;
|
10 | }
|
11 | exports.isObjectLike = isObjectLike;
|
12 | function isPromise(value) {
|
13 | return value?.then != null;
|
14 | }
|
15 | exports.isPromise = isPromise;
|
16 | function promiseReduce(values, callbackFn, initialValue) {
|
17 | let accumulator = initialValue;
|
18 | for (const value of values) {
|
19 | accumulator = isPromise(accumulator)
|
20 | ? accumulator.then(resolved => callbackFn(resolved, value))
|
21 | : callbackFn(accumulator, value);
|
22 | }
|
23 | return accumulator;
|
24 | }
|
25 | exports.promiseReduce = promiseReduce;
|
26 | function hasOwnProperty(obj, prop) {
|
27 | return Object.prototype.hasOwnProperty.call(obj, prop);
|
28 | }
|
29 | exports.hasOwnProperty = hasOwnProperty;
|