@naturalcycles/js-lib 14.69.4 → 14.71.0

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.
@@ -1,4 +1,4 @@
1
- import { AppError, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse, StringifyAnyOptions } from '..';
1
+ import { AppError, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse, StringifyAnyOptions, Class } from '..';
2
2
  /**
3
3
  * Useful to ensure that error in `catch (err) { ... }`
4
4
  * is indeed an Error (and not e.g `string` or `undefined`).
@@ -7,7 +7,7 @@ import { AppError, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse, Str
7
7
  *
8
8
  * Alternatively, if you're sure it's Error - you can use `_assertIsError(err)`.
9
9
  */
10
- export declare function _anyToError(o: any, opt?: StringifyAnyOptions): Error;
10
+ export declare function _anyToError<ERROR_TYPE extends Error = Error>(o: any, errorClass?: Class<ERROR_TYPE>, opt?: StringifyAnyOptions): ERROR_TYPE;
11
11
  /**
12
12
  * Converts "anything" to ErrorObject.
13
13
  * Detects if it's HttpErrorResponse, HttpErrorObject, ErrorObject, Error, etc..
@@ -17,6 +17,10 @@ export declare function _anyToError(o: any, opt?: StringifyAnyOptions): Error;
17
17
  export declare function _anyToErrorObject<DATA_TYPE extends ErrorData = ErrorData>(o: any, opt?: StringifyAnyOptions): ErrorObject<DATA_TYPE>;
18
18
  export declare function _errorToErrorObject<DATA_TYPE extends ErrorData = ErrorData>(e: AppError<DATA_TYPE> | Error, includeErrorStack?: boolean): ErrorObject<DATA_TYPE>;
19
19
  export declare function _errorObjectToAppError<DATA_TYPE>(o: ErrorObject<DATA_TYPE>): AppError<DATA_TYPE>;
20
+ export declare function _errorObjectToError<DATA_TYPE, ERROR_TYPE extends Error>(o: ErrorObject<DATA_TYPE>, errorClass?: Class<ERROR_TYPE>): ERROR_TYPE;
20
21
  export declare function _isHttpErrorResponse(o: any): o is HttpErrorResponse;
21
22
  export declare function _isHttpErrorObject(o: any): o is ErrorObject<HttpErrorData>;
23
+ /**
24
+ * Note: any instance of AppError is also automatically an ErrorObject
25
+ */
22
26
  export declare function _isErrorObject(o: any): o is ErrorObject;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._isErrorObject = exports._isHttpErrorObject = exports._isHttpErrorResponse = exports._errorObjectToAppError = exports._errorToErrorObject = exports._anyToErrorObject = exports._anyToError = void 0;
3
+ exports._isErrorObject = exports._isHttpErrorObject = exports._isHttpErrorResponse = exports._errorObjectToError = exports._errorObjectToAppError = exports._errorToErrorObject = exports._anyToErrorObject = exports._anyToError = void 0;
4
4
  const __1 = require("..");
5
5
  /**
6
6
  * Useful to ensure that error in `catch (err) { ... }`
@@ -10,13 +10,12 @@ const __1 = require("..");
10
10
  *
11
11
  * Alternatively, if you're sure it's Error - you can use `_assertIsError(err)`.
12
12
  */
13
- function _anyToError(o, opt) {
14
- if (o instanceof Error) {
15
- // Already an Error - return as-is
13
+ function _anyToError(o, errorClass = Error, opt) {
14
+ if (o instanceof errorClass)
16
15
  return o;
17
- }
18
- const message = (0, __1._stringifyAny)(o, opt);
19
- return new Error(message);
16
+ // If it's an instance of Error, but ErrorClass is something else (e.g AppError) - it'll be "repacked" into AppError
17
+ const errorObject = _isErrorObject(o) ? o : _anyToErrorObject(o, opt);
18
+ return _errorObjectToError(errorObject, errorClass);
20
19
  }
21
20
  exports._anyToError = _anyToError;
22
21
  /**
@@ -27,7 +26,7 @@ exports._anyToError = _anyToError;
27
26
  */
28
27
  function _anyToErrorObject(o, opt) {
29
28
  if (o instanceof Error) {
30
- return _errorToErrorObject(o, opt?.includeErrorStack);
29
+ return _errorToErrorObject(o, opt?.includeErrorStack ?? true);
31
30
  }
32
31
  o = (0, __1._jsonParseIfPossible)(o);
33
32
  if (_isHttpErrorResponse(o)) {
@@ -51,7 +50,7 @@ function _anyToErrorObject(o, opt) {
51
50
  };
52
51
  }
53
52
  exports._anyToErrorObject = _anyToErrorObject;
54
- function _errorToErrorObject(e, includeErrorStack = false) {
53
+ function _errorToErrorObject(e, includeErrorStack = true) {
55
54
  const obj = {
56
55
  name: e.name,
57
56
  message: e.message,
@@ -64,31 +63,48 @@ function _errorToErrorObject(e, includeErrorStack = false) {
64
63
  }
65
64
  exports._errorToErrorObject = _errorToErrorObject;
66
65
  function _errorObjectToAppError(o) {
67
- const err = Object.assign(new __1.AppError(o.message, o.data), {
66
+ return _errorObjectToError(o, __1.AppError);
67
+ }
68
+ exports._errorObjectToAppError = _errorObjectToAppError;
69
+ function _errorObjectToError(o, errorClass = Error) {
70
+ if (o instanceof errorClass)
71
+ return o;
72
+ const err = new errorClass(o.message);
68
73
  // name: err.name, // cannot be assigned to a readonly property like this
69
74
  // stack: o.stack, // also readonly e.g in Firefox
70
- });
71
75
  Object.defineProperty(err, 'name', {
72
76
  value: o.name,
73
77
  configurable: true,
74
78
  });
75
- Object.defineProperty(err, 'stack', {
76
- value: o.stack,
79
+ Object.defineProperty(err, 'data', {
80
+ value: o.data,
81
+ writable: true,
82
+ configurable: true,
83
+ enumerable: false,
77
84
  });
85
+ if (o.stack) {
86
+ Object.defineProperty(err, 'stack', {
87
+ value: o.stack,
88
+ });
89
+ }
78
90
  return err;
79
91
  }
80
- exports._errorObjectToAppError = _errorObjectToAppError;
92
+ exports._errorObjectToError = _errorObjectToError;
81
93
  function _isHttpErrorResponse(o) {
82
94
  return _isHttpErrorObject(o?.error);
83
95
  }
84
96
  exports._isHttpErrorResponse = _isHttpErrorResponse;
85
97
  function _isHttpErrorObject(o) {
86
- return (typeof o?.name === 'string' &&
87
- typeof o?.message === 'string' &&
88
- typeof o?.data?.httpStatusCode === 'number');
98
+ return (!!o &&
99
+ typeof o.name === 'string' &&
100
+ typeof o.message === 'string' &&
101
+ typeof o.data?.httpStatusCode === 'number');
89
102
  }
90
103
  exports._isHttpErrorObject = _isHttpErrorObject;
104
+ /**
105
+ * Note: any instance of AppError is also automatically an ErrorObject
106
+ */
91
107
  function _isErrorObject(o) {
92
- return (typeof o?.name === 'string' && typeof o?.message === 'string' && typeof o?.data === 'object');
108
+ return (!!o && typeof o.name === 'string' && typeof o.message === 'string' && typeof o.data === 'object');
93
109
  }
94
110
  exports._isErrorObject = _isErrorObject;
@@ -21,4 +21,4 @@ export declare function _try<ERR = unknown, RETURN = void>(fn: () => RETURN): [e
21
21
  * Also, intentionally types second return item as non-optional,
22
22
  * but you should check for `err` presense first!
23
23
  */
24
- export declare function pTry<ERR = unknown, RETURN = void>(promise: Promise<RETURN>): Promise<[err: ERR | null, value: RETURN]>;
24
+ export declare function pTry<ERR = unknown, RETURN = void>(promise: Promise<RETURN>): Promise<[err: ERR | null, value: Awaited<RETURN>]>;
package/dist/error/try.js CHANGED
@@ -26,6 +26,8 @@ function _try(fn) {
26
26
  }
27
27
  }
28
28
  exports._try = _try;
29
+ // todo: remove when eslint starts to know about Awaited
30
+ /* eslint-disable no-undef */
29
31
  /**
30
32
  * Like _try, but for Promises.
31
33
  *
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ import { _Timeout } from './decorators/timeout.decorator';
15
15
  import { AppError } from './error/app.error';
16
16
  import { AssertionError, _assert, _assertDeepEquals, _assertEquals, _assertIsError, _assertIsNumber, _assertIsString, _assertTypeOf } from './error/assert';
17
17
  import { Admin401ErrorData, Admin403ErrorData, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse } from './error/error.model';
18
- import { _anyToError, _anyToErrorObject, _errorObjectToAppError, _errorToErrorObject, _isErrorObject, _isHttpErrorObject, _isHttpErrorResponse } from './error/error.util';
18
+ export * from './error/error.util';
19
19
  import { ErrorMode } from './error/errorMode';
20
20
  import { HttpError } from './error/http.error';
21
21
  import { _try, pTry } from './error/try';
@@ -50,12 +50,13 @@ import { _jsonParseIfPossible } from './string/json.util';
50
50
  import { _capitalize, _lowerFirst, _nl2br, _removeWhitespace, _replaceAll, _split, _substringAfter, _substringAfterLast, _substringBefore, _substringBeforeLast, _substringBetweenLast, _truncate, _truncateMiddle, _upperFirst } from './string/string.util';
51
51
  import { JsonStringifyFunction, StringifyAnyOptions, _stringifyAny } from './string/stringifyAny';
52
52
  import { _ms, _since } from './time/time.util';
53
- import { Class, ConditionalExcept, ConditionalPick, Merge, Promisable, PromiseValue, ReadonlyDeep, Simplify } from './typeFest';
54
- import { AsyncMapper, AsyncPredicate, BaseDBEntity, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, Saved, Unsaved, BatchResult, InstanceId, IsoDate, IsoDateTime, KeyValueTuple, Mapper, ObjectMapper, ObjectPredicate, Predicate, PromiseMap, AnyObject, AnyFunction, Reviver, SavedDBEntity, StringMap, UnixTimestamp, ValueOf, ValuesOf, _noop, _objectKeys, _passNothingPredicate, _passthroughMapper, _passthroughPredicate, _passUndefinedMapper, _stringMapEntries, _stringMapValues } from './types';
53
+ import { Class, ConditionalExcept, ConditionalPick, Merge, Promisable, ReadonlyDeep, Simplify } from './typeFest';
54
+ import { AsyncMapper, AsyncPredicate, BaseDBEntity, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, Saved, Unsaved, BatchResult, InstanceId, IsoDate, IsoDateTime, KeyValueTuple, Mapper, ObjectMapper, ObjectPredicate, Predicate, PromiseMap, AnyObject, AnyFunction, Reviver, SavedDBEntity, StringMap, UnixTimestamp, ValueOf, ValuesOf, AbortableMapper, AbortableAsyncPredicate, AbortableAsyncMapper, AbortablePredicate, END, SKIP, _noop, _objectKeys, _passNothingPredicate, _passthroughMapper, _passthroughPredicate, _passUndefinedMapper, _stringMapEntries, _stringMapValues } from './types';
55
55
  import { _gb, _hb, _kb, _mb } from './unit/size.util';
56
56
  import { is } from './vendor/is';
57
57
  import { CommonLogLevel, CommonLogFunction, CommonLogger, commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLoggerPipe, commonLoggerPrefix, CommonLogWithLevelFunction, commonLoggerCreate } from './log/commonLogger';
58
58
  import { _safeJsonStringify } from './string/safeJsonStringify';
59
59
  import { PQueue, PQueueCfg } from './promise/pQueue';
60
- export type { PQueueCfg, MemoCache, PromiseDecoratorCfg, PromiseDecoratorResp, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse, Admin401ErrorData, Admin403ErrorData, StringMap, PromiseMap, AnyObject, AnyFunction, ValuesOf, ValueOf, KeyValueTuple, ObjectMapper, ObjectPredicate, InstanceId, IsoDate, IsoDateTime, Reviver, PMapOptions, Mapper, AsyncMapper, Predicate, AsyncPredicate, BatchResult, DeferredPromise, PRetryOptions, PTimeoutOptions, TryCatchOptions, StringifyAnyOptions, JsonStringifyFunction, Merge, ReadonlyDeep, Promisable, PromiseValue, Simplify, ConditionalPick, ConditionalExcept, Class, UnixTimestamp, BaseDBEntity, SavedDBEntity, Saved, Unsaved, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, JsonSchema, JsonSchemaAny, JsonSchemaOneOf, JsonSchemaAllOf, JsonSchemaAnyOf, JsonSchemaNot, JsonSchemaRef, JsonSchemaConst, JsonSchemaEnum, JsonSchemaString, JsonSchemaNumber, JsonSchemaBoolean, JsonSchemaNull, JsonSchemaRootObject, JsonSchemaObject, JsonSchemaArray, JsonSchemaTuple, JsonSchemaBuilder, CommonLogLevel, CommonLogWithLevelFunction, CommonLogFunction, CommonLogger, };
61
- export { is, _Memo, _memoFn, _LogMethod, _getArgsSignature, _createPromiseDecorator, AppError, HttpError, AssertionError, _isErrorObject, _isHttpErrorObject, _isHttpErrorResponse, _assert, _assertEquals, _assertDeepEquals, _assertIsError, _assertIsString, _assertIsNumber, _assertTypeOf, _randomInt, _randomArrayItem, _createDeterministicRandom, _inRange, _stringMapValues, _stringMapEntries, _objectKeys, _capitalize, _upperFirst, _lowerFirst, _split, _removeWhitespace, _substringBefore, _substringBeforeLast, _substringAfter, _substringAfterLast, _substringBetweenLast, _replaceAll, _nl2br, _truncate, _truncateMiddle, _pick, _omit, _filterFalsyValues, _filterUndefinedValues, _filterNullishValues, _filterEmptyArrays, _filterEmptyValues, _filterObject, _undefinedIfEmpty, _isObject, _isPrimitive, _mapKeys, _mapValues, _mapObject, _objectNullValuesToUndefined, _deepEquals, _deepCopy, _isEmptyObject, _isEmpty, _merge, _deepTrim, _sortObjectDeep, _sortObject, _get, _set, _has, _unset, _mask, _invert, _invertMap, _by, _groupBy, _sortBy, _sortNumbers, _toFixed, _toPrecision, _round, _findLast, _takeWhile, _takeRightWhile, _dropWhile, _dropRightWhile, _countBy, _intersection, _difference, _shuffle, _mapToObject, _findKeyByValue, _anyToError, _anyToErrorObject, _errorToErrorObject, _errorObjectToAppError, _range, _uniq, _uniqBy, _flatten, _flattenDeep, _chunk, SimpleMovingAverage, _average, _averageWeighted, _percentile, _median, _debounce, _throttle, _Debounce, _Throttle, pMap, _passthroughMapper, _passUndefinedMapper, _passthroughPredicate, _passNothingPredicate, _noop, pBatch, ErrorMode, pFilter, pProps, pDelay, pDefer, pHang, pState, AggregatedError, pRetry, pTimeout, pTuple, _Retry, _Timeout, _tryCatch, _TryCatch, _try, pTry, _jsonParseIfPossible, _stringifyAny, _ms, _since, _hb, _gb, _mb, _kb, _snakeCase, _camelCase, _kebabCase, _sum, _sumBy, _clamp, _last, mergeJsonSchemaObjects, jsonSchema, JsonSchemaAnyBuilder, JSON_SCHEMA_ORDER, generateJsonSchemaFromData, _parseQueryString, _defineLazyProperty, _defineLazyProps, _lazyValue, commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLoggerPipe, commonLoggerPrefix, commonLoggerCreate, _safeJsonStringify, PQueue, };
60
+ export * from './seq/seq';
61
+ export type { AbortableMapper, AbortablePredicate, AbortableAsyncPredicate, AbortableAsyncMapper, PQueueCfg, MemoCache, PromiseDecoratorCfg, PromiseDecoratorResp, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse, Admin401ErrorData, Admin403ErrorData, StringMap, PromiseMap, AnyObject, AnyFunction, ValuesOf, ValueOf, KeyValueTuple, ObjectMapper, ObjectPredicate, InstanceId, IsoDate, IsoDateTime, Reviver, PMapOptions, Mapper, AsyncMapper, Predicate, AsyncPredicate, BatchResult, DeferredPromise, PRetryOptions, PTimeoutOptions, TryCatchOptions, StringifyAnyOptions, JsonStringifyFunction, Merge, ReadonlyDeep, Promisable, Simplify, ConditionalPick, ConditionalExcept, Class, UnixTimestamp, BaseDBEntity, SavedDBEntity, Saved, Unsaved, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, JsonSchema, JsonSchemaAny, JsonSchemaOneOf, JsonSchemaAllOf, JsonSchemaAnyOf, JsonSchemaNot, JsonSchemaRef, JsonSchemaConst, JsonSchemaEnum, JsonSchemaString, JsonSchemaNumber, JsonSchemaBoolean, JsonSchemaNull, JsonSchemaRootObject, JsonSchemaObject, JsonSchemaArray, JsonSchemaTuple, JsonSchemaBuilder, CommonLogLevel, CommonLogWithLevelFunction, CommonLogFunction, CommonLogger, };
62
+ export { is, _Memo, _memoFn, _LogMethod, _getArgsSignature, _createPromiseDecorator, AppError, HttpError, AssertionError, _assert, _assertEquals, _assertDeepEquals, _assertIsError, _assertIsString, _assertIsNumber, _assertTypeOf, _randomInt, _randomArrayItem, _createDeterministicRandom, _inRange, _stringMapValues, _stringMapEntries, _objectKeys, _capitalize, _upperFirst, _lowerFirst, _split, _removeWhitespace, _substringBefore, _substringBeforeLast, _substringAfter, _substringAfterLast, _substringBetweenLast, _replaceAll, _nl2br, _truncate, _truncateMiddle, _pick, _omit, _filterFalsyValues, _filterUndefinedValues, _filterNullishValues, _filterEmptyArrays, _filterEmptyValues, _filterObject, _undefinedIfEmpty, _isObject, _isPrimitive, _mapKeys, _mapValues, _mapObject, _objectNullValuesToUndefined, _deepEquals, _deepCopy, _isEmptyObject, _isEmpty, _merge, _deepTrim, _sortObjectDeep, _sortObject, _get, _set, _has, _unset, _mask, _invert, _invertMap, _by, _groupBy, _sortBy, _sortNumbers, _toFixed, _toPrecision, _round, _findLast, _takeWhile, _takeRightWhile, _dropWhile, _dropRightWhile, _countBy, _intersection, _difference, _shuffle, _mapToObject, _findKeyByValue, _range, _uniq, _uniqBy, _flatten, _flattenDeep, _chunk, SimpleMovingAverage, _average, _averageWeighted, _percentile, _median, _debounce, _throttle, _Debounce, _Throttle, pMap, _passthroughMapper, _passUndefinedMapper, _passthroughPredicate, _passNothingPredicate, _noop, pBatch, ErrorMode, pFilter, pProps, pDelay, pDefer, pHang, pState, AggregatedError, pRetry, pTimeout, pTuple, _Retry, _Timeout, _tryCatch, _TryCatch, _try, pTry, _jsonParseIfPossible, _stringifyAny, _ms, _since, _hb, _gb, _mb, _kb, _snakeCase, _camelCase, _kebabCase, _sum, _sumBy, _clamp, _last, mergeJsonSchemaObjects, jsonSchema, JsonSchemaAnyBuilder, JSON_SCHEMA_ORDER, generateJsonSchemaFromData, _parseQueryString, _defineLazyProperty, _defineLazyProps, _lazyValue, commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLoggerPipe, commonLoggerPrefix, commonLoggerCreate, _safeJsonStringify, PQueue, END, SKIP, };
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._isObject = exports._undefinedIfEmpty = exports._filterObject = exports._filterEmptyValues = exports._filterEmptyArrays = exports._filterNullishValues = exports._filterUndefinedValues = exports._filterFalsyValues = exports._omit = exports._pick = exports._truncateMiddle = exports._truncate = exports._nl2br = exports._replaceAll = exports._substringBetweenLast = exports._substringAfterLast = exports._substringAfter = exports._substringBeforeLast = exports._substringBefore = exports._removeWhitespace = exports._split = exports._lowerFirst = exports._upperFirst = exports._capitalize = exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._inRange = exports._createDeterministicRandom = exports._randomArrayItem = exports._randomInt = exports._assertTypeOf = exports._assertIsNumber = exports._assertIsString = exports._assertIsError = exports._assertDeepEquals = exports._assertEquals = exports._assert = exports._isHttpErrorResponse = exports._isHttpErrorObject = exports._isErrorObject = exports.AssertionError = exports.HttpError = exports.AppError = exports._createPromiseDecorator = exports._getArgsSignature = exports._LogMethod = exports._memoFn = exports._Memo = exports.is = void 0;
4
- exports._average = exports.SimpleMovingAverage = exports._chunk = exports._flattenDeep = exports._flatten = exports._uniqBy = exports._uniq = exports._range = exports._errorObjectToAppError = exports._errorToErrorObject = exports._anyToErrorObject = exports._anyToError = exports._findKeyByValue = exports._mapToObject = exports._shuffle = exports._difference = exports._intersection = exports._countBy = exports._dropRightWhile = exports._dropWhile = exports._takeRightWhile = exports._takeWhile = exports._findLast = exports._round = exports._toPrecision = exports._toFixed = exports._sortNumbers = exports._sortBy = exports._groupBy = exports._by = exports._invertMap = exports._invert = exports._mask = exports._unset = exports._has = exports._set = exports._get = exports._sortObject = exports._sortObjectDeep = exports._deepTrim = exports._merge = exports._isEmpty = exports._isEmptyObject = exports._deepCopy = exports._deepEquals = exports._objectNullValuesToUndefined = exports._mapObject = exports._mapValues = exports._mapKeys = exports._isPrimitive = void 0;
5
- exports.JSON_SCHEMA_ORDER = exports.JsonSchemaAnyBuilder = exports.jsonSchema = exports.mergeJsonSchemaObjects = exports._last = exports._clamp = exports._sumBy = exports._sum = exports._kebabCase = exports._camelCase = exports._snakeCase = exports._kb = exports._mb = exports._gb = exports._hb = exports._since = exports._ms = exports._stringifyAny = exports._jsonParseIfPossible = exports.pTry = exports._try = exports._TryCatch = exports._tryCatch = exports._Timeout = exports._Retry = exports.pTuple = exports.pTimeout = exports.pRetry = exports.AggregatedError = exports.pState = exports.pHang = exports.pDefer = exports.pDelay = exports.pProps = exports.pFilter = exports.ErrorMode = exports.pBatch = exports._noop = exports._passNothingPredicate = exports._passthroughPredicate = exports._passUndefinedMapper = exports._passthroughMapper = exports.pMap = exports._Throttle = exports._Debounce = exports._throttle = exports._debounce = exports._median = exports._percentile = exports._averageWeighted = void 0;
6
- exports.PQueue = exports._safeJsonStringify = exports.commonLoggerCreate = exports.commonLoggerPrefix = exports.commonLoggerPipe = exports.commonLogLevelNumber = exports.commonLoggerNoop = exports.commonLoggerMinLevel = exports._lazyValue = exports._defineLazyProps = exports._defineLazyProperty = exports._parseQueryString = exports.generateJsonSchemaFromData = void 0;
3
+ exports._mapValues = exports._mapKeys = exports._isPrimitive = exports._isObject = exports._undefinedIfEmpty = exports._filterObject = exports._filterEmptyValues = exports._filterEmptyArrays = exports._filterNullishValues = exports._filterUndefinedValues = exports._filterFalsyValues = exports._omit = exports._pick = exports._truncateMiddle = exports._truncate = exports._nl2br = exports._replaceAll = exports._substringBetweenLast = exports._substringAfterLast = exports._substringAfter = exports._substringBeforeLast = exports._substringBefore = exports._removeWhitespace = exports._split = exports._lowerFirst = exports._upperFirst = exports._capitalize = exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._inRange = exports._createDeterministicRandom = exports._randomArrayItem = exports._randomInt = exports._assertTypeOf = exports._assertIsNumber = exports._assertIsString = exports._assertIsError = exports._assertDeepEquals = exports._assertEquals = exports._assert = exports.AssertionError = exports.HttpError = exports.AppError = exports._createPromiseDecorator = exports._getArgsSignature = exports._LogMethod = exports._memoFn = exports._Memo = exports.is = void 0;
4
+ exports._Throttle = exports._Debounce = exports._throttle = exports._debounce = exports._median = exports._percentile = exports._averageWeighted = exports._average = exports.SimpleMovingAverage = exports._chunk = exports._flattenDeep = exports._flatten = exports._uniqBy = exports._uniq = exports._range = exports._findKeyByValue = exports._mapToObject = exports._shuffle = exports._difference = exports._intersection = exports._countBy = exports._dropRightWhile = exports._dropWhile = exports._takeRightWhile = exports._takeWhile = exports._findLast = exports._round = exports._toPrecision = exports._toFixed = exports._sortNumbers = exports._sortBy = exports._groupBy = exports._by = exports._invertMap = exports._invert = exports._mask = exports._unset = exports._has = exports._set = exports._get = exports._sortObject = exports._sortObjectDeep = exports._deepTrim = exports._merge = exports._isEmpty = exports._isEmptyObject = exports._deepCopy = exports._deepEquals = exports._objectNullValuesToUndefined = exports._mapObject = void 0;
5
+ exports.commonLoggerNoop = exports.commonLoggerMinLevel = exports._lazyValue = exports._defineLazyProps = exports._defineLazyProperty = exports._parseQueryString = exports.generateJsonSchemaFromData = exports.JSON_SCHEMA_ORDER = exports.JsonSchemaAnyBuilder = exports.jsonSchema = exports.mergeJsonSchemaObjects = exports._last = exports._clamp = exports._sumBy = exports._sum = exports._kebabCase = exports._camelCase = exports._snakeCase = exports._kb = exports._mb = exports._gb = exports._hb = exports._since = exports._ms = exports._stringifyAny = exports._jsonParseIfPossible = exports.pTry = exports._try = exports._TryCatch = exports._tryCatch = exports._Timeout = exports._Retry = exports.pTuple = exports.pTimeout = exports.pRetry = exports.AggregatedError = exports.pState = exports.pHang = exports.pDefer = exports.pDelay = exports.pProps = exports.pFilter = exports.ErrorMode = exports.pBatch = exports._noop = exports._passNothingPredicate = exports._passthroughPredicate = exports._passUndefinedMapper = exports._passthroughMapper = exports.pMap = void 0;
6
+ exports.SKIP = exports.END = exports.PQueue = exports._safeJsonStringify = exports.commonLoggerCreate = exports.commonLoggerPrefix = exports.commonLoggerPipe = exports.commonLogLevelNumber = void 0;
7
+ const tslib_1 = require("tslib");
7
8
  const array_util_1 = require("./array/array.util");
8
9
  Object.defineProperty(exports, "_by", { enumerable: true, get: function () { return array_util_1._by; } });
9
10
  Object.defineProperty(exports, "_chunk", { enumerable: true, get: function () { return array_util_1._chunk; } });
@@ -65,14 +66,7 @@ Object.defineProperty(exports, "_assertIsError", { enumerable: true, get: functi
65
66
  Object.defineProperty(exports, "_assertIsNumber", { enumerable: true, get: function () { return assert_1._assertIsNumber; } });
66
67
  Object.defineProperty(exports, "_assertIsString", { enumerable: true, get: function () { return assert_1._assertIsString; } });
67
68
  Object.defineProperty(exports, "_assertTypeOf", { enumerable: true, get: function () { return assert_1._assertTypeOf; } });
68
- const error_util_1 = require("./error/error.util");
69
- Object.defineProperty(exports, "_anyToError", { enumerable: true, get: function () { return error_util_1._anyToError; } });
70
- Object.defineProperty(exports, "_anyToErrorObject", { enumerable: true, get: function () { return error_util_1._anyToErrorObject; } });
71
- Object.defineProperty(exports, "_errorObjectToAppError", { enumerable: true, get: function () { return error_util_1._errorObjectToAppError; } });
72
- Object.defineProperty(exports, "_errorToErrorObject", { enumerable: true, get: function () { return error_util_1._errorToErrorObject; } });
73
- Object.defineProperty(exports, "_isErrorObject", { enumerable: true, get: function () { return error_util_1._isErrorObject; } });
74
- Object.defineProperty(exports, "_isHttpErrorObject", { enumerable: true, get: function () { return error_util_1._isHttpErrorObject; } });
75
- Object.defineProperty(exports, "_isHttpErrorResponse", { enumerable: true, get: function () { return error_util_1._isHttpErrorResponse; } });
69
+ (0, tslib_1.__exportStar)(require("./error/error.util"), exports);
76
70
  const errorMode_1 = require("./error/errorMode");
77
71
  Object.defineProperty(exports, "ErrorMode", { enumerable: true, get: function () { return errorMode_1.ErrorMode; } });
78
72
  const http_error_1 = require("./error/http.error");
@@ -196,6 +190,8 @@ const time_util_1 = require("./time/time.util");
196
190
  Object.defineProperty(exports, "_ms", { enumerable: true, get: function () { return time_util_1._ms; } });
197
191
  Object.defineProperty(exports, "_since", { enumerable: true, get: function () { return time_util_1._since; } });
198
192
  const types_1 = require("./types");
193
+ Object.defineProperty(exports, "END", { enumerable: true, get: function () { return types_1.END; } });
194
+ Object.defineProperty(exports, "SKIP", { enumerable: true, get: function () { return types_1.SKIP; } });
199
195
  Object.defineProperty(exports, "_noop", { enumerable: true, get: function () { return types_1._noop; } });
200
196
  Object.defineProperty(exports, "_objectKeys", { enumerable: true, get: function () { return types_1._objectKeys; } });
201
197
  Object.defineProperty(exports, "_passNothingPredicate", { enumerable: true, get: function () { return types_1._passNothingPredicate; } });
@@ -222,3 +218,4 @@ const safeJsonStringify_1 = require("./string/safeJsonStringify");
222
218
  Object.defineProperty(exports, "_safeJsonStringify", { enumerable: true, get: function () { return safeJsonStringify_1._safeJsonStringify; } });
223
219
  const pQueue_1 = require("./promise/pQueue");
224
220
  Object.defineProperty(exports, "PQueue", { enumerable: true, get: function () { return pQueue_1.PQueue; } });
221
+ (0, tslib_1.__exportStar)(require("./seq/seq"), exports);
@@ -1,8 +1,7 @@
1
- import { BatchResult } from '..';
2
- import { AsyncMapper } from '../types';
1
+ import { AbortableAsyncMapper, BatchResult } from '..';
3
2
  /**
4
3
  * Like pMap, but doesn't fail on errors, instead returns both successful results and errors.
5
4
  */
6
- export declare function pBatch<IN, OUT>(iterable: Iterable<IN | PromiseLike<IN>>, mapper: AsyncMapper<IN, OUT>, opt?: {
5
+ export declare function pBatch<IN, OUT>(iterable: Iterable<IN | PromiseLike<IN>>, mapper: AbortableAsyncMapper<IN, OUT>, opt?: {
7
6
  concurrency?: number;
8
7
  }): Promise<BatchResult<OUT>>;
@@ -1,3 +1,3 @@
1
- import { AsyncPredicate } from '../types';
1
+ import { AbortableAsyncPredicate } from '../types';
2
2
  import { PMapOptions } from './pMap';
3
- export declare function pFilter<T>(iterable: Iterable<T | PromiseLike<T>>, filterFn: AsyncPredicate<T>, opt?: PMapOptions): Promise<T[]>;
3
+ export declare function pFilter<T>(iterable: Iterable<T | PromiseLike<T>>, filterFn: AbortableAsyncPredicate<T>, opt?: PMapOptions): Promise<T[]>;
@@ -1,5 +1,4 @@
1
- import { ErrorMode } from '..';
2
- import { AsyncMapper } from '../types';
1
+ import { AbortableAsyncMapper, ErrorMode } from '..';
3
2
  export interface PMapOptions {
4
3
  /**
5
4
  * Number of concurrently pending promises returned by `mapper`.
@@ -42,4 +41,4 @@ export interface PMapOptions {
42
41
  * //=> ['http://ava.li/', 'http://todomvc.com/']
43
42
  * })();
44
43
  */
45
- export declare function pMap<IN, OUT>(iterable: Iterable<IN | PromiseLike<IN>>, mapper: AsyncMapper<IN, OUT>, opt?: PMapOptions): Promise<OUT[]>;
44
+ export declare function pMap<IN, OUT>(iterable: Iterable<IN | PromiseLike<IN>>, mapper: AbortableAsyncMapper<IN, OUT>, opt?: PMapOptions): Promise<OUT[]>;
@@ -43,25 +43,27 @@ async function pMap(iterable, mapper, opt = {}) {
43
43
  const ret = [];
44
44
  const iterator = iterable[Symbol.iterator]();
45
45
  const errors = [];
46
- let isRejected = false;
46
+ let isSettled = false;
47
47
  let isIterableDone = false;
48
48
  let resolvingCount = 0;
49
49
  let currentIndex = 0;
50
- const next = () => {
51
- if (isRejected) {
50
+ const next = (skipped = false) => {
51
+ if (isSettled) {
52
52
  return;
53
53
  }
54
54
  const nextItem = iterator.next();
55
55
  const i = currentIndex;
56
- currentIndex++;
56
+ if (!skipped)
57
+ currentIndex++;
57
58
  if (nextItem.done) {
58
59
  isIterableDone = true;
59
60
  if (resolvingCount === 0) {
61
+ const r = ret.filter(r => r !== __1.SKIP);
60
62
  if (errors.length && errorMode === __1.ErrorMode.THROW_AGGREGATED) {
61
- reject(new AggregatedError_1.AggregatedError(errors, ret));
63
+ reject(new AggregatedError_1.AggregatedError(errors, r));
62
64
  }
63
65
  else {
64
- resolve(ret);
66
+ resolve(r);
65
67
  }
66
68
  }
67
69
  return;
@@ -70,12 +72,16 @@ async function pMap(iterable, mapper, opt = {}) {
70
72
  Promise.resolve(nextItem.value)
71
73
  .then(async (element) => await mapper(element, i))
72
74
  .then(value => {
75
+ if (value === __1.END) {
76
+ isSettled = true;
77
+ return resolve(ret.filter(r => r !== __1.SKIP));
78
+ }
73
79
  ret[i] = value;
74
80
  resolvingCount--;
75
81
  next();
76
82
  }, err => {
77
83
  if (errorMode === __1.ErrorMode.THROW_IMMEDIATELY) {
78
- isRejected = true;
84
+ isSettled = true;
79
85
  reject(err);
80
86
  }
81
87
  else {
@@ -5,4 +5,6 @@ import { PMapOptions } from './pMap';
5
5
  */
6
6
  export declare function pProps<T>(input: {
7
7
  [K in keyof T]: T[K] | Promise<T[K]>;
8
- }, opt?: PMapOptions): Promise<T>;
8
+ }, opt?: PMapOptions): Promise<{
9
+ [K in keyof T]: Awaited<T[K]>;
10
+ }>;
@@ -11,17 +11,16 @@ Improvements:
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.pProps = void 0;
13
13
  const pMap_1 = require("./pMap");
14
+ // todo: remove when eslint starts to know about Awaited
15
+ /* eslint-disable no-undef */
14
16
  /**
15
17
  * Promise.all for Object instead of Array.
16
18
  * Supports concurrency.
17
19
  */
18
20
  async function pProps(input, opt) {
19
- const keys = Object.keys(input);
20
- const values = await (0, pMap_1.pMap)(Object.values(input), r => r, opt);
21
21
  const r = {};
22
- values.forEach((v, i) => {
23
- r[keys[i]] = v;
24
- });
22
+ const keys = Object.keys(input);
23
+ await (0, pMap_1.pMap)(Object.values(input), (v, i) => (r[keys[i]] = v), opt);
25
24
  return r;
26
25
  }
27
26
  exports.pProps = pProps;
@@ -0,0 +1,30 @@
1
+ import { AbortableMapper, AbortablePredicate, END } from '../types';
2
+ /**
3
+ * Inspired by Kotlin Sequences.
4
+ * Similar to arrays, but with lazy evaluation, abortable.
5
+ * Can be useful when it's not feasible/performant to create an array of values to iterate upfront
6
+ * (e.g to construct 1000 Dayjs instances only to find that 2 of them were needed).
7
+ *
8
+ * @experimental
9
+ */
10
+ export declare class Seq<T> implements Iterable<T> {
11
+ private nextFn;
12
+ private constructor();
13
+ [Symbol.iterator](): Iterator<T>;
14
+ static create<T>(initialValue: T | typeof END, nextFn: AbortableMapper<T, T>): Seq<T>;
15
+ static range(minIncl: number, maxExcl: number, step?: number): Seq<number>;
16
+ static from<T>(a: Iterable<T>): Seq<T>;
17
+ static empty<T = any>(): Seq<T>;
18
+ private currentValue;
19
+ private sentInitialValue;
20
+ private i;
21
+ next(): T | typeof END;
22
+ find(predicate: AbortablePredicate<T>): T | undefined;
23
+ some(predicate: AbortablePredicate<T>): boolean;
24
+ every(predicate: AbortablePredicate<T>): boolean;
25
+ toArray(): T[];
26
+ }
27
+ /**
28
+ * Convenience function to create a Sequence.
29
+ */
30
+ export declare function _seq<T>(initialValue: T | typeof END, nextFn: AbortableMapper<T, T>): Seq<T>;
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._seq = exports.Seq = void 0;
4
+ const types_1 = require("../types");
5
+ /**
6
+ * Inspired by Kotlin Sequences.
7
+ * Similar to arrays, but with lazy evaluation, abortable.
8
+ * Can be useful when it's not feasible/performant to create an array of values to iterate upfront
9
+ * (e.g to construct 1000 Dayjs instances only to find that 2 of them were needed).
10
+ *
11
+ * @experimental
12
+ */
13
+ class Seq {
14
+ constructor(initialValue, nextFn) {
15
+ this.nextFn = nextFn;
16
+ this.sentInitialValue = false;
17
+ this.i = -1;
18
+ this.currentValue = initialValue;
19
+ }
20
+ [Symbol.iterator]() {
21
+ return {
22
+ next: () => {
23
+ const value = this.next();
24
+ return value === types_1.END ? { done: true, value: undefined } : { value };
25
+ },
26
+ };
27
+ }
28
+ static create(initialValue, nextFn) {
29
+ return new Seq(initialValue, nextFn);
30
+ }
31
+ static range(minIncl, maxExcl, step = 1) {
32
+ const max = maxExcl - step;
33
+ return new Seq(minIncl, n => (n < max ? n + step : types_1.END));
34
+ }
35
+ static from(a) {
36
+ const it = a[Symbol.iterator]();
37
+ const v = it.next();
38
+ if (v.done)
39
+ return new Seq(types_1.END, () => { });
40
+ return new Seq(v.value, () => {
41
+ const v = it.next();
42
+ if (v.done)
43
+ return types_1.END;
44
+ return v.value;
45
+ });
46
+ }
47
+ static empty() {
48
+ return new Seq(types_1.END, () => { });
49
+ }
50
+ next() {
51
+ if (this.currentValue === types_1.END)
52
+ return types_1.END;
53
+ this.i++;
54
+ let v;
55
+ if (!this.sentInitialValue) {
56
+ this.sentInitialValue = true;
57
+ v = this.currentValue;
58
+ }
59
+ else {
60
+ v = this.nextFn(this.currentValue, this.i);
61
+ }
62
+ // console.log(`_seq`, v)
63
+ if (v === types_1.SKIP)
64
+ return this.next();
65
+ return (this.currentValue = v);
66
+ }
67
+ // Chainable functions - return another (chained) Sequence
68
+ // map<OUT>(mapper: Mapper<T, OUT | typeof SKIP | typeof END>): Seq<OUT> {
69
+ // if (this.currentValue === END) return this as any
70
+ //
71
+ // // Iterate until first valid value, to have as `initialValue` of the new Sequence
72
+ // let v: OUT | typeof SKIP | typeof END
73
+ //
74
+ // while (true) {
75
+ // v = mapper(this.currentValue, ++this.i)
76
+ // if (v === SKIP) continue
77
+ // if (v === END) return this as any
78
+ // }
79
+ //
80
+ // return new Seq<OUT>(v as OUT, (current, i) => {
81
+ // const v = mapper(current, i)
82
+ //
83
+ // })
84
+ // }
85
+ // Final functions - return final value, not a chained sequence
86
+ find(predicate) {
87
+ do {
88
+ const v = this.next();
89
+ if (v === types_1.END)
90
+ return; // not found, end of sequence
91
+ const r = predicate(v, this.i);
92
+ if (r === types_1.END)
93
+ return;
94
+ if (r)
95
+ return v;
96
+ // otherwise proceed
97
+ } while (true); // eslint-disable-line no-constant-condition
98
+ }
99
+ some(predicate) {
100
+ do {
101
+ const v = this.next();
102
+ if (v === types_1.END)
103
+ return false;
104
+ const r = predicate(v, this.i);
105
+ if (r === types_1.END)
106
+ return false;
107
+ if (r)
108
+ return true;
109
+ } while (true); // eslint-disable-line no-constant-condition
110
+ }
111
+ every(predicate) {
112
+ do {
113
+ const v = this.next();
114
+ if (v === types_1.END)
115
+ return true;
116
+ const r = predicate(v, this.i);
117
+ if (r === types_1.END)
118
+ return true;
119
+ if (!r)
120
+ return false;
121
+ } while (true); // eslint-disable-line no-constant-condition
122
+ }
123
+ toArray() {
124
+ const a = [];
125
+ // eslint-disable-next-line no-constant-condition
126
+ while (true) {
127
+ const v = this.next();
128
+ if (v === types_1.END)
129
+ return a;
130
+ a.push(v);
131
+ }
132
+ }
133
+ }
134
+ exports.Seq = Seq;
135
+ /**
136
+ * Convenience function to create a Sequence.
137
+ */
138
+ function _seq(initialValue, nextFn) {
139
+ return Seq.create(initialValue, nextFn);
140
+ }
141
+ exports._seq = _seq;
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._jsonParseIfPossible = void 0;
4
+ // const possibleJsonStartTokens = ['{', '[', '"']
5
+ const DETECT_JSON = /^\s*[{["\-\d]/;
4
6
  /**
5
7
  * Attempts to parse object as JSON.
6
8
  * Returns original object if JSON parse failed (silently).
7
9
  */
8
10
  function _jsonParseIfPossible(obj, reviver) {
9
- if (typeof obj === 'string' && obj) {
11
+ // Optimization: only try to parse if it looks like JSON: starts with a json possible character
12
+ if (typeof obj === 'string' && obj && DETECT_JSON.test(obj)) {
10
13
  try {
11
14
  return JSON.parse(obj, reviver);
12
15
  }
@@ -130,36 +130,6 @@ export declare type Merge<FirstType, SecondType> = Simplify<Merge_<FirstType, Se
130
130
  ```
131
131
  */
132
132
  export declare type Promisable<T> = T | PromiseLike<T>;
133
- /**
134
- Returns the type that is wrapped inside a `Promise` type.
135
- If the type is a nested Promise, it is unwrapped recursively until a non-Promise type is obtained.
136
- If the type is not a `Promise`, the type itself is returned.
137
-
138
- @example
139
- ```
140
- import {PromiseValue} from 'type-fest';
141
-
142
- type AsyncData = Promise<string>;
143
- let asyncData: PromiseValue<AsyncData> = Promise.resolve('ABC');
144
-
145
- type Data = PromiseValue<AsyncData>;
146
- let data: Data = await asyncData;
147
-
148
- // Here's an example that shows how this type reacts to non-Promise types.
149
- type SyncData = PromiseValue<string>;
150
- let syncData: SyncData = getSyncData();
151
-
152
- // Here's an example that shows how this type reacts to recursive Promise types.
153
- type RecursiveAsyncData = Promise<Promise<string> >;
154
- let recursiveAsyncData: PromiseValue<RecursiveAsyncData> = Promise.resolve(Promise.resolve('ABC'));
155
- ```
156
-
157
- @category Utilities
158
- */
159
- export declare type PromiseValue<PromiseType, Otherwise = PromiseType> = PromiseType extends Promise<infer Value> ? {
160
- 0: PromiseValue<Value>;
161
- 1: Value;
162
- }[PromiseType extends Promise<unknown> ? 0 : 1] : Otherwise;
163
133
  /**
164
134
  Extract the keys from a type where the value type of the key extends the given `Condition`.
165
135
  Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Merge } from './typeFest';
1
+ import { Merge, Promisable } from './typeFest';
2
2
  /**
3
3
  * Map from String to String (or <T>).
4
4
  *
@@ -37,6 +37,14 @@ export interface AnyObjectWithId extends AnyObject, ObjectWithId {
37
37
  * Because `Function` type is discouraged by eslint.
38
38
  */
39
39
  export declare type AnyFunction = (...args: any[]) => any;
40
+ /**
41
+ * Symbol to indicate END of Sequence.
42
+ */
43
+ export declare const END: unique symbol;
44
+ /**
45
+ * Symbol to indicate SKIP of item (e.g in AbortableMapper)
46
+ */
47
+ export declare const SKIP: unique symbol;
40
48
  /**
41
49
  * Function which is called for every item in `input`. Expected to return a `Promise` or value.
42
50
  */
@@ -50,6 +58,10 @@ export declare const _passUndefinedMapper: Mapper<any, void>;
50
58
  export declare const _noop: (..._args: any[]) => undefined;
51
59
  export declare type Predicate<T> = (item: T, index: number) => boolean;
52
60
  export declare type AsyncPredicate<T> = (item: T, index: number) => boolean | PromiseLike<boolean>;
61
+ export declare type AbortablePredicate<T> = (item: T, i: number) => boolean | typeof END;
62
+ export declare type AbortableAsyncPredicate<T> = (item: T, i: number) => Promisable<boolean | typeof END>;
63
+ export declare type AbortableMapper<IN = any, OUT = any> = (input: IN, i: number) => OUT | typeof SKIP | typeof END;
64
+ export declare type AbortableAsyncMapper<IN = any, OUT = any> = (input: IN, i: number) => Promisable<OUT | typeof SKIP | typeof END>;
53
65
  export declare const _passthroughPredicate: Predicate<any>;
54
66
  export declare const _passNothingPredicate: Predicate<any>;
55
67
  export interface BatchResult<RES = any, ERR = Error> {
package/dist/types.js CHANGED
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._passNothingPredicate = exports._passthroughPredicate = exports._noop = exports._passUndefinedMapper = exports._passthroughMapper = void 0;
3
+ exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._passNothingPredicate = exports._passthroughPredicate = exports._noop = exports._passUndefinedMapper = exports._passthroughMapper = exports.SKIP = exports.END = void 0;
4
+ /**
5
+ * Symbol to indicate END of Sequence.
6
+ */
7
+ exports.END = Symbol('END');
8
+ /**
9
+ * Symbol to indicate SKIP of item (e.g in AbortableMapper)
10
+ */
11
+ exports.SKIP = Symbol('SKIP');
4
12
  const _passthroughMapper = item => item;
5
13
  exports._passthroughMapper = _passthroughMapper;
6
14
  const _passUndefinedMapper = () => undefined;