@telperion/js-utils 3.5.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 (351) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +621 -0
  3. package/array/arrayize.cjs +22 -0
  4. package/array/arrayize.d.ts +17 -0
  5. package/array/arrayize.js +21 -0
  6. package/array/arrayize.js.map +1 -0
  7. package/array/async-map.cjs +40 -0
  8. package/array/async-map.d.ts +34 -0
  9. package/array/async-map.js +39 -0
  10. package/array/async-map.js.map +1 -0
  11. package/array/compact.cjs +34 -0
  12. package/array/compact.d.ts +28 -0
  13. package/array/compact.js +33 -0
  14. package/array/compact.js.map +1 -0
  15. package/array/difference.cjs +16 -0
  16. package/array/difference.d.ts +45 -0
  17. package/array/difference.js +15 -0
  18. package/array/difference.js.map +1 -0
  19. package/array/find-by-key.cjs +35 -0
  20. package/array/find-by-key.d.ts +30 -0
  21. package/array/find-by-key.js +34 -0
  22. package/array/find-by-key.js.map +1 -0
  23. package/array/index.cjs +14 -0
  24. package/array/index.d.ts +11 -0
  25. package/array/index.js +13 -0
  26. package/array/index.js.map +1 -0
  27. package/array/intersection.cjs +16 -0
  28. package/array/intersection.d.ts +45 -0
  29. package/array/intersection.js +15 -0
  30. package/array/intersection.js.map +1 -0
  31. package/array/limit.cjs +37 -0
  32. package/array/limit.d.ts +29 -0
  33. package/array/limit.js +36 -0
  34. package/array/limit.js.map +1 -0
  35. package/array/proto/async-map.cjs +6 -0
  36. package/array/proto/async-map.d.ts +25 -0
  37. package/array/proto/async-map.js +6 -0
  38. package/array/proto/async-map.js.map +1 -0
  39. package/array/proto/compact.cjs +6 -0
  40. package/array/proto/compact.d.ts +15 -0
  41. package/array/proto/compact.js +6 -0
  42. package/array/proto/compact.js.map +1 -0
  43. package/array/proto/difference.cjs +6 -0
  44. package/array/proto/difference.d.ts +27 -0
  45. package/array/proto/difference.js +6 -0
  46. package/array/proto/difference.js.map +1 -0
  47. package/array/proto/find-by-key.cjs +6 -0
  48. package/array/proto/find-by-key.d.ts +25 -0
  49. package/array/proto/find-by-key.js +6 -0
  50. package/array/proto/find-by-key.js.map +1 -0
  51. package/array/proto/intersection.cjs +6 -0
  52. package/array/proto/intersection.d.ts +27 -0
  53. package/array/proto/intersection.js +6 -0
  54. package/array/proto/intersection.js.map +1 -0
  55. package/array/proto/limit.cjs +6 -0
  56. package/array/proto/limit.d.ts +24 -0
  57. package/array/proto/limit.js +6 -0
  58. package/array/proto/limit.js.map +1 -0
  59. package/array/proto/remove.cjs +6 -0
  60. package/array/proto/remove.d.ts +32 -0
  61. package/array/proto/remove.js +6 -0
  62. package/array/proto/remove.js.map +1 -0
  63. package/array/proto/replace.cjs +6 -0
  64. package/array/proto/replace.d.ts +72 -0
  65. package/array/proto/replace.js +6 -0
  66. package/array/proto/replace.js.map +1 -0
  67. package/array/proto/uniquify-by-key.cjs +6 -0
  68. package/array/proto/uniquify-by-key.d.ts +24 -0
  69. package/array/proto/uniquify-by-key.js +6 -0
  70. package/array/proto/uniquify-by-key.js.map +1 -0
  71. package/array/proto/uniquify.cjs +6 -0
  72. package/array/proto/uniquify.d.ts +23 -0
  73. package/array/proto/uniquify.js +6 -0
  74. package/array/proto/uniquify.js.map +1 -0
  75. package/array/remove.cjs +46 -0
  76. package/array/remove.d.ts +33 -0
  77. package/array/remove.js +45 -0
  78. package/array/remove.js.map +1 -0
  79. package/array/replace.cjs +69 -0
  80. package/array/replace.d.ts +139 -0
  81. package/array/replace.js +68 -0
  82. package/array/replace.js.map +1 -0
  83. package/array/static/arrayize.cjs +4 -0
  84. package/array/static/arrayize.d.ts +6 -0
  85. package/array/static/arrayize.js +4 -0
  86. package/array/static/arrayize.js.map +1 -0
  87. package/array/uniquify-by-key.cjs +41 -0
  88. package/array/uniquify-by-key.d.ts +29 -0
  89. package/array/uniquify-by-key.js +40 -0
  90. package/array/uniquify-by-key.js.map +1 -0
  91. package/array/uniquify.cjs +32 -0
  92. package/array/uniquify.d.ts +27 -0
  93. package/array/uniquify.js +31 -0
  94. package/array/uniquify.js.map +1 -0
  95. package/boolean/static/is-falsy.cjs +4 -0
  96. package/boolean/static/is-falsy.d.ts +23 -0
  97. package/boolean/static/is-falsy.js +4 -0
  98. package/boolean/static/is-falsy.js.map +1 -0
  99. package/boolean/static/is-truthy.cjs +4 -0
  100. package/boolean/static/is-truthy.d.ts +23 -0
  101. package/boolean/static/is-truthy.js +4 -0
  102. package/boolean/static/is-truthy.js.map +1 -0
  103. package/class/index.cjs +4 -0
  104. package/class/index.d.ts +1 -0
  105. package/class/index.js +3 -0
  106. package/class/index.js.map +1 -0
  107. package/class/mixin.cjs +60 -0
  108. package/class/mixin.d.ts +50 -0
  109. package/class/mixin.js +59 -0
  110. package/class/mixin.js.map +1 -0
  111. package/compact.cjs +39 -0
  112. package/compact.d.ts +2 -0
  113. package/compact.js +38 -0
  114. package/compact.js.map +1 -0
  115. package/function/call.cjs +6 -0
  116. package/function/call.d.ts +1 -0
  117. package/function/call.js +5 -0
  118. package/function/call.js.map +1 -0
  119. package/function/debounce.cjs +85 -0
  120. package/function/debounce.d.ts +44 -0
  121. package/function/debounce.js +82 -0
  122. package/function/debounce.js.map +1 -0
  123. package/function/defer.cjs +42 -0
  124. package/function/defer.d.ts +26 -0
  125. package/function/defer.js +41 -0
  126. package/function/defer.js.map +1 -0
  127. package/function/index.cjs +8 -0
  128. package/function/index.d.ts +5 -0
  129. package/function/index.js +7 -0
  130. package/function/index.js.map +1 -0
  131. package/function/noop.cjs +23 -0
  132. package/function/noop.d.ts +20 -0
  133. package/function/noop.js +22 -0
  134. package/function/noop.js.map +1 -0
  135. package/function/of.cjs +44 -0
  136. package/function/of.d.ts +31 -0
  137. package/function/of.js +43 -0
  138. package/function/of.js.map +1 -0
  139. package/function/proto/debounce.cjs +6 -0
  140. package/function/proto/debounce.d.ts +30 -0
  141. package/function/proto/debounce.js +6 -0
  142. package/function/proto/debounce.js.map +1 -0
  143. package/function/static/call.cjs +4 -0
  144. package/function/static/call.d.ts +6 -0
  145. package/function/static/call.js +4 -0
  146. package/function/static/call.js.map +1 -0
  147. package/function/static/defer.cjs +4 -0
  148. package/function/static/defer.d.ts +23 -0
  149. package/function/static/defer.js +4 -0
  150. package/function/static/defer.js.map +1 -0
  151. package/function/static/noop.cjs +4 -0
  152. package/function/static/noop.d.ts +18 -0
  153. package/function/static/noop.js +4 -0
  154. package/function/static/noop.js.map +1 -0
  155. package/function/static/of.cjs +4 -0
  156. package/function/static/of.d.ts +26 -0
  157. package/function/static/of.js +4 -0
  158. package/function/static/of.js.map +1 -0
  159. package/index.cjs +31 -0
  160. package/index.d.ts +14 -0
  161. package/index.js +17 -0
  162. package/index.js.map +1 -0
  163. package/is-falsy.cjs +33 -0
  164. package/is-falsy.d.ts +28 -0
  165. package/is-falsy.js +32 -0
  166. package/is-falsy.js.map +1 -0
  167. package/is-truthy.cjs +33 -0
  168. package/is-truthy.d.ts +28 -0
  169. package/is-truthy.js +32 -0
  170. package/is-truthy.js.map +1 -0
  171. package/limit.cjs +34 -0
  172. package/limit.d.ts +2 -0
  173. package/limit.js +33 -0
  174. package/limit.js.map +1 -0
  175. package/map/index.cjs +4 -0
  176. package/map/index.d.ts +1 -0
  177. package/map/index.js +3 -0
  178. package/map/index.js.map +1 -0
  179. package/map/merge.cjs +33 -0
  180. package/map/merge.d.ts +24 -0
  181. package/map/merge.js +32 -0
  182. package/map/merge.js.map +1 -0
  183. package/math/index.cjs +4 -0
  184. package/math/index.d.ts +1 -0
  185. package/math/index.js +3 -0
  186. package/math/index.js.map +1 -0
  187. package/math/min-max.cjs +29 -0
  188. package/math/min-max.d.ts +24 -0
  189. package/math/min-max.js +28 -0
  190. package/math/min-max.js.map +1 -0
  191. package/math/static/min-max.cjs +4 -0
  192. package/math/static/min-max.d.ts +20 -0
  193. package/math/static/min-max.js +4 -0
  194. package/math/static/min-max.js.map +1 -0
  195. package/object/clone.cjs +157 -0
  196. package/object/clone.d.ts +161 -0
  197. package/object/clone.js +156 -0
  198. package/object/clone.js.map +1 -0
  199. package/object/compact.cjs +49 -0
  200. package/object/compact.d.ts +37 -0
  201. package/object/compact.js +48 -0
  202. package/object/compact.js.map +1 -0
  203. package/object/deep-freeze.cjs +16 -0
  204. package/object/deep-freeze.d.ts +1 -0
  205. package/object/deep-freeze.js +15 -0
  206. package/object/deep-freeze.js.map +1 -0
  207. package/object/deepest.cjs +55 -0
  208. package/object/deepest.d.ts +47 -0
  209. package/object/deepest.js +54 -0
  210. package/object/deepest.js.map +1 -0
  211. package/object/index.cjs +7 -0
  212. package/object/index.d.ts +4 -0
  213. package/object/index.js +6 -0
  214. package/object/index.js.map +1 -0
  215. package/object/static/clone.cjs +4 -0
  216. package/object/static/clone.d.ts +43 -0
  217. package/object/static/clone.js +4 -0
  218. package/object/static/clone.js.map +1 -0
  219. package/object/static/compact.cjs +4 -0
  220. package/object/static/compact.d.ts +26 -0
  221. package/object/static/compact.js +4 -0
  222. package/object/static/compact.js.map +1 -0
  223. package/object/static/deep-freeze.cjs +4 -0
  224. package/object/static/deep-freeze.d.ts +6 -0
  225. package/object/static/deep-freeze.js +4 -0
  226. package/object/static/deep-freeze.js.map +1 -0
  227. package/object/static/deepest.cjs +4 -0
  228. package/object/static/deepest.d.ts +32 -0
  229. package/object/static/deepest.js +4 -0
  230. package/object/static/deepest.js.map +1 -0
  231. package/open-promise.cjs +115 -0
  232. package/open-promise.d.ts +80 -0
  233. package/open-promise.js +113 -0
  234. package/open-promise.js.map +1 -0
  235. package/package.json +667 -0
  236. package/promise/chain.cjs +12 -0
  237. package/promise/chain.d.ts +7 -0
  238. package/promise/chain.js +11 -0
  239. package/promise/chain.js.map +1 -0
  240. package/promise/index.cjs +10 -0
  241. package/promise/index.d.ts +7 -0
  242. package/promise/index.js +9 -0
  243. package/promise/index.js.map +1 -0
  244. package/promise/never.cjs +41 -0
  245. package/promise/never.d.ts +34 -0
  246. package/promise/never.js +39 -0
  247. package/promise/never.js.map +1 -0
  248. package/promise/promisify.cjs +12 -0
  249. package/promise/promisify.d.ts +7 -0
  250. package/promise/promisify.js +11 -0
  251. package/promise/promisify.js.map +1 -0
  252. package/promise/proto/revert.cjs +6 -0
  253. package/promise/proto/revert.d.ts +29 -0
  254. package/promise/proto/revert.js +6 -0
  255. package/promise/proto/revert.js.map +1 -0
  256. package/promise/proto/try-catch.cjs +7 -0
  257. package/promise/proto/try-catch.d.ts +30 -0
  258. package/promise/proto/try-catch.js +7 -0
  259. package/promise/proto/try-catch.js.map +1 -0
  260. package/promise/revert.cjs +43 -0
  261. package/promise/revert.d.ts +38 -0
  262. package/promise/revert.js +42 -0
  263. package/promise/revert.js.map +1 -0
  264. package/promise/static/chain.cjs +4 -0
  265. package/promise/static/chain.d.ts +10 -0
  266. package/promise/static/chain.js +4 -0
  267. package/promise/static/chain.js.map +1 -0
  268. package/promise/static/never.cjs +5 -0
  269. package/promise/static/never.d.ts +39 -0
  270. package/promise/static/never.js +5 -0
  271. package/promise/static/never.js.map +1 -0
  272. package/promise/static/timeout.cjs +4 -0
  273. package/promise/static/timeout.d.ts +21 -0
  274. package/promise/static/timeout.js +4 -0
  275. package/promise/static/timeout.js.map +1 -0
  276. package/promise/static/try-one-by-one.cjs +4 -0
  277. package/promise/static/try-one-by-one.d.ts +27 -0
  278. package/promise/static/try-one-by-one.js +4 -0
  279. package/promise/static/try-one-by-one.js.map +1 -0
  280. package/promise/timeout.cjs +104 -0
  281. package/promise/timeout.d.ts +109 -0
  282. package/promise/timeout.js +103 -0
  283. package/promise/timeout.js.map +1 -0
  284. package/promise/try-catch.cjs +12 -0
  285. package/promise/try-catch.d.ts +45 -0
  286. package/promise/try-catch.js +11 -0
  287. package/promise/try-catch.js.map +1 -0
  288. package/promise/try-one-by-one.cjs +59 -0
  289. package/promise/try-one-by-one.d.ts +42 -0
  290. package/promise/try-one-by-one.js +58 -0
  291. package/promise/try-one-by-one.js.map +1 -0
  292. package/set/proto/difference.cjs +6 -0
  293. package/set/proto/difference.d.ts +26 -0
  294. package/set/proto/difference.js +6 -0
  295. package/set/proto/difference.js.map +1 -0
  296. package/set/proto/intersection.cjs +6 -0
  297. package/set/proto/intersection.d.ts +26 -0
  298. package/set/proto/intersection.js +6 -0
  299. package/set/proto/intersection.js.map +1 -0
  300. package/smart-map.cjs +108 -0
  301. package/smart-map.d.ts +81 -0
  302. package/smart-map.js +106 -0
  303. package/smart-map.js.map +1 -0
  304. package/string/index.cjs +4 -0
  305. package/string/index.d.ts +1 -0
  306. package/string/index.js +3 -0
  307. package/string/index.js.map +1 -0
  308. package/string/limit.cjs +35 -0
  309. package/string/limit.d.ts +29 -0
  310. package/string/limit.js +34 -0
  311. package/string/limit.js.map +1 -0
  312. package/string/proto/limit.cjs +6 -0
  313. package/string/proto/limit.d.ts +30 -0
  314. package/string/proto/limit.js +6 -0
  315. package/string/proto/limit.js.map +1 -0
  316. package/time/days.cjs +21 -0
  317. package/time/days.d.ts +15 -0
  318. package/time/days.js +20 -0
  319. package/time/days.js.map +1 -0
  320. package/time/hours.cjs +21 -0
  321. package/time/hours.d.ts +15 -0
  322. package/time/hours.js +20 -0
  323. package/time/hours.js.map +1 -0
  324. package/time/index.cjs +10 -0
  325. package/time/index.d.ts +7 -0
  326. package/time/index.js +9 -0
  327. package/time/index.js.map +1 -0
  328. package/time/minutes.cjs +21 -0
  329. package/time/minutes.d.ts +15 -0
  330. package/time/minutes.js +20 -0
  331. package/time/minutes.js.map +1 -0
  332. package/time/months.cjs +21 -0
  333. package/time/months.d.ts +15 -0
  334. package/time/months.js +20 -0
  335. package/time/months.js.map +1 -0
  336. package/time/seconds.cjs +20 -0
  337. package/time/seconds.d.ts +15 -0
  338. package/time/seconds.js +19 -0
  339. package/time/seconds.js.map +1 -0
  340. package/time/weeks.cjs +21 -0
  341. package/time/weeks.d.ts +15 -0
  342. package/time/weeks.js +20 -0
  343. package/time/weeks.js.map +1 -0
  344. package/time/years.cjs +21 -0
  345. package/time/years.d.ts +15 -0
  346. package/time/years.js +20 -0
  347. package/time/years.js.map +1 -0
  348. package/unique-id.cjs +24 -0
  349. package/unique-id.d.ts +21 -0
  350. package/unique-id.js +23 -0
  351. package/unique-id.js.map +1 -0
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chain = chain;
4
+ /**
5
+ * Chains promises in a sequential order
6
+ *
7
+ * @param promises The promise returning functions array in the order they should be executed
8
+ * @returns A promise that resolves when all the promises in the array are resolved. The promise resolves with the value of the last promise in the array
9
+ */
10
+ function chain(promises) {
11
+ return promises.reduce((promise, next) => promise.then(next), Promise.resolve(null));
12
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Chains promises in a sequential order
3
+ *
4
+ * @param promises The promise returning functions array in the order they should be executed
5
+ * @returns A promise that resolves when all the promises in the array are resolved. The promise resolves with the value of the last promise in the array
6
+ */
7
+ export declare function chain<T>(promises: (() => Promise<T>)[]): Promise<T>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Chains promises in a sequential order
3
+ *
4
+ * @param promises The promise returning functions array in the order they should be executed
5
+ * @returns A promise that resolves when all the promises in the array are resolved. The promise resolves with the value of the last promise in the array
6
+ */
7
+ export function chain(promises) {
8
+ return promises.reduce((promise, next) => promise.then(next), Promise.resolve(null));
9
+ }
10
+
11
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/chain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAI,QAA8B;IACrD,OAAO,QAAQ,CAAC,MAAM,CAAa,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,IAAK,CAAC,CAAC,CAAC;AACpG,CAAC","file":"chain.js","sourcesContent":["/**\n * Chains promises in a sequential order\n *\n * @param promises The promise returning functions array in the order they should be executed\n * @returns A promise that resolves when all the promises in the array are resolved. The promise resolves with the value of the last promise in the array\n */\nexport function chain<T>(promises: (() => Promise<T>)[]): Promise<T> {\n return promises.reduce<Promise<T>>((promise, next) => promise.then(next), Promise.resolve(null!));\n}\n"]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("@telperion/js-utils/promise/chain"), exports);
5
+ tslib_1.__exportStar(require("@telperion/js-utils/promise/never"), exports);
6
+ tslib_1.__exportStar(require("@telperion/js-utils/promise/promisify"), exports);
7
+ tslib_1.__exportStar(require("@telperion/js-utils/promise/revert"), exports);
8
+ tslib_1.__exportStar(require("@telperion/js-utils/promise/try-catch"), exports);
9
+ tslib_1.__exportStar(require("@telperion/js-utils/promise/try-one-by-one"), exports);
10
+ tslib_1.__exportStar(require("@telperion/js-utils/promise/timeout"), exports);
@@ -0,0 +1,7 @@
1
+ export * from '@telperion/js-utils/promise/chain';
2
+ export * from '@telperion/js-utils/promise/never';
3
+ export * from '@telperion/js-utils/promise/promisify';
4
+ export * from '@telperion/js-utils/promise/revert';
5
+ export * from '@telperion/js-utils/promise/try-catch';
6
+ export * from '@telperion/js-utils/promise/try-one-by-one';
7
+ export * from '@telperion/js-utils/promise/timeout';
@@ -0,0 +1,9 @@
1
+ export * from '@telperion/js-utils/promise/chain';
2
+ export * from '@telperion/js-utils/promise/never';
3
+ export * from '@telperion/js-utils/promise/promisify';
4
+ export * from '@telperion/js-utils/promise/revert';
5
+ export * from '@telperion/js-utils/promise/try-catch';
6
+ export * from '@telperion/js-utils/promise/try-one-by-one';
7
+ export * from '@telperion/js-utils/promise/timeout';
8
+
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC","file":"index.js","sourcesContent":["export * from '@telperion/js-utils/promise/chain';\nexport * from '@telperion/js-utils/promise/never';\nexport * from '@telperion/js-utils/promise/promisify';\nexport * from '@telperion/js-utils/promise/revert';\nexport * from '@telperion/js-utils/promise/try-catch';\nexport * from '@telperion/js-utils/promise/try-one-by-one';\nexport * from '@telperion/js-utils/promise/timeout';\n"]}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NEVER = void 0;
4
+ exports.never = never;
5
+ const noop_1 = require("@telperion/js-utils/function/noop");
6
+ /**
7
+ * A promise which never resolves
8
+ *
9
+ * Example:
10
+ * ```typescript
11
+ * import { NEVER } from '@telperion/js-utils/promise';
12
+ *
13
+ * function foo(promise = NEVER) {
14
+ * promise.then(val => {
15
+ * ...
16
+ * });
17
+ * }
18
+ * ```
19
+ */
20
+ exports.NEVER = new Promise(noop_1.noop);
21
+ /**
22
+ * Creates a promise which never resolves
23
+ *
24
+ * Example:
25
+ * ```typescript
26
+ * import { never } from '@telperion/js-utils/promise';
27
+ *
28
+ * function foo(promise) {
29
+ * promise = promise || never();
30
+ *
31
+ * promise.then(val => {
32
+ * ...
33
+ * });
34
+ * }
35
+ * ```
36
+ *
37
+ * @returns the promise which never resolves
38
+ */
39
+ function never() {
40
+ return exports.NEVER;
41
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A promise which never resolves
3
+ *
4
+ * Example:
5
+ * ```typescript
6
+ * import { NEVER } from '@telperion/js-utils/promise';
7
+ *
8
+ * function foo(promise = NEVER) {
9
+ * promise.then(val => {
10
+ * ...
11
+ * });
12
+ * }
13
+ * ```
14
+ */
15
+ export declare const NEVER: Promise<any>;
16
+ /**
17
+ * Creates a promise which never resolves
18
+ *
19
+ * Example:
20
+ * ```typescript
21
+ * import { never } from '@telperion/js-utils/promise';
22
+ *
23
+ * function foo(promise) {
24
+ * promise = promise || never();
25
+ *
26
+ * promise.then(val => {
27
+ * ...
28
+ * });
29
+ * }
30
+ * ```
31
+ *
32
+ * @returns the promise which never resolves
33
+ */
34
+ export declare function never<T = never>(): Promise<T>;
@@ -0,0 +1,39 @@
1
+ import { noop } from '@telperion/js-utils/function/noop';
2
+ /**
3
+ * A promise which never resolves
4
+ *
5
+ * Example:
6
+ * ```typescript
7
+ * import { NEVER } from '@telperion/js-utils/promise';
8
+ *
9
+ * function foo(promise = NEVER) {
10
+ * promise.then(val => {
11
+ * ...
12
+ * });
13
+ * }
14
+ * ```
15
+ */
16
+ export const NEVER = new Promise(noop);
17
+ /**
18
+ * Creates a promise which never resolves
19
+ *
20
+ * Example:
21
+ * ```typescript
22
+ * import { never } from '@telperion/js-utils/promise';
23
+ *
24
+ * function foo(promise) {
25
+ * promise = promise || never();
26
+ *
27
+ * promise.then(val => {
28
+ * ...
29
+ * });
30
+ * }
31
+ * ```
32
+ *
33
+ * @returns the promise which never resolves
34
+ */
35
+ export function never() {
36
+ return NEVER;
37
+ }
38
+
39
+ //# sourceMappingURL=never.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/never.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,OAAO,CAAM,IAAI,CAAC,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,KAAK,CAAC;AACf,CAAC","file":"never.js","sourcesContent":["import { noop } from '@telperion/js-utils/function/noop';\n\n/**\n * A promise which never resolves\n *\n * Example:\n * ```typescript\n * import { NEVER } from '@telperion/js-utils/promise';\n *\n * function foo(promise = NEVER) {\n * promise.then(val => {\n * ...\n * });\n * }\n * ```\n */\nexport const NEVER = new Promise<any>(noop);\n\n/**\n * Creates a promise which never resolves\n *\n * Example:\n * ```typescript\n * import { never } from '@telperion/js-utils/promise';\n *\n * function foo(promise) {\n * promise = promise || never();\n *\n * promise.then(val => {\n * ...\n * });\n * }\n * ```\n *\n * @returns the promise which never resolves\n */\nexport function never<T = never>(): Promise<T> {\n return NEVER;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.promisify = promisify;
4
+ /**
5
+ * Converts a promise or a value to a promise to ensure that the return value is a promise
6
+ *
7
+ * @param promiseOrValue The promise or value to convert to a promise
8
+ * @returns The promise of the given promise or value
9
+ */
10
+ async function promisify(promiseOrValue) {
11
+ return await promiseOrValue;
12
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Converts a promise or a value to a promise to ensure that the return value is a promise
3
+ *
4
+ * @param promiseOrValue The promise or value to convert to a promise
5
+ * @returns The promise of the given promise or value
6
+ */
7
+ export declare function promisify<T>(promiseOrValue: T | Promise<T>): Promise<T>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Converts a promise or a value to a promise to ensure that the return value is a promise
3
+ *
4
+ * @param promiseOrValue The promise or value to convert to a promise
5
+ * @returns The promise of the given promise or value
6
+ */
7
+ export async function promisify(promiseOrValue) {
8
+ return await promiseOrValue;
9
+ }
10
+
11
+ //# sourceMappingURL=promisify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/promisify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,cAA8B;IAC/D,OAAO,MAAM,cAAc,CAAC;AAC9B,CAAC","file":"promisify.js","sourcesContent":["/**\n * Converts a promise or a value to a promise to ensure that the return value is a promise\n *\n * @param promiseOrValue The promise or value to convert to a promise\n * @returns The promise of the given promise or value\n */\nexport async function promisify<T>(promiseOrValue: T | Promise<T>): Promise<T> {\n return await promiseOrValue;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const revert_1 = require("@telperion/js-utils/promise/revert");
4
+ Promise.prototype.revert = function () {
5
+ return (0, revert_1.revert)(this);
6
+ };
@@ -0,0 +1,29 @@
1
+ declare global {
2
+ export interface Promise<T> {
3
+ /**
4
+ * #### Revert Promise
5
+ *
6
+ * Exchanges resolve state with rejection of a promise
7
+ *
8
+ * * * *
9
+ * Example usage:
10
+ * ```typescript
11
+ * import "@telperion/js-utils/dist/as-proto/promise-revert";
12
+ *
13
+ * Promise.reject(new Error('foo'))
14
+ * .revert()
15
+ * .then(err => {
16
+ * console.log("this will be logged", err);
17
+ * })
18
+ * .catch(res => {
19
+ * console.log("this won't be logged", res);
20
+ * });
21
+ * ```
22
+ * * * *
23
+ * @param promise The promise to revert its statements
24
+ * @return the reverted promise
25
+ */
26
+ revert<U = any>(): Promise<U>;
27
+ }
28
+ }
29
+ export {};
@@ -0,0 +1,6 @@
1
+ import { revert } from '@telperion/js-utils/promise/revert';
2
+ Promise.prototype.revert = function () {
3
+ return revert(this);
4
+ };
5
+
6
+ //# sourceMappingURL=revert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/proto/revert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AA+B5D,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG;IACzB,OAAO,MAAM,CAAI,IAAI,CAAC,CAAC;AACzB,CAAC,CAAC","file":"revert.js","sourcesContent":["import { revert } from '@telperion/js-utils/promise/revert';\n\ndeclare global {\n export interface Promise<T> {\n /**\n * #### Revert Promise\n *\n * Exchanges resolve state with rejection of a promise\n *\n * * * *\n * Example usage:\n * ```typescript\n * import \"@telperion/js-utils/dist/as-proto/promise-revert\";\n *\n * Promise.reject(new Error('foo'))\n * .revert()\n * .then(err => {\n * console.log(\"this will be logged\", err);\n * })\n * .catch(res => {\n * console.log(\"this won't be logged\", res);\n * });\n * ```\n * * * *\n * @param promise The promise to revert its statements\n * @return the reverted promise\n */\n revert<U = any>(): Promise<U>;\n }\n}\n\nPromise.prototype.revert = function<T = any>(this: Promise<any>): Promise<T> {\n return revert<T>(this);\n};\n"]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const try_catch_1 = require("@telperion/js-utils/promise/try-catch");
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ Promise.prototype.tryCatch = function (defaultResult) {
6
+ return (0, try_catch_1.tryCatch)(this, defaultResult);
7
+ };
@@ -0,0 +1,30 @@
1
+ declare global {
2
+ export interface Promise<T> {
3
+ /**
4
+ * #### Promise Try Catch
5
+ *
6
+ * Merges result and error in the same callback
7
+ *
8
+ * * * *
9
+ * Example:
10
+ * ```typescript
11
+ * import "@telperion/js-utils/as-proto/promise-try-catch";
12
+ *
13
+ * async function fooFunction() {
14
+ * const [error, result] = await anAsyncCall().tryCatch();
15
+ *
16
+ * if (error) {
17
+ * // handle error
18
+ * }
19
+ *
20
+ * // do stuff
21
+ * }
22
+ *
23
+ * ```
24
+ * * * *
25
+ * @param defaultResult Setting this will put the value into the result field when the promise throws error
26
+ */
27
+ tryCatch<E = unknown>(defaultResult?: T): Promise<[E, T]>;
28
+ }
29
+ }
30
+ export {};
@@ -0,0 +1,7 @@
1
+ import { tryCatch } from '@telperion/js-utils/promise/try-catch';
2
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ Promise.prototype.tryCatch = function (defaultResult) {
4
+ return tryCatch(this, defaultResult);
5
+ };
6
+
7
+ //# sourceMappingURL=try-catch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/proto/try-catch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAgCjE,8DAA8D;AAC9D,OAAO,CAAC,SAAS,CAAC,QAAQ,GAAG,UAA6B,aAAmB;IAC3E,OAAO,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AACvC,CAAC,CAAC","file":"try-catch.js","sourcesContent":["import { tryCatch } from '@telperion/js-utils/promise/try-catch';\n\ndeclare global {\n export interface Promise<T> {\n /**\n * #### Promise Try Catch\n *\n * Merges result and error in the same callback\n *\n * * * *\n * Example:\n * ```typescript\n * import \"@telperion/js-utils/as-proto/promise-try-catch\";\n *\n * async function fooFunction() {\n * const [error, result] = await anAsyncCall().tryCatch();\n *\n * if (error) {\n * // handle error\n * }\n *\n * // do stuff\n * }\n *\n * ```\n * * * *\n * @param defaultResult Setting this will put the value into the result field when the promise throws error\n */\n tryCatch<E = unknown>(defaultResult?: T): Promise<[E, T]>;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nPromise.prototype.tryCatch = function(this: Promise<any>, defaultResult?: any): ReturnType<typeof tryCatch<any, any>> {\n return tryCatch(this, defaultResult);\n};\n"]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.revert = revert;
4
+ /**
5
+ * #### Revert Promise
6
+ * Exchanges resolve state with rejection of a promise
7
+ *
8
+ * * * *
9
+ * Example usage:
10
+ * ```typescript
11
+ * import { revert } from "@telperion/js-utils/promise";
12
+ *
13
+ * const errorPromise = Promise.reject(new Error('foo'));
14
+ *
15
+ * revert(errorPromise)
16
+ * .then(err => {
17
+ * console.log("this will be logged", err);
18
+ * })
19
+ * .catch(res => {
20
+ * console.log("this won't be logged", res);
21
+ * });
22
+ * ```
23
+ *
24
+ * Proto usage example:
25
+ * ```typescript
26
+ * import "@telperion/js-utils/promise/proto/revert";
27
+ *
28
+ * Promise.reject(new Error('foo'))
29
+ * .revert()
30
+ * .then(err => {
31
+ * console.log("this will be logged", err);
32
+ * })
33
+ * .catch(res => {
34
+ * console.log("this won't be logged", res);
35
+ * });
36
+ * ```
37
+ * * * *
38
+ * @param promise The promise to revert its statements
39
+ * @return the reverted promise
40
+ */
41
+ function revert(promise) {
42
+ return promise.then(res => { throw res; }, err => err);
43
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * #### Revert Promise
3
+ * Exchanges resolve state with rejection of a promise
4
+ *
5
+ * * * *
6
+ * Example usage:
7
+ * ```typescript
8
+ * import { revert } from "@telperion/js-utils/promise";
9
+ *
10
+ * const errorPromise = Promise.reject(new Error('foo'));
11
+ *
12
+ * revert(errorPromise)
13
+ * .then(err => {
14
+ * console.log("this will be logged", err);
15
+ * })
16
+ * .catch(res => {
17
+ * console.log("this won't be logged", res);
18
+ * });
19
+ * ```
20
+ *
21
+ * Proto usage example:
22
+ * ```typescript
23
+ * import "@telperion/js-utils/promise/proto/revert";
24
+ *
25
+ * Promise.reject(new Error('foo'))
26
+ * .revert()
27
+ * .then(err => {
28
+ * console.log("this will be logged", err);
29
+ * })
30
+ * .catch(res => {
31
+ * console.log("this won't be logged", res);
32
+ * });
33
+ * ```
34
+ * * * *
35
+ * @param promise The promise to revert its statements
36
+ * @return the reverted promise
37
+ */
38
+ export declare function revert<T = any>(promise: Promise<any>): Promise<T>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * #### Revert Promise
3
+ * Exchanges resolve state with rejection of a promise
4
+ *
5
+ * * * *
6
+ * Example usage:
7
+ * ```typescript
8
+ * import { revert } from "@telperion/js-utils/promise";
9
+ *
10
+ * const errorPromise = Promise.reject(new Error('foo'));
11
+ *
12
+ * revert(errorPromise)
13
+ * .then(err => {
14
+ * console.log("this will be logged", err);
15
+ * })
16
+ * .catch(res => {
17
+ * console.log("this won't be logged", res);
18
+ * });
19
+ * ```
20
+ *
21
+ * Proto usage example:
22
+ * ```typescript
23
+ * import "@telperion/js-utils/promise/proto/revert";
24
+ *
25
+ * Promise.reject(new Error('foo'))
26
+ * .revert()
27
+ * .then(err => {
28
+ * console.log("this will be logged", err);
29
+ * })
30
+ * .catch(res => {
31
+ * console.log("this won't be logged", res);
32
+ * });
33
+ * ```
34
+ * * * *
35
+ * @param promise The promise to revert its statements
36
+ * @return the reverted promise
37
+ */
38
+ export function revert(promise) {
39
+ return promise.then(res => { throw res; }, err => err);
40
+ }
41
+
42
+ //# sourceMappingURL=revert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/revert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,MAAM,CAAU,OAAqB;IACnD,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAE,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AACxD,CAAC","file":"revert.js","sourcesContent":["/**\n * #### Revert Promise\n * Exchanges resolve state with rejection of a promise\n *\n * * * *\n * Example usage:\n * ```typescript\n * import { revert } from \"@telperion/js-utils/promise\";\n *\n * const errorPromise = Promise.reject(new Error('foo'));\n *\n * revert(errorPromise)\n * .then(err => {\n * console.log(\"this will be logged\", err);\n * })\n * .catch(res => {\n * console.log(\"this won't be logged\", res);\n * });\n * ```\n *\n * Proto usage example:\n * ```typescript\n * import \"@telperion/js-utils/promise/proto/revert\";\n *\n * Promise.reject(new Error('foo'))\n * .revert()\n * .then(err => {\n * console.log(\"this will be logged\", err);\n * })\n * .catch(res => {\n * console.log(\"this won't be logged\", res);\n * });\n * ```\n * * * *\n * @param promise The promise to revert its statements\n * @return the reverted promise\n */\nexport function revert<T = any>(promise: Promise<any>): Promise<T> {\n return promise.then(res => {throw res; }, err => err);\n}\n"]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chain_1 = require("@telperion/js-utils/promise/chain");
4
+ Promise.chain = chain_1.chain;
@@ -0,0 +1,10 @@
1
+ import { chain } from "@telperion/js-utils/promise/chain";
2
+ declare global {
3
+ export interface PromiseConstructor {
4
+ /**
5
+ * #### Chain
6
+ * Chains promises in a sequential order
7
+ */
8
+ chain: typeof chain;
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ import { chain } from "@telperion/js-utils/promise/chain";
2
+ Promise.chain = chain;
3
+
4
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/static/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAY1D,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC","file":"chain.js","sourcesContent":["import { chain } from \"@telperion/js-utils/promise/chain\";\n\ndeclare global {\n export interface PromiseConstructor {\n /**\n * #### Chain\n * Chains promises in a sequential order\n */\n chain: typeof chain;\n }\n}\n\nPromise.chain = chain;\n"]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const never_1 = require("@telperion/js-utils/promise/never");
4
+ Promise.never = never_1.never;
5
+ Promise.NEVER = never_1.NEVER;
@@ -0,0 +1,39 @@
1
+ import { never, NEVER } from '@telperion/js-utils/promise/never';
2
+ declare global {
3
+ export interface PromiseConstructor {
4
+ /**
5
+ * Creates a promise which never resolves
6
+ *
7
+ * Example:
8
+ * ```typescript
9
+ * import '@telperion/js-utils/promise/static/never';
10
+ *
11
+ * function foo(promise) {
12
+ * promise = promise || Promise.never();
13
+ *
14
+ * promise.then(val => {
15
+ * ...
16
+ * });
17
+ * }
18
+ * ```
19
+ *
20
+ * @returns the promise which never resolves
21
+ */
22
+ never: typeof never;
23
+ /**
24
+ * A promise which never resolves
25
+ *
26
+ * Example:
27
+ * ```typescript
28
+ * import '@telperion/js-utils/promise/static/never';
29
+ *
30
+ * function foo(promise = Promise.NEVER) {
31
+ * promise.then(val => {
32
+ * ...
33
+ * });
34
+ * }
35
+ * ```
36
+ */
37
+ NEVER: typeof NEVER;
38
+ }
39
+ }
@@ -0,0 +1,5 @@
1
+ import { never, NEVER } from '@telperion/js-utils/promise/never';
2
+ Promise.never = never;
3
+ Promise.NEVER = NEVER;
4
+
5
+ //# sourceMappingURL=never.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/static/never.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AA0CjE,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;AACtB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC","file":"never.js","sourcesContent":["import { never, NEVER } from '@telperion/js-utils/promise/never';\n\ndeclare global {\n export interface PromiseConstructor {\n /**\n * Creates a promise which never resolves\n *\n * Example:\n * ```typescript\n * import '@telperion/js-utils/promise/static/never';\n *\n * function foo(promise) {\n * promise = promise || Promise.never();\n *\n * promise.then(val => {\n * ...\n * });\n * }\n * ```\n *\n * @returns the promise which never resolves\n */\n never: typeof never;\n\n /**\n * A promise which never resolves\n *\n * Example:\n * ```typescript\n * import '@telperion/js-utils/promise/static/never';\n *\n * function foo(promise = Promise.NEVER) {\n * promise.then(val => {\n * ...\n * });\n * }\n * ```\n */\n NEVER: typeof NEVER;\n }\n}\n\nPromise.never = never;\nPromise.NEVER = NEVER;\n"]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const timeout_1 = require("@telperion/js-utils/promise/timeout");
4
+ Promise.timeout = timeout_1.timeout;
@@ -0,0 +1,21 @@
1
+ import { PromiseTimeoutFunction } from '@telperion/js-utils/promise/timeout';
2
+ declare global {
3
+ export interface PromiseConstructor {
4
+ /**
5
+ * #### Promise Timeout
6
+ * Returns a promise which resolves after given time
7
+ *
8
+ * * * *
9
+ * Example:
10
+ * ```typescript
11
+ * import "@telperion/js-utils/promise/static/timeout";
12
+ *
13
+ * Promise.timeout(1000);
14
+ * .then(() => console.log("will be logged after a second"));
15
+ * ```
16
+ * * * *
17
+ * @see PromiseTimeoutFunction#cancel for cancelling
18
+ */
19
+ timeout: PromiseTimeoutFunction;
20
+ }
21
+ }
@@ -0,0 +1,4 @@
1
+ import { timeout } from '@telperion/js-utils/promise/timeout';
2
+ Promise.timeout = timeout;
3
+
4
+ //# sourceMappingURL=timeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/static/timeout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA0B,MAAM,qCAAqC,CAAC;AAuBtF,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC","file":"timeout.js","sourcesContent":["import { timeout, PromiseTimeoutFunction } from '@telperion/js-utils/promise/timeout';\n\ndeclare global {\n export interface PromiseConstructor {\n /**\n * #### Promise Timeout\n * Returns a promise which resolves after given time\n *\n * * * *\n * Example:\n * ```typescript\n * import \"@telperion/js-utils/promise/static/timeout\";\n *\n * Promise.timeout(1000);\n * .then(() => console.log(\"will be logged after a second\"));\n * ```\n * * * *\n * @see PromiseTimeoutFunction#cancel for cancelling\n */\n timeout: PromiseTimeoutFunction;\n }\n}\n\nPromise.timeout = timeout;\n"]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const try_one_by_one_1 = require("@telperion/js-utils/promise/try-one-by-one");
4
+ Promise.tryOneByOne = try_one_by_one_1.tryOneByOne;
@@ -0,0 +1,27 @@
1
+ import { tryOneByOne } from '@telperion/js-utils/promise/try-one-by-one';
2
+ declare global {
3
+ export interface PromiseConstructor {
4
+ /**
5
+ * #### Try One By One
6
+ * Tries a set of promises one by one with given order. Breaks the call when a promise resolved. Otherwise keeps trying incoming promises until the list is finished.
7
+ *
8
+ * * * *
9
+ * Example:
10
+ * ```typescript
11
+ * import "@telperion/js-utils/promise/static/try-one-by-one";
12
+ *
13
+ * async function fooFunction() {
14
+ * const foo = await Promise.tryOneByOne([
15
+ * () => someCall(),
16
+ * (err) => anotherCall(),
17
+ * (err) => fooPromise()
18
+ * ]);
19
+ *
20
+ * // do stuff
21
+ * }
22
+ * ```
23
+ * * * *
24
+ */
25
+ tryOneByOne: typeof tryOneByOne;
26
+ }
27
+ }
@@ -0,0 +1,4 @@
1
+ import { tryOneByOne } from '@telperion/js-utils/promise/try-one-by-one';
2
+ Promise.tryOneByOne = tryOneByOne;
3
+
4
+ //# sourceMappingURL=try-one-by-one.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../libs/js-utils/src/promise/static/try-one-by-one.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AA6BzE,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC","file":"try-one-by-one.js","sourcesContent":["import { tryOneByOne } from '@telperion/js-utils/promise/try-one-by-one';\n\ndeclare global {\n export interface PromiseConstructor {\n /**\n * #### Try One By One\n * Tries a set of promises one by one with given order. Breaks the call when a promise resolved. Otherwise keeps trying incoming promises until the list is finished.\n *\n * * * *\n * Example:\n * ```typescript\n * import \"@telperion/js-utils/promise/static/try-one-by-one\";\n *\n * async function fooFunction() {\n * const foo = await Promise.tryOneByOne([\n * () => someCall(),\n * (err) => anotherCall(),\n * (err) => fooPromise()\n * ]);\n *\n * // do stuff\n * }\n * ```\n * * * *\n */\n tryOneByOne: typeof tryOneByOne;\n }\n}\n\nPromise.tryOneByOne = tryOneByOne;\n"]}