@naturalcycles/js-lib 14.70.0 → 14.72.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.
Files changed (43) hide show
  1. package/dist/error/error.util.js +2 -0
  2. package/dist/error/try.d.ts +1 -1
  3. package/dist/error/try.js +2 -0
  4. package/dist/index.d.ts +28 -26
  5. package/dist/index.js +28 -122
  6. package/dist/math/sma.d.ts +2 -2
  7. package/dist/math/stack.util.d.ts +21 -0
  8. package/dist/math/stack.util.js +36 -0
  9. package/dist/promise/pBatch.d.ts +2 -3
  10. package/dist/promise/pFilter.d.ts +2 -2
  11. package/dist/promise/pMap.d.ts +2 -3
  12. package/dist/promise/pMap.js +13 -7
  13. package/dist/promise/pProps.d.ts +3 -1
  14. package/dist/promise/pProps.js +4 -5
  15. package/dist/seq/seq.d.ts +30 -0
  16. package/dist/seq/seq.js +141 -0
  17. package/dist/string/json.util.js +4 -1
  18. package/dist/typeFest.d.ts +0 -30
  19. package/dist/types.d.ts +13 -1
  20. package/dist/types.js +9 -1
  21. package/dist-esm/error/error.util.js +2 -0
  22. package/dist-esm/error/try.js +2 -0
  23. package/dist-esm/index.js +26 -24
  24. package/dist-esm/math/stack.util.js +32 -0
  25. package/dist-esm/promise/pMap.js +14 -8
  26. package/dist-esm/promise/pProps.js +4 -5
  27. package/dist-esm/seq/seq.js +136 -0
  28. package/dist-esm/string/json.util.js +4 -1
  29. package/dist-esm/types.js +8 -0
  30. package/package.json +1 -1
  31. package/src/error/error.util.ts +2 -0
  32. package/src/error/try.ts +4 -1
  33. package/src/index.ts +36 -195
  34. package/src/math/sma.ts +1 -1
  35. package/src/math/stack.util.ts +35 -0
  36. package/src/promise/pBatch.ts +2 -3
  37. package/src/promise/pFilter.ts +2 -2
  38. package/src/promise/pMap.ts +16 -11
  39. package/src/promise/pProps.ts +6 -7
  40. package/src/seq/seq.ts +143 -0
  41. package/src/string/json.util.ts +5 -1
  42. package/src/typeFest.ts +0 -32
  43. package/src/types.ts +22 -1
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Merge } from './typeFest'
1
+ import { Merge, Promisable } from './typeFest'
2
2
 
3
3
  /**
4
4
  * Map from String to String (or <T>).
@@ -45,6 +45,16 @@ export interface AnyObjectWithId extends AnyObject, ObjectWithId {}
45
45
  */
46
46
  export type AnyFunction = (...args: any[]) => any
47
47
 
48
+ /**
49
+ * Symbol to indicate END of Sequence.
50
+ */
51
+ export const END = Symbol('END')
52
+
53
+ /**
54
+ * Symbol to indicate SKIP of item (e.g in AbortableMapper)
55
+ */
56
+ export const SKIP = Symbol('SKIP')
57
+
48
58
  /**
49
59
  * Function which is called for every item in `input`. Expected to return a `Promise` or value.
50
60
  */
@@ -62,6 +72,17 @@ export const _noop = (..._args: any[]): undefined => undefined
62
72
  export type Predicate<T> = (item: T, index: number) => boolean
63
73
  export type AsyncPredicate<T> = (item: T, index: number) => boolean | PromiseLike<boolean>
64
74
 
75
+ export type AbortablePredicate<T> = (item: T, i: number) => boolean | typeof END
76
+ export type AbortableAsyncPredicate<T> = (item: T, i: number) => Promisable<boolean | typeof END>
77
+ export type AbortableMapper<IN = any, OUT = any> = (
78
+ input: IN,
79
+ i: number,
80
+ ) => OUT | typeof SKIP | typeof END
81
+ export type AbortableAsyncMapper<IN = any, OUT = any> = (
82
+ input: IN,
83
+ i: number,
84
+ ) => Promisable<OUT | typeof SKIP | typeof END>
85
+
65
86
  export const _passthroughPredicate: Predicate<any> = () => true
66
87
  export const _passNothingPredicate: Predicate<any> = () => false
67
88