@telperion/js-utils 3.7.0 → 3.8.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 (575) hide show
  1. package/.build-manifest.json +966 -0
  2. package/README.md +24 -0
  3. package/array/arrayize.cjs +5 -3
  4. package/array/arrayize.cjs.map +1 -0
  5. package/array/arrayize.d.cts +19 -0
  6. package/array/arrayize.d.ts +3 -1
  7. package/array/arrayize.js +2 -1
  8. package/array/arrayize.js.map +1 -1
  9. package/array/async-map.cjs +5 -3
  10. package/array/async-map.cjs.map +1 -0
  11. package/array/async-map.d.cts +36 -0
  12. package/array/async-map.d.ts +3 -1
  13. package/array/async-map.js +2 -1
  14. package/array/async-map.js.map +1 -1
  15. package/array/compact.cjs +8 -5
  16. package/array/compact.cjs.map +1 -0
  17. package/array/compact.d.cts +30 -0
  18. package/array/compact.d.ts +3 -1
  19. package/array/compact.js +4 -2
  20. package/array/compact.js.map +1 -1
  21. package/array/difference.cjs +5 -3
  22. package/array/difference.cjs.map +1 -0
  23. package/array/difference.d.cts +48 -0
  24. package/array/difference.d.ts +6 -3
  25. package/array/difference.js +2 -1
  26. package/array/difference.js.map +1 -1
  27. package/array/find-by-key.cjs +5 -3
  28. package/array/find-by-key.cjs.map +1 -0
  29. package/array/find-by-key.d.cts +32 -0
  30. package/array/find-by-key.d.ts +3 -1
  31. package/array/find-by-key.js +2 -1
  32. package/array/find-by-key.js.map +1 -1
  33. package/array/gather.cjs +5 -3
  34. package/array/gather.cjs.map +1 -0
  35. package/array/gather.d.cts +50 -0
  36. package/array/gather.d.ts +3 -1
  37. package/array/gather.js +2 -1
  38. package/array/gather.js.map +1 -1
  39. package/array/index.cjs +34 -15
  40. package/array/index.cjs.map +1 -0
  41. package/array/index.d.cts +14 -0
  42. package/array/index.d.ts +14 -12
  43. package/array/index.js +14 -13
  44. package/array/index.js.map +1 -1
  45. package/array/intersection.cjs +5 -3
  46. package/array/intersection.cjs.map +1 -0
  47. package/array/intersection.d.cts +48 -0
  48. package/array/intersection.d.ts +6 -3
  49. package/array/intersection.js +2 -1
  50. package/array/intersection.js.map +1 -1
  51. package/array/limit.cjs +5 -3
  52. package/array/limit.cjs.map +1 -0
  53. package/array/limit.d.cts +31 -0
  54. package/array/limit.d.ts +3 -1
  55. package/array/limit.js +2 -1
  56. package/array/limit.js.map +1 -1
  57. package/array/proto/async-map.cjs +6 -4
  58. package/array/proto/async-map.cjs.map +1 -0
  59. package/array/proto/async-map.d.cts +24 -0
  60. package/array/proto/async-map.d.ts +0 -1
  61. package/array/proto/async-map.js +2 -2
  62. package/array/proto/async-map.js.map +1 -1
  63. package/array/proto/compact.cjs +6 -4
  64. package/array/proto/compact.cjs.map +1 -0
  65. package/array/proto/compact.d.cts +14 -0
  66. package/array/proto/compact.d.ts +0 -1
  67. package/array/proto/compact.js +2 -2
  68. package/array/proto/compact.js.map +1 -1
  69. package/array/proto/difference.cjs +6 -4
  70. package/array/proto/difference.cjs.map +1 -0
  71. package/array/proto/difference.d.cts +28 -0
  72. package/array/proto/difference.d.ts +2 -1
  73. package/array/proto/difference.js +2 -2
  74. package/array/proto/difference.js.map +1 -1
  75. package/array/proto/find-by-key.cjs +6 -4
  76. package/array/proto/find-by-key.cjs.map +1 -0
  77. package/array/proto/find-by-key.d.cts +24 -0
  78. package/array/proto/find-by-key.d.ts +0 -1
  79. package/array/proto/find-by-key.js +2 -2
  80. package/array/proto/find-by-key.js.map +1 -1
  81. package/array/proto/gather.cjs +6 -4
  82. package/array/proto/gather.cjs.map +1 -0
  83. package/array/proto/gather.d.cts +31 -0
  84. package/array/proto/gather.d.ts +0 -1
  85. package/array/proto/gather.js +2 -2
  86. package/array/proto/gather.js.map +1 -1
  87. package/array/proto/intersection.cjs +6 -4
  88. package/array/proto/intersection.cjs.map +1 -0
  89. package/array/proto/intersection.d.cts +28 -0
  90. package/array/proto/intersection.d.ts +2 -1
  91. package/array/proto/intersection.js +2 -2
  92. package/array/proto/intersection.js.map +1 -1
  93. package/array/proto/limit.cjs +6 -4
  94. package/array/proto/limit.cjs.map +1 -0
  95. package/array/proto/limit.d.cts +23 -0
  96. package/array/proto/limit.d.ts +0 -1
  97. package/array/proto/limit.js +2 -2
  98. package/array/proto/limit.js.map +1 -1
  99. package/array/proto/remove.cjs +6 -4
  100. package/array/proto/remove.cjs.map +1 -0
  101. package/array/proto/remove.d.cts +32 -0
  102. package/array/proto/remove.d.ts +3 -3
  103. package/array/proto/remove.js +2 -2
  104. package/array/proto/remove.js.map +1 -1
  105. package/array/proto/replace.cjs +6 -4
  106. package/array/proto/replace.cjs.map +1 -0
  107. package/array/proto/replace.d.cts +73 -0
  108. package/array/proto/replace.d.ts +2 -1
  109. package/array/proto/replace.js +2 -2
  110. package/array/proto/replace.js.map +1 -1
  111. package/array/proto/slice-after.cjs +8 -0
  112. package/array/proto/slice-after.cjs.map +1 -0
  113. package/array/proto/slice-after.d.cts +33 -0
  114. package/array/proto/slice-after.d.ts +33 -0
  115. package/array/proto/slice-after.js +6 -0
  116. package/array/proto/slice-after.js.map +1 -0
  117. package/array/proto/slice-before.cjs +8 -0
  118. package/array/proto/slice-before.cjs.map +1 -0
  119. package/array/proto/slice-before.d.cts +33 -0
  120. package/array/proto/slice-before.d.ts +33 -0
  121. package/array/proto/slice-before.js +6 -0
  122. package/array/proto/slice-before.js.map +1 -0
  123. package/array/proto/uniquify-by-key.cjs +6 -4
  124. package/array/proto/uniquify-by-key.cjs.map +1 -0
  125. package/array/proto/uniquify-by-key.d.cts +23 -0
  126. package/array/proto/uniquify-by-key.d.ts +0 -1
  127. package/array/proto/uniquify-by-key.js +2 -2
  128. package/array/proto/uniquify-by-key.js.map +1 -1
  129. package/array/proto/uniquify.cjs +6 -4
  130. package/array/proto/uniquify.cjs.map +1 -0
  131. package/array/proto/uniquify.d.cts +22 -0
  132. package/array/proto/uniquify.d.ts +0 -1
  133. package/array/proto/uniquify.js +2 -2
  134. package/array/proto/uniquify.js.map +1 -1
  135. package/array/remove.cjs +5 -3
  136. package/array/remove.cjs.map +1 -0
  137. package/array/remove.d.cts +35 -0
  138. package/array/remove.d.ts +3 -1
  139. package/array/remove.js +2 -1
  140. package/array/remove.js.map +1 -1
  141. package/array/replace.cjs +5 -3
  142. package/array/replace.cjs.map +1 -0
  143. package/array/replace.d.cts +142 -0
  144. package/array/replace.d.ts +8 -5
  145. package/array/replace.js +2 -1
  146. package/array/replace.js.map +1 -1
  147. package/array/slice-after.cjs +44 -0
  148. package/array/slice-after.cjs.map +1 -0
  149. package/array/slice-after.d.cts +35 -0
  150. package/array/slice-after.d.ts +35 -0
  151. package/array/slice-after.js +42 -0
  152. package/array/slice-after.js.map +1 -0
  153. package/array/slice-before.cjs +44 -0
  154. package/array/slice-before.cjs.map +1 -0
  155. package/array/slice-before.d.cts +35 -0
  156. package/array/slice-before.d.ts +35 -0
  157. package/array/slice-before.js +42 -0
  158. package/array/slice-before.js.map +1 -0
  159. package/array/static/arrayize.cjs +6 -4
  160. package/array/static/arrayize.cjs.map +1 -0
  161. package/array/static/arrayize.d.cts +7 -0
  162. package/array/static/arrayize.d.ts +2 -1
  163. package/array/static/arrayize.js +2 -2
  164. package/array/static/arrayize.js.map +1 -1
  165. package/array/uniquify-by-key.cjs +5 -3
  166. package/array/uniquify-by-key.cjs.map +1 -0
  167. package/array/uniquify-by-key.d.cts +31 -0
  168. package/array/uniquify-by-key.d.ts +3 -1
  169. package/array/uniquify-by-key.js +2 -1
  170. package/array/uniquify-by-key.js.map +1 -1
  171. package/array/uniquify.cjs +5 -3
  172. package/array/uniquify.cjs.map +1 -0
  173. package/array/uniquify.d.cts +29 -0
  174. package/array/uniquify.d.ts +3 -1
  175. package/array/uniquify.js +2 -1
  176. package/array/uniquify.js.map +1 -1
  177. package/boolean/static/is-falsy.cjs +6 -4
  178. package/boolean/static/is-falsy.cjs.map +1 -0
  179. package/boolean/static/is-falsy.d.cts +24 -0
  180. package/boolean/static/is-falsy.d.ts +2 -1
  181. package/boolean/static/is-falsy.js +2 -2
  182. package/boolean/static/is-falsy.js.map +1 -1
  183. package/boolean/static/is-truthy.cjs +6 -4
  184. package/boolean/static/is-truthy.cjs.map +1 -0
  185. package/boolean/static/is-truthy.d.cts +24 -0
  186. package/boolean/static/is-truthy.d.ts +2 -1
  187. package/boolean/static/is-truthy.js +2 -2
  188. package/boolean/static/is-truthy.js.map +1 -1
  189. package/class/index.cjs +8 -4
  190. package/class/index.cjs.map +1 -0
  191. package/class/index.d.cts +1 -0
  192. package/class/index.d.ts +1 -1
  193. package/class/index.js +1 -2
  194. package/class/index.js.map +1 -1
  195. package/class/mixin.cjs +6 -4
  196. package/class/mixin.cjs.map +1 -0
  197. package/class/mixin.d.cts +51 -0
  198. package/class/mixin.d.ts +3 -2
  199. package/class/mixin.js +3 -2
  200. package/class/mixin.js.map +1 -1
  201. package/compact.cjs +10 -7
  202. package/compact.cjs.map +1 -0
  203. package/compact.d.cts +4 -0
  204. package/compact.d.ts +4 -2
  205. package/compact.js +7 -5
  206. package/compact.js.map +1 -1
  207. package/fesm/js-utils.mjs +1817 -0
  208. package/fesm/js-utils.mjs.map +1 -0
  209. package/function/call.cjs +5 -3
  210. package/function/call.cjs.map +1 -0
  211. package/function/call.d.cts +3 -0
  212. package/function/call.d.ts +3 -1
  213. package/function/call.js +2 -1
  214. package/function/call.js.map +1 -1
  215. package/function/debounce.cjs +19 -16
  216. package/function/debounce.cjs.map +1 -0
  217. package/function/debounce.d.cts +47 -0
  218. package/function/debounce.d.ts +7 -4
  219. package/function/debounce.js +8 -6
  220. package/function/debounce.js.map +1 -1
  221. package/function/defer.cjs +8 -5
  222. package/function/defer.cjs.map +1 -0
  223. package/function/defer.d.cts +28 -0
  224. package/function/defer.d.ts +3 -1
  225. package/function/defer.js +4 -2
  226. package/function/defer.js.map +1 -1
  227. package/function/index.cjs +18 -8
  228. package/function/index.cjs.map +1 -0
  229. package/function/index.d.cts +5 -0
  230. package/function/index.d.ts +5 -5
  231. package/function/index.js +5 -6
  232. package/function/index.js.map +1 -1
  233. package/function/noop.cjs +5 -3
  234. package/function/noop.cjs.map +1 -0
  235. package/function/noop.d.cts +22 -0
  236. package/function/noop.d.ts +3 -1
  237. package/function/noop.js +2 -1
  238. package/function/noop.js.map +1 -1
  239. package/function/of.cjs +8 -5
  240. package/function/of.cjs.map +1 -0
  241. package/function/of.d.cts +33 -0
  242. package/function/of.d.ts +3 -1
  243. package/function/of.js +4 -2
  244. package/function/of.js.map +1 -1
  245. package/function/proto/debounce.cjs +7 -5
  246. package/function/proto/debounce.cjs.map +1 -0
  247. package/function/proto/debounce.d.cts +29 -0
  248. package/function/proto/debounce.d.ts +0 -1
  249. package/function/proto/debounce.js +2 -2
  250. package/function/proto/debounce.js.map +1 -1
  251. package/function/static/call.cjs +6 -4
  252. package/function/static/call.cjs.map +1 -0
  253. package/function/static/call.d.cts +7 -0
  254. package/function/static/call.d.ts +2 -1
  255. package/function/static/call.js +2 -2
  256. package/function/static/call.js.map +1 -1
  257. package/function/static/defer.cjs +6 -4
  258. package/function/static/defer.cjs.map +1 -0
  259. package/function/static/defer.d.cts +24 -0
  260. package/function/static/defer.d.ts +2 -1
  261. package/function/static/defer.js +2 -2
  262. package/function/static/defer.js.map +1 -1
  263. package/function/static/noop.cjs +6 -4
  264. package/function/static/noop.cjs.map +1 -0
  265. package/function/static/noop.d.cts +19 -0
  266. package/function/static/noop.d.ts +2 -1
  267. package/function/static/noop.js +2 -2
  268. package/function/static/noop.js.map +1 -1
  269. package/function/static/of.cjs +6 -4
  270. package/function/static/of.cjs.map +1 -0
  271. package/function/static/of.d.cts +27 -0
  272. package/function/static/of.d.ts +2 -1
  273. package/function/static/of.js +2 -2
  274. package/function/static/of.js.map +1 -1
  275. package/index.cjs +95 -34
  276. package/index.cjs.map +1 -0
  277. package/index.d.cts +44 -0
  278. package/index.d.ts +44 -15
  279. package/index.js +43 -17
  280. package/index.js.map +1 -1
  281. package/is-falsy.cjs +5 -3
  282. package/is-falsy.cjs.map +1 -0
  283. package/is-falsy.d.cts +30 -0
  284. package/is-falsy.d.ts +3 -1
  285. package/is-falsy.js +2 -1
  286. package/is-falsy.js.map +1 -1
  287. package/is-truthy.cjs +5 -3
  288. package/is-truthy.cjs.map +1 -0
  289. package/is-truthy.d.cts +30 -0
  290. package/is-truthy.d.ts +3 -1
  291. package/is-truthy.js +2 -1
  292. package/is-truthy.js.map +1 -1
  293. package/limit.cjs +10 -7
  294. package/limit.cjs.map +1 -0
  295. package/limit.d.cts +4 -0
  296. package/limit.d.ts +4 -2
  297. package/limit.js +7 -5
  298. package/limit.js.map +1 -1
  299. package/map/index.cjs +8 -4
  300. package/map/index.cjs.map +1 -0
  301. package/map/index.d.cts +1 -0
  302. package/map/index.d.ts +1 -1
  303. package/map/index.js +1 -2
  304. package/map/index.js.map +1 -1
  305. package/map/merge.cjs +5 -3
  306. package/map/merge.cjs.map +1 -0
  307. package/map/merge.d.cts +26 -0
  308. package/map/merge.d.ts +3 -1
  309. package/map/merge.js +2 -1
  310. package/map/merge.js.map +1 -1
  311. package/math/index.cjs +8 -4
  312. package/math/index.cjs.map +1 -0
  313. package/math/index.d.cts +1 -0
  314. package/math/index.d.ts +1 -1
  315. package/math/index.js +1 -2
  316. package/math/index.js.map +1 -1
  317. package/math/min-max.cjs +5 -3
  318. package/math/min-max.cjs.map +1 -0
  319. package/math/min-max.d.cts +26 -0
  320. package/math/min-max.d.ts +3 -1
  321. package/math/min-max.js +2 -1
  322. package/math/min-max.js.map +1 -1
  323. package/math/static/min-max.cjs +6 -4
  324. package/math/static/min-max.cjs.map +1 -0
  325. package/math/static/min-max.d.cts +21 -0
  326. package/math/static/min-max.d.ts +2 -1
  327. package/math/static/min-max.js +2 -2
  328. package/math/static/min-max.js.map +1 -1
  329. package/object/clone.cjs +14 -11
  330. package/object/clone.cjs.map +1 -0
  331. package/object/clone.d.cts +164 -0
  332. package/object/clone.d.ts +9 -6
  333. package/object/clone.js +6 -4
  334. package/object/clone.js.map +1 -1
  335. package/object/compact.cjs +5 -3
  336. package/object/compact.cjs.map +1 -0
  337. package/object/compact.d.cts +39 -0
  338. package/object/compact.d.ts +3 -1
  339. package/object/compact.js +2 -1
  340. package/object/compact.js.map +1 -1
  341. package/object/deep-freeze.cjs +5 -3
  342. package/object/deep-freeze.cjs.map +1 -0
  343. package/object/deep-freeze.d.cts +3 -0
  344. package/object/deep-freeze.d.ts +3 -1
  345. package/object/deep-freeze.js +2 -1
  346. package/object/deep-freeze.js.map +1 -1
  347. package/object/deepest.cjs +5 -3
  348. package/object/deepest.cjs.map +1 -0
  349. package/object/deepest.d.cts +50 -0
  350. package/object/deepest.d.ts +5 -2
  351. package/object/deepest.js +2 -1
  352. package/object/deepest.js.map +1 -1
  353. package/object/index.cjs +16 -8
  354. package/object/index.cjs.map +1 -0
  355. package/object/index.d.cts +6 -0
  356. package/object/index.d.ts +6 -5
  357. package/object/index.js +5 -6
  358. package/object/index.js.map +1 -1
  359. package/object/map.cjs +5 -3
  360. package/object/map.cjs.map +1 -0
  361. package/object/map.d.cts +34 -0
  362. package/object/map.d.ts +3 -1
  363. package/object/map.js +2 -1
  364. package/object/map.js.map +1 -1
  365. package/object/static/clone.cjs +6 -4
  366. package/object/static/clone.cjs.map +1 -0
  367. package/object/static/clone.d.cts +44 -0
  368. package/object/static/clone.d.ts +2 -1
  369. package/object/static/clone.js +2 -2
  370. package/object/static/clone.js.map +1 -1
  371. package/object/static/compact.cjs +6 -4
  372. package/object/static/compact.cjs.map +1 -0
  373. package/object/static/compact.d.cts +27 -0
  374. package/object/static/compact.d.ts +2 -1
  375. package/object/static/compact.js +2 -2
  376. package/object/static/compact.js.map +1 -1
  377. package/object/static/deep-freeze.cjs +6 -4
  378. package/object/static/deep-freeze.cjs.map +1 -0
  379. package/object/static/deep-freeze.d.cts +7 -0
  380. package/object/static/deep-freeze.d.ts +2 -1
  381. package/object/static/deep-freeze.js +2 -2
  382. package/object/static/deep-freeze.js.map +1 -1
  383. package/object/static/deepest.cjs +6 -4
  384. package/object/static/deepest.cjs.map +1 -0
  385. package/object/static/deepest.d.cts +34 -0
  386. package/object/static/deepest.d.ts +3 -1
  387. package/object/static/deepest.js +2 -2
  388. package/object/static/deepest.js.map +1 -1
  389. package/object/static/map.cjs +6 -4
  390. package/object/static/map.cjs.map +1 -0
  391. package/object/static/map.d.cts +27 -0
  392. package/object/static/map.d.ts +2 -1
  393. package/object/static/map.js +2 -2
  394. package/object/static/map.js.map +1 -1
  395. package/open-promise.cjs +13 -11
  396. package/open-promise.cjs.map +1 -0
  397. package/open-promise.d.cts +82 -0
  398. package/open-promise.d.ts +5 -3
  399. package/open-promise.js +4 -2
  400. package/open-promise.js.map +1 -1
  401. package/package.json +817 -412
  402. package/promise/chain.cjs +5 -3
  403. package/promise/chain.cjs.map +1 -0
  404. package/promise/chain.d.cts +9 -0
  405. package/promise/chain.d.ts +3 -1
  406. package/promise/chain.js +2 -1
  407. package/promise/chain.js.map +1 -1
  408. package/promise/index.cjs +21 -10
  409. package/promise/index.cjs.map +1 -0
  410. package/promise/index.d.cts +7 -0
  411. package/promise/index.d.ts +7 -7
  412. package/promise/index.js +7 -8
  413. package/promise/index.js.map +1 -1
  414. package/promise/never.cjs +10 -7
  415. package/promise/never.cjs.map +1 -0
  416. package/promise/never.d.cts +36 -0
  417. package/promise/never.d.ts +4 -2
  418. package/promise/never.js +5 -3
  419. package/promise/never.js.map +1 -1
  420. package/promise/promisify.cjs +5 -3
  421. package/promise/promisify.cjs.map +1 -0
  422. package/promise/promisify.d.cts +9 -0
  423. package/promise/promisify.d.ts +3 -1
  424. package/promise/promisify.js +2 -1
  425. package/promise/promisify.js.map +1 -1
  426. package/promise/proto/revert.cjs +6 -4
  427. package/promise/proto/revert.cjs.map +1 -0
  428. package/promise/proto/revert.d.cts +28 -0
  429. package/promise/proto/revert.d.ts +0 -1
  430. package/promise/proto/revert.js +2 -2
  431. package/promise/proto/revert.js.map +1 -1
  432. package/promise/proto/try-catch.cjs +6 -4
  433. package/promise/proto/try-catch.cjs.map +1 -0
  434. package/promise/proto/try-catch.d.cts +29 -0
  435. package/promise/proto/try-catch.d.ts +0 -1
  436. package/promise/proto/try-catch.js +2 -2
  437. package/promise/proto/try-catch.js.map +1 -1
  438. package/promise/revert.cjs +5 -3
  439. package/promise/revert.cjs.map +1 -0
  440. package/promise/revert.d.cts +40 -0
  441. package/promise/revert.d.ts +3 -1
  442. package/promise/revert.js +2 -1
  443. package/promise/revert.js.map +1 -1
  444. package/promise/static/chain.cjs +6 -4
  445. package/promise/static/chain.cjs.map +1 -0
  446. package/promise/static/chain.d.cts +11 -0
  447. package/promise/static/chain.d.ts +2 -1
  448. package/promise/static/chain.js +2 -2
  449. package/promise/static/chain.js.map +1 -1
  450. package/promise/static/never.cjs +7 -5
  451. package/promise/static/never.cjs.map +1 -0
  452. package/promise/static/never.d.cts +40 -0
  453. package/promise/static/never.d.ts +2 -1
  454. package/promise/static/never.js +2 -2
  455. package/promise/static/never.js.map +1 -1
  456. package/promise/static/timeout.cjs +6 -4
  457. package/promise/static/timeout.cjs.map +1 -0
  458. package/promise/static/timeout.d.cts +22 -0
  459. package/promise/static/timeout.d.ts +2 -1
  460. package/promise/static/timeout.js +2 -2
  461. package/promise/static/timeout.js.map +1 -1
  462. package/promise/static/try-one-by-one.cjs +6 -4
  463. package/promise/static/try-one-by-one.cjs.map +1 -0
  464. package/promise/static/try-one-by-one.d.cts +28 -0
  465. package/promise/static/try-one-by-one.d.ts +2 -1
  466. package/promise/static/try-one-by-one.js +2 -2
  467. package/promise/static/try-one-by-one.js.map +1 -1
  468. package/promise/timeout.cjs +13 -11
  469. package/promise/timeout.cjs.map +1 -0
  470. package/promise/timeout.d.cts +112 -0
  471. package/promise/timeout.d.ts +5 -2
  472. package/promise/timeout.js +4 -3
  473. package/promise/timeout.js.map +1 -1
  474. package/promise/try-catch.cjs +5 -3
  475. package/promise/try-catch.cjs.map +1 -0
  476. package/promise/try-catch.d.cts +47 -0
  477. package/promise/try-catch.d.ts +4 -2
  478. package/promise/try-catch.js +2 -1
  479. package/promise/try-catch.js.map +1 -1
  480. package/promise/try-one-by-one.cjs +5 -3
  481. package/promise/try-one-by-one.cjs.map +1 -0
  482. package/promise/try-one-by-one.d.cts +44 -0
  483. package/promise/try-one-by-one.d.ts +3 -1
  484. package/promise/try-one-by-one.js +2 -1
  485. package/promise/try-one-by-one.js.map +1 -1
  486. package/set/proto/difference.cjs +6 -4
  487. package/set/proto/difference.cjs.map +1 -0
  488. package/set/proto/difference.d.cts +27 -0
  489. package/set/proto/difference.d.ts +2 -1
  490. package/set/proto/difference.js +2 -2
  491. package/set/proto/difference.js.map +1 -1
  492. package/set/proto/intersection.cjs +6 -4
  493. package/set/proto/intersection.cjs.map +1 -0
  494. package/set/proto/intersection.d.cts +27 -0
  495. package/set/proto/intersection.d.ts +2 -1
  496. package/set/proto/intersection.js +2 -2
  497. package/set/proto/intersection.js.map +1 -1
  498. package/smart-map.cjs +4 -3
  499. package/smart-map.cjs.map +1 -0
  500. package/smart-map.d.cts +82 -0
  501. package/smart-map.d.ts +3 -2
  502. package/smart-map.js +2 -1
  503. package/smart-map.js.map +1 -1
  504. package/string/index.cjs +8 -4
  505. package/string/index.cjs.map +1 -0
  506. package/string/index.d.cts +1 -0
  507. package/string/index.d.ts +1 -1
  508. package/string/index.js +1 -2
  509. package/string/index.js.map +1 -1
  510. package/string/limit.cjs +8 -5
  511. package/string/limit.cjs.map +1 -0
  512. package/string/limit.d.cts +31 -0
  513. package/string/limit.d.ts +3 -1
  514. package/string/limit.js +5 -3
  515. package/string/limit.js.map +1 -1
  516. package/string/proto/limit.cjs +6 -4
  517. package/string/proto/limit.cjs.map +1 -0
  518. package/string/proto/limit.d.cts +30 -0
  519. package/string/proto/limit.d.ts +3 -3
  520. package/string/proto/limit.js +2 -2
  521. package/string/proto/limit.js.map +1 -1
  522. package/time/days.cjs +8 -5
  523. package/time/days.cjs.map +1 -0
  524. package/time/days.d.cts +17 -0
  525. package/time/days.d.ts +3 -1
  526. package/time/days.js +4 -2
  527. package/time/days.js.map +1 -1
  528. package/time/hours.cjs +8 -5
  529. package/time/hours.cjs.map +1 -0
  530. package/time/hours.d.cts +17 -0
  531. package/time/hours.d.ts +3 -1
  532. package/time/hours.js +4 -2
  533. package/time/hours.js.map +1 -1
  534. package/time/index.cjs +20 -10
  535. package/time/index.cjs.map +1 -0
  536. package/time/index.d.cts +7 -0
  537. package/time/index.d.ts +7 -7
  538. package/time/index.js +7 -8
  539. package/time/index.js.map +1 -1
  540. package/time/minutes.cjs +8 -5
  541. package/time/minutes.cjs.map +1 -0
  542. package/time/minutes.d.cts +17 -0
  543. package/time/minutes.d.ts +3 -1
  544. package/time/minutes.js +4 -2
  545. package/time/minutes.js.map +1 -1
  546. package/time/months.cjs +8 -5
  547. package/time/months.cjs.map +1 -0
  548. package/time/months.d.cts +17 -0
  549. package/time/months.d.ts +3 -1
  550. package/time/months.js +4 -2
  551. package/time/months.js.map +1 -1
  552. package/time/seconds.cjs +5 -3
  553. package/time/seconds.cjs.map +1 -0
  554. package/time/seconds.d.cts +17 -0
  555. package/time/seconds.d.ts +3 -1
  556. package/time/seconds.js +2 -1
  557. package/time/seconds.js.map +1 -1
  558. package/time/weeks.cjs +8 -5
  559. package/time/weeks.cjs.map +1 -0
  560. package/time/weeks.d.cts +17 -0
  561. package/time/weeks.d.ts +3 -1
  562. package/time/weeks.js +4 -2
  563. package/time/weeks.js.map +1 -1
  564. package/time/years.cjs +8 -5
  565. package/time/years.cjs.map +1 -0
  566. package/time/years.d.cts +17 -0
  567. package/time/years.d.ts +3 -1
  568. package/time/years.js +4 -2
  569. package/time/years.js.map +1 -1
  570. package/unique-id.cjs +5 -3
  571. package/unique-id.cjs.map +1 -0
  572. package/unique-id.d.cts +23 -0
  573. package/unique-id.d.ts +4 -2
  574. package/unique-id.js +2 -1
  575. package/unique-id.js.map +1 -1
@@ -0,0 +1,22 @@
1
+ declare global {
2
+ export interface Array<T> {
3
+ /**
4
+ * #### Uniquify
5
+ *
6
+ * Removes repeated items from the array
7
+ *
8
+ * * * *
9
+ * Example:
10
+ * ```typescript
11
+ * import "@telperion/js-utils/array/proto/uniquify";
12
+ *
13
+ * const array = ["a", "b", "c", "a", "b", "c"];
14
+ *
15
+ * array.uniquify(); // ["a", "b", "c"]
16
+ * ```
17
+ * * * *
18
+ * @return The new uniquified array
19
+ */
20
+ uniquify(): T[];
21
+ }
22
+ }
@@ -20,4 +20,3 @@ declare global {
20
20
  uniquify(): T[];
21
21
  }
22
22
  }
23
- export {};
@@ -1,6 +1,6 @@
1
- import { uniquify } from '@telperion/js-utils/array/uniquify';
1
+ import { uniquify } from '../uniquify.js';
2
+
2
3
  Array.prototype.uniquify = function () {
3
4
  return uniquify(this);
4
5
  };
5
-
6
6
  //# sourceMappingURL=uniquify.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../libs/js-utils/src/array/proto/uniquify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAyB9D,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAQ;IAC9B,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC,CAAC","file":"uniquify.js","sourcesContent":["import { uniquify } from '@telperion/js-utils/array/uniquify';\n\ndeclare global {\n export interface Array<T> {\n /**\n * #### Uniquify\n *\n * Removes repeated items from the array\n *\n * * * *\n * Example:\n * ```typescript\n * import \"@telperion/js-utils/array/proto/uniquify\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * array.uniquify(); // [\"a\", \"b\", \"c\"]\n * ```\n * * * *\n * @return The new uniquified array\n */\n uniquify(): T[];\n }\n}\n\nArray.prototype.uniquify = <any>function<T>(this: T[]): T[] {\n return uniquify(this);\n};\n"]}
1
+ {"version":3,"file":"uniquify.js","sources":["../../../../../libs/js-utils/src/array/proto/uniquify.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAyBA,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAQ,YAAA;AAC9B,IAAA,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC"}
package/array/remove.cjs CHANGED
@@ -1,6 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.remove = remove;
1
+ 'use strict';
2
+
4
3
  /**
5
4
  * #### Remove
6
5
  *
@@ -44,3 +43,6 @@ function remove(array, item, multi = false) {
44
43
  } while (multi && index > -1);
45
44
  return array;
46
45
  }
46
+
47
+ exports.remove = remove;
48
+ //# sourceMappingURL=remove.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.cjs","sources":["../../../../libs/js-utils/src/array/remove.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACG,SAAU,MAAM,CAAc,KAAU,EAAE,IAAO,EAAE,KAAK,GAAG,KAAK,EAAA;IACpE,IAAI,KAAK,GAAW,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAEvC,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,QAAA,OAAO,CAAC,GAAG,KAAK,CAAC;IACnB;AAEA,IAAA,GAAG;QACD,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AAC7D,QAAA,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAC7B,IAAA,CAAC,QAAQ,KAAK,IAAI,KAAK,GAAG,EAAE;AAE5B,IAAA,OAAO,KAAK;AACd;;;;"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * #### Remove
3
+ *
4
+ * Removes an item from the array
5
+ *
6
+ * Removes all item references if multi is set to `true`
7
+ *
8
+ * * * *
9
+ * Example:
10
+ * ```typescript
11
+ * import { remove } from "@telperion/js-utils/array";
12
+ *
13
+ * const array = ["a", "b", "c", "a", "b", "c"];
14
+ *
15
+ * remove(array, "b"); // ["a", "c", "a", "b", "c"]
16
+ * remove(array, "b", true); // ["a", "c", "a", "c"]
17
+ * ```
18
+ *
19
+ * Prototype Example:
20
+ * ```typescript
21
+ * import "@telperion/js-utils/array/proto/remove";
22
+ *
23
+ * const array = ["a", "b", "c", "a", "b", "c"];
24
+ *
25
+ * array.remove("b"); // ["a", "c", "a", "b", "c"]
26
+ * array.remove("b", true); // ["a", "c", "a", "c"]
27
+ * ```
28
+ * * * *
29
+ * @param array: Array to remove the item
30
+ * @param itemToRemove Item to remove
31
+ * @return New array
32
+ */
33
+ declare function remove<T = unknown>(array: T[], item: T, multi?: boolean): T[];
34
+
35
+ export { remove };
package/array/remove.d.ts CHANGED
@@ -30,4 +30,6 @@
30
30
  * @param itemToRemove Item to remove
31
31
  * @return New array
32
32
  */
33
- export declare function remove<T = unknown>(array: T[], item: T, multi?: boolean): T[];
33
+ declare function remove<T = unknown>(array: T[], item: T, multi?: boolean): T[];
34
+
35
+ export { remove };
package/array/remove.js CHANGED
@@ -30,7 +30,7 @@
30
30
  * @param itemToRemove Item to remove
31
31
  * @return New array
32
32
  */
33
- export function remove(array, item, multi = false) {
33
+ function remove(array, item, multi = false) {
34
34
  let index = array.indexOf(item);
35
35
  if (index < 0) {
36
36
  return [...array];
@@ -42,4 +42,5 @@ export function remove(array, item, multi = false) {
42
42
  return array;
43
43
  }
44
44
 
45
+ export { remove };
45
46
  //# sourceMappingURL=remove.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../libs/js-utils/src/array/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,MAAM,CAAc,KAAU,EAAE,IAAO,EAAE,KAAK,GAAG,KAAK;IACpE,IAAI,KAAK,GAAW,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,GAAG,CAAC;QACF,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9D,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC,QAAQ,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;IAE9B,OAAO,KAAK,CAAC;AACf,CAAC","file":"remove.js","sourcesContent":["/**\n * #### Remove\n *\n * Removes an item from the array\n *\n * Removes all item references if multi is set to `true`\n *\n * * * *\n * Example:\n * ```typescript\n * import { remove } from \"@telperion/js-utils/array\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * remove(array, \"b\"); // [\"a\", \"c\", \"a\", \"b\", \"c\"]\n * remove(array, \"b\", true); // [\"a\", \"c\", \"a\", \"c\"]\n * ```\n *\n * Prototype Example:\n * ```typescript\n * import \"@telperion/js-utils/array/proto/remove\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * array.remove(\"b\"); // [\"a\", \"c\", \"a\", \"b\", \"c\"]\n * array.remove(\"b\", true); // [\"a\", \"c\", \"a\", \"c\"]\n * ```\n * * * *\n * @param array: Array to remove the item\n * @param itemToRemove Item to remove\n * @return New array\n */\nexport function remove<T = unknown>(array: T[], item: T, multi = false): T[] {\n let index: number = array.indexOf(item);\n\n if (index < 0) {\n return [...array];\n }\n\n do {\n array = [...array.slice(0, index), ...array.slice(index + 1)];\n index = array.indexOf(item);\n } while (multi && index > -1);\n\n return array;\n}\n"]}
1
+ {"version":3,"file":"remove.js","sources":["../../../../libs/js-utils/src/array/remove.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACG,SAAU,MAAM,CAAc,KAAU,EAAE,IAAO,EAAE,KAAK,GAAG,KAAK,EAAA;IACpE,IAAI,KAAK,GAAW,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAEvC,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,QAAA,OAAO,CAAC,GAAG,KAAK,CAAC;IACnB;AAEA,IAAA,GAAG;QACD,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AAC7D,QAAA,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAC7B,IAAA,CAAC,QAAQ,KAAK,IAAI,KAAK,GAAG,EAAE;AAE5B,IAAA,OAAO,KAAK;AACd;;;;"}
package/array/replace.cjs CHANGED
@@ -1,6 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replace = replace;
1
+ 'use strict';
2
+
4
3
  /**
5
4
  * Default Options for Replace Items Mode
6
5
  */
@@ -67,3 +66,6 @@ function _replaceByMap(array, options) {
67
66
  });
68
67
  return newArray;
69
68
  }
69
+
70
+ exports.replace = replace;
71
+ //# sourceMappingURL=replace.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace.cjs","sources":["../../../../libs/js-utils/src/array/replace.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA+CA;;AAEG;AACH,MAAM,6BAA6B,GAAuC;AACxE,IAAA,WAAW,EAAE,CAAC;AACd,IAAA,cAAc,EAAE,EAAE;AAClB,IAAA,aAAa,EAAE;CAChB;AACD;;AAEG;AACH,MAAM,8BAA8B,GAAuC;IACzE,cAAc,EAAE,IAAI,GAAG,EAAE;AACzB,IAAA,KAAK,EAAE;CACR;SAmGe,OAAO,CACrB,KAAU,EACV,OAA4D,EAC5D,aAAiB,EAAA;AAEjB,IAAA,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;AACxB,QAAA,OAAO,GAA2B;AAChC,YAAA,aAAa,EAAE,KAAK,CAAC,OAAO,CAAI,OAAO,CAAC;YACxC,cAAc,EAAE,CAAC,aAAa;SAC/B;IACH;AAEA,IAAA,IAAsD,OAAQ,CAAC,cAAc,YAAY,KAAK,EAAE;AAC9F,QAAA,OAAO,aAAa,CAAC,KAAK,EAA0B,OAAO,CAAC;IAC9D;SAAO;AACL,QAAA,OAAO,aAAa,CAAC,KAAK,EAA0B,OAAO,CAAC;IAC9D;AACF;AAEA;;;;;AAKG;AACH,SAAS,aAAa,CAAI,KAAU,EAAE,OAA+B,EAAA;AACnE,IAAA,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,6BAA6B,EAAE,OAAO,CAAC;AAClJ,IAAA,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC;;AAG3B,IAAA,IAAI,aAAa,GAAG,CAAC,EAAE;AACrB,QAAA,OAAO,QAAQ;IACjB;IAEA,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC;AAE9D,IAAA,OAAO,QAAQ;AACjB;AAEA;;;;;AAKG;AACH,SAAS,aAAa,CAAI,KAAU,EAAE,OAA+B,EAAA;AACnE,IAAA,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,8BAA8B,EAAE,OAAO,CAAC;AAC9H,IAAA,MAAM,eAAe,GAAG,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI;AAC9E,IAAA,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC;IAE3B,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,KAAI;QACpC,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,KAAI;AAC7C,YAAA,MAAM,OAAO,GAAG,IAAI,KAAK,GAAG;YAE5B,IAAI,OAAO,EAAE;gBACX,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC;YAClC;AAEA,YAAA,OAAO,OAAO;AAChB,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,QAAQ;AACjB;;;;"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Replace Items Options Interface
3
+ *
4
+ * @template T typeof the items of the array
5
+ */
6
+ interface ReplaceItemsOptions<T> {
7
+ /**
8
+ * Starting index of the array for replacement operation
9
+ *
10
+ * @default 0
11
+ */
12
+ startingIndex?: number;
13
+ /**
14
+ * Determines how many items will be deleted from the array
15
+ *
16
+ * @default 1
17
+ */
18
+ deleteCount?: number;
19
+ /**
20
+ * Items to replace
21
+ *
22
+ * @default []
23
+ */
24
+ itemsToReplace?: T[];
25
+ }
26
+ /**
27
+ * Replace by Item Matcher Map Options Interface
28
+ *
29
+ * @template T typeof the items of the array
30
+ */
31
+ interface ReplaceByMapOptions<T> {
32
+ /**
33
+ * Items' Matcher Map to replace
34
+ */
35
+ itemsToReplace: Map<T, T>;
36
+ /**
37
+ * Set as `true` to replace all items in the array if matches with the key of the matcher map while iterating
38
+ *
39
+ * @default false
40
+ */
41
+ multi?: boolean;
42
+ }
43
+ /**
44
+ * #### Replace
45
+ *
46
+ * Replaces an item with passed one of an array
47
+ *
48
+ * * * *
49
+ * Example:
50
+ * ```typescript
51
+ * import { replace } from "@telperion/js-utils/array";
52
+ *
53
+ * const array = ["a", "b", "c", "a", "b", "c"];
54
+ *
55
+ * replace(array, "b", "x"); // ["a", "x", "c", "a", "b", "c"]
56
+ * ```
57
+ *
58
+ * Array Prototype Example:
59
+ * ```typescript
60
+ * import "@telperion/js-utils/array/proto/replace";
61
+ *
62
+ * const array = ["a", "b", "c", "a", "b", "c"];
63
+ *
64
+ * array.replace("b", "x"); // ["a", "x", "c", "a", "b", "c"]
65
+ * ```
66
+ * * * *
67
+ * @param array Array to replace its item
68
+ * @param itemToRemove Item to remove
69
+ * @param itemToReplace Item to replace with
70
+ * @template T Typeof array items
71
+ * @return New replaced array
72
+ */
73
+ declare function replace<T>(array: T[], itemToRemove: T, itemToReplace: T): T[];
74
+ /**
75
+ * #### Replace
76
+ *
77
+ * Deletes items and replaces new ones from passed starting index of an array
78
+ *
79
+ * * * *
80
+ * Example:
81
+ * ```typescript
82
+ * import { replace } from "@telperion/js-utils";
83
+ *
84
+ * const array = ["a", "b", "c", "a", "b", "c"];
85
+ *
86
+ * replace(array, {startingIndex: 3, deleteCount: 1, itemsToReplace: ['x', 'y']}); // ["a", "b", "c", "x", "y", "b", "c"];
87
+ * ```
88
+ * Array Prototype Example:
89
+ * ```typescript
90
+ * import "@telperion/js-utils/dist/as-proto/array-replace";
91
+ *
92
+ * const array = ["a", "b", "c", "a", "b", "c"];
93
+ *
94
+ * array.replace({startingIndex: 3, deleteCount: 1, itemsToReplace: ['x', 'y']}); // ["a", "b", "c", "x", "y", "b", "c"];
95
+ * ```
96
+ * * * *
97
+ * @param array Array to replace its item
98
+ * @param replaceOptions Replace options
99
+ * @template T Typeof array items
100
+ * @return New replaced array
101
+ */
102
+ declare function replace<T>(array: T[], replaceOptions: ReplaceItemsOptions<T>): T[];
103
+ /**
104
+ * #### Replace
105
+ *
106
+ * Deletes items and replaces new ones by passed matcher map
107
+ *
108
+ * * * *
109
+ * Example:
110
+ * ```typescript
111
+ * import { replace } from "@telperion/js-utils";
112
+ *
113
+ * const array = ["a", "b", "c", "a", "b", "c"];
114
+ * const map = new Map();
115
+ * map.set("a", "x")
116
+ * map.set("b", "y");
117
+ *
118
+ * replace(array, {itemsToReplace: map}); // ["x", "y", "c", "a", "b", "c"];
119
+ * replace(array, {itemsToReplace: map, multi: true}); // ["x", "y", "c", "x", "y", "c"];
120
+ * ```
121
+ * Array Prototype Example:
122
+ * ```typescript
123
+ * import "@telperion/js-utils/dist/as-proto/array-replace";
124
+ *
125
+ * const array = ["a", "b", "c", "a", "b", "c"];
126
+ * const map = new Map();
127
+ * map.set("a", "x")
128
+ * map.set("b", "y");
129
+ *
130
+ * array.replace({itemsToReplace: map}); // ["x", "y", "c", "a", "b", "c"];
131
+ * array.replace({itemsToReplace: map, multi: true}); // ["x", "y", "c", "x", "y", "c"];
132
+ * ```
133
+ * * * *
134
+ * @param array Array to replace its item
135
+ * @param replaceOptions Replace options
136
+ * @template T Typeof array items
137
+ * @return New replaced array
138
+ */
139
+ declare function replace<T>(array: T[], replaceOptions: ReplaceByMapOptions<T>): T[];
140
+
141
+ export { replace };
142
+ export type { ReplaceByMapOptions, ReplaceItemsOptions };
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @template T typeof the items of the array
5
5
  */
6
- export interface ReplaceItemsOptions<T> {
6
+ interface ReplaceItemsOptions<T> {
7
7
  /**
8
8
  * Starting index of the array for replacement operation
9
9
  *
@@ -28,7 +28,7 @@ export interface ReplaceItemsOptions<T> {
28
28
  *
29
29
  * @template T typeof the items of the array
30
30
  */
31
- export interface ReplaceByMapOptions<T> {
31
+ interface ReplaceByMapOptions<T> {
32
32
  /**
33
33
  * Items' Matcher Map to replace
34
34
  */
@@ -70,7 +70,7 @@ export interface ReplaceByMapOptions<T> {
70
70
  * @template T Typeof array items
71
71
  * @return New replaced array
72
72
  */
73
- export declare function replace<T>(array: T[], itemToRemove: T, itemToReplace: T): T[];
73
+ declare function replace<T>(array: T[], itemToRemove: T, itemToReplace: T): T[];
74
74
  /**
75
75
  * #### Replace
76
76
  *
@@ -99,7 +99,7 @@ export declare function replace<T>(array: T[], itemToRemove: T, itemToReplace: T
99
99
  * @template T Typeof array items
100
100
  * @return New replaced array
101
101
  */
102
- export declare function replace<T>(array: T[], replaceOptions: ReplaceItemsOptions<T>): T[];
102
+ declare function replace<T>(array: T[], replaceOptions: ReplaceItemsOptions<T>): T[];
103
103
  /**
104
104
  * #### Replace
105
105
  *
@@ -136,4 +136,7 @@ export declare function replace<T>(array: T[], replaceOptions: ReplaceItemsOptio
136
136
  * @template T Typeof array items
137
137
  * @return New replaced array
138
138
  */
139
- export declare function replace<T>(array: T[], replaceOptions: ReplaceByMapOptions<T>): T[];
139
+ declare function replace<T>(array: T[], replaceOptions: ReplaceByMapOptions<T>): T[];
140
+
141
+ export { replace };
142
+ export type { ReplaceByMapOptions, ReplaceItemsOptions };
package/array/replace.js CHANGED
@@ -13,7 +13,7 @@ const REPLACE_BY_MAP_DEFAULT_OPTIONS = {
13
13
  itemsToReplace: new Map(),
14
14
  multi: false
15
15
  };
16
- export function replace(array, options, itemToReplace) {
16
+ function replace(array, options, itemToReplace) {
17
17
  if (arguments.length > 2) {
18
18
  options = {
19
19
  startingIndex: array.indexOf(options),
@@ -65,4 +65,5 @@ function _replaceByMap(array, options) {
65
65
  return newArray;
66
66
  }
67
67
 
68
+ export { replace };
68
69
  //# sourceMappingURL=replace.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../libs/js-utils/src/array/replace.ts"],"names":[],"mappings":"AA+CA;;GAEG;AACH,MAAM,6BAA6B,GAAuC;IACxE,WAAW,EAAE,CAAC;IACd,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,CAAC;CACjB,CAAC;AACF;;GAEG;AACH,MAAM,8BAA8B,GAAuC;IACzE,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,KAAK,EAAE,KAAK;CACb,CAAC;AAmGF,MAAM,UAAU,OAAO,CACrB,KAAU,EACV,OAA4D,EAC5D,aAAiB;IAEjB,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,GAA2B;YAChC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAI,OAAO,CAAC;YACxC,cAAc,EAAE,CAAC,aAAa,CAAC;SAChC,CAAC;IACJ,CAAC;IAED,IAAsD,OAAQ,CAAC,cAAc,YAAY,KAAK,EAAE,CAAC;QAC/F,OAAO,aAAa,CAAC,KAAK,EAA0B,OAAO,CAAC,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,OAAO,aAAa,CAAC,KAAK,EAA0B,OAAO,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAI,KAAU,EAAE,OAA+B;IACnE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,6BAA6B,EAAE,OAAO,CAAC,CAAC;IACnJ,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IAE5B,4DAA4D;IAC5D,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC,CAAC;IAE/D,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAI,KAAU,EAAE,OAA+B;IACnE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,8BAA8B,EAAE,OAAO,CAAC,CAAC;IAC/H,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;IAC/E,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IAE5B,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACpC,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC7C,MAAM,OAAO,GAAG,IAAI,KAAK,GAAG,CAAC;YAE7B,IAAI,OAAO,EAAE,CAAC;gBACZ,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;YACnC,CAAC;YAED,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC","file":"replace.js","sourcesContent":["/**\n * Replace Items Options Interface\n *\n * @template T typeof the items of the array\n */\nexport interface ReplaceItemsOptions<T> {\n /**\n * Starting index of the array for replacement operation\n *\n * @default 0\n */\n startingIndex?: number;\n\n /**\n * Determines how many items will be deleted from the array\n *\n * @default 1\n */\n deleteCount?: number;\n\n /**\n * Items to replace\n *\n * @default []\n */\n itemsToReplace?: T[];\n}\n\n/**\n * Replace by Item Matcher Map Options Interface\n *\n * @template T typeof the items of the array\n */\nexport interface ReplaceByMapOptions<T> {\n /**\n * Items' Matcher Map to replace\n */\n itemsToReplace: Map<T, T>;\n\n /**\n * Set as `true` to replace all items in the array if matches with the key of the matcher map while iterating\n *\n * @default false\n */\n multi?: boolean;\n}\n\n/**\n * Default Options for Replace Items Mode\n */\nconst REPLACE_ITEMS_DEFAULT_OPTIONS: Required<ReplaceItemsOptions<any>> = {\n deleteCount: 1,\n itemsToReplace: [],\n startingIndex: 0\n};\n/**\n * Default Options for Replace By Map Mode\n */\nconst REPLACE_BY_MAP_DEFAULT_OPTIONS: Required<ReplaceByMapOptions<any>> = {\n itemsToReplace: new Map(),\n multi: false\n};\n\n/**\n * #### Replace\n *\n * Replaces an item with passed one of an array\n *\n * * * *\n * Example:\n * ```typescript\n * import { replace } from \"@telperion/js-utils/array\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * replace(array, \"b\", \"x\"); // [\"a\", \"x\", \"c\", \"a\", \"b\", \"c\"]\n * ```\n *\n * Array Prototype Example:\n * ```typescript\n * import \"@telperion/js-utils/array/proto/replace\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * array.replace(\"b\", \"x\"); // [\"a\", \"x\", \"c\", \"a\", \"b\", \"c\"]\n * ```\n * * * *\n * @param array Array to replace its item\n * @param itemToRemove Item to remove\n * @param itemToReplace Item to replace with\n * @template T Typeof array items\n * @return New replaced array\n */\nexport function replace<T>(array: T[], itemToRemove: T, itemToReplace: T): T[];\n/**\n * #### Replace\n *\n * Deletes items and replaces new ones from passed starting index of an array\n *\n * * * *\n * Example:\n * ```typescript\n * import { replace } from \"@telperion/js-utils\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * replace(array, {startingIndex: 3, deleteCount: 1, itemsToReplace: ['x', 'y']}); // [\"a\", \"b\", \"c\", \"x\", \"y\", \"b\", \"c\"];\n * ```\n * Array Prototype Example:\n * ```typescript\n * import \"@telperion/js-utils/dist/as-proto/array-replace\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * array.replace({startingIndex: 3, deleteCount: 1, itemsToReplace: ['x', 'y']}); // [\"a\", \"b\", \"c\", \"x\", \"y\", \"b\", \"c\"];\n * ```\n * * * *\n * @param array Array to replace its item\n * @param replaceOptions Replace options\n * @template T Typeof array items\n * @return New replaced array\n */\nexport function replace<T>(array: T[], replaceOptions: ReplaceItemsOptions<T>): T[];\n/**\n * #### Replace\n *\n * Deletes items and replaces new ones by passed matcher map\n *\n * * * *\n * Example:\n * ```typescript\n * import { replace } from \"@telperion/js-utils\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n * const map = new Map();\n * map.set(\"a\", \"x\")\n * map.set(\"b\", \"y\");\n *\n * replace(array, {itemsToReplace: map}); // [\"x\", \"y\", \"c\", \"a\", \"b\", \"c\"];\n * replace(array, {itemsToReplace: map, multi: true}); // [\"x\", \"y\", \"c\", \"x\", \"y\", \"c\"];\n * ```\n * Array Prototype Example:\n * ```typescript\n * import \"@telperion/js-utils/dist/as-proto/array-replace\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n * const map = new Map();\n * map.set(\"a\", \"x\")\n * map.set(\"b\", \"y\");\n *\n * array.replace({itemsToReplace: map}); // [\"x\", \"y\", \"c\", \"a\", \"b\", \"c\"];\n * array.replace({itemsToReplace: map, multi: true}); // [\"x\", \"y\", \"c\", \"x\", \"y\", \"c\"];\n * ```\n * * * *\n * @param array Array to replace its item\n * @param replaceOptions Replace options\n * @template T Typeof array items\n * @return New replaced array\n */\nexport function replace<T>(array: T[], replaceOptions: ReplaceByMapOptions<T>): T[];\nexport function replace<T>(\n array: T[],\n options: T | ReplaceItemsOptions<T> | ReplaceByMapOptions<T>,\n itemToReplace?: T\n): T[] {\n if (arguments.length > 2) {\n options = <ReplaceItemsOptions<T>>{\n startingIndex: array.indexOf(<T>options),\n itemsToReplace: [itemToReplace]\n };\n }\n\n if ((<ReplaceByMapOptions<T> | ReplaceItemsOptions<T>>options).itemsToReplace instanceof Array) {\n return _replaceItems(array, <ReplaceItemsOptions<T>>options);\n } else {\n return _replaceByMap(array, <ReplaceByMapOptions<T>>options);\n }\n}\n\n/**\n * Replace items by 'replace items' mode\n *\n * @param array Array to replace items\n * @param options Replace options\n */\nfunction _replaceItems<T>(array: T[], options: ReplaceItemsOptions<T>): T[] {\n const { startingIndex, deleteCount, itemsToReplace }: Required<ReplaceItemsOptions<T>> = Object.assign({}, REPLACE_ITEMS_DEFAULT_OPTIONS, options);\n const newArray = [...array];\n\n // If item not found or index number is negative; do nothing\n if (startingIndex < 0) {\n return newArray;\n }\n\n newArray.splice(startingIndex, deleteCount, ...itemsToReplace);\n\n return newArray;\n}\n\n/**\n * Replace items by 'replace by map' mode\n *\n * @param array Array to replace items\n * @param options Replace options\n */\nfunction _replaceByMap<T>(array: T[], options: ReplaceByMapOptions<T>): T[] {\n const { itemsToReplace, multi }: Required<ReplaceByMapOptions<T>> = Object.assign({}, REPLACE_BY_MAP_DEFAULT_OPTIONS, options);\n const iterationMethod = multi ? Array.prototype.forEach : Array.prototype.some;\n const newArray = [...array];\n\n itemsToReplace.forEach((value, key) => {\n iterationMethod.call(newArray, (item, index) => {\n const matches = item === key;\n\n if (matches) {\n newArray.splice(index, 1, value);\n }\n\n return matches;\n });\n });\n\n return newArray;\n}\n"]}
1
+ {"version":3,"file":"replace.js","sources":["../../../../libs/js-utils/src/array/replace.ts"],"sourcesContent":[null],"names":[],"mappings":"AA+CA;;AAEG;AACH,MAAM,6BAA6B,GAAuC;AACxE,IAAA,WAAW,EAAE,CAAC;AACd,IAAA,cAAc,EAAE,EAAE;AAClB,IAAA,aAAa,EAAE;CAChB;AACD;;AAEG;AACH,MAAM,8BAA8B,GAAuC;IACzE,cAAc,EAAE,IAAI,GAAG,EAAE;AACzB,IAAA,KAAK,EAAE;CACR;SAmGe,OAAO,CACrB,KAAU,EACV,OAA4D,EAC5D,aAAiB,EAAA;AAEjB,IAAA,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;AACxB,QAAA,OAAO,GAA2B;AAChC,YAAA,aAAa,EAAE,KAAK,CAAC,OAAO,CAAI,OAAO,CAAC;YACxC,cAAc,EAAE,CAAC,aAAa;SAC/B;IACH;AAEA,IAAA,IAAsD,OAAQ,CAAC,cAAc,YAAY,KAAK,EAAE;AAC9F,QAAA,OAAO,aAAa,CAAC,KAAK,EAA0B,OAAO,CAAC;IAC9D;SAAO;AACL,QAAA,OAAO,aAAa,CAAC,KAAK,EAA0B,OAAO,CAAC;IAC9D;AACF;AAEA;;;;;AAKG;AACH,SAAS,aAAa,CAAI,KAAU,EAAE,OAA+B,EAAA;AACnE,IAAA,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,6BAA6B,EAAE,OAAO,CAAC;AAClJ,IAAA,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC;;AAG3B,IAAA,IAAI,aAAa,GAAG,CAAC,EAAE;AACrB,QAAA,OAAO,QAAQ;IACjB;IAEA,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC;AAE9D,IAAA,OAAO,QAAQ;AACjB;AAEA;;;;;AAKG;AACH,SAAS,aAAa,CAAI,KAAU,EAAE,OAA+B,EAAA;AACnE,IAAA,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,8BAA8B,EAAE,OAAO,CAAC;AAC9H,IAAA,MAAM,eAAe,GAAG,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI;AAC9E,IAAA,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC;IAE3B,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,KAAI;QACpC,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,KAAI;AAC7C,YAAA,MAAM,OAAO,GAAG,IAAI,KAAK,GAAG;YAE5B,IAAI,OAAO,EAAE;gBACX,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC;YAClC;AAEA,YAAA,OAAO,OAAO;AAChB,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,QAAQ;AACjB;;;;"}
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * #### Slice After
5
+ *
6
+ * Returns a new array containing the items located after the first occurrence
7
+ * of the given item.
8
+ *
9
+ * If the item is not found, an empty array is returned.
10
+ *
11
+ * * * *
12
+ * Example:
13
+ * ```typescript
14
+ * import { sliceAfter } from "@telperion/js-utils/array";
15
+ *
16
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
17
+ *
18
+ * sliceAfter(fruits, "banana"); // ["melon", "orange"]
19
+ * sliceAfter(fruits, "kiwi"); // []
20
+ * ```
21
+ *
22
+ * Prototype Example:
23
+ * ```typescript
24
+ * import "@telperion/js-utils/array/proto/slice-after";
25
+ *
26
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
27
+ *
28
+ * fruits.sliceAfter("banana"); // ["melon", "orange"]
29
+ * ```
30
+ * * * *
31
+ * @param array Array to slice
32
+ * @param item Item to slice after
33
+ * @return New array containing the items after the given item
34
+ */
35
+ function sliceAfter(array, item) {
36
+ const index = array.indexOf(item);
37
+ if (index < 0) {
38
+ return [];
39
+ }
40
+ return array.slice(index + 1);
41
+ }
42
+
43
+ exports.sliceAfter = sliceAfter;
44
+ //# sourceMappingURL=slice-after.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slice-after.cjs","sources":["../../../../libs/js-utils/src/array/slice-after.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACG,SAAU,UAAU,CAAc,KAAU,EAAE,IAAO,EAAA;IACzD,MAAM,KAAK,GAAW,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAEzC,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,QAAA,OAAO,EAAE;IACX;IAEA,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;AAC/B;;;;"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * #### Slice After
3
+ *
4
+ * Returns a new array containing the items located after the first occurrence
5
+ * of the given item.
6
+ *
7
+ * If the item is not found, an empty array is returned.
8
+ *
9
+ * * * *
10
+ * Example:
11
+ * ```typescript
12
+ * import { sliceAfter } from "@telperion/js-utils/array";
13
+ *
14
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
15
+ *
16
+ * sliceAfter(fruits, "banana"); // ["melon", "orange"]
17
+ * sliceAfter(fruits, "kiwi"); // []
18
+ * ```
19
+ *
20
+ * Prototype Example:
21
+ * ```typescript
22
+ * import "@telperion/js-utils/array/proto/slice-after";
23
+ *
24
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
25
+ *
26
+ * fruits.sliceAfter("banana"); // ["melon", "orange"]
27
+ * ```
28
+ * * * *
29
+ * @param array Array to slice
30
+ * @param item Item to slice after
31
+ * @return New array containing the items after the given item
32
+ */
33
+ declare function sliceAfter<T = unknown>(array: T[], item: T): T[];
34
+
35
+ export { sliceAfter };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * #### Slice After
3
+ *
4
+ * Returns a new array containing the items located after the first occurrence
5
+ * of the given item.
6
+ *
7
+ * If the item is not found, an empty array is returned.
8
+ *
9
+ * * * *
10
+ * Example:
11
+ * ```typescript
12
+ * import { sliceAfter } from "@telperion/js-utils/array";
13
+ *
14
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
15
+ *
16
+ * sliceAfter(fruits, "banana"); // ["melon", "orange"]
17
+ * sliceAfter(fruits, "kiwi"); // []
18
+ * ```
19
+ *
20
+ * Prototype Example:
21
+ * ```typescript
22
+ * import "@telperion/js-utils/array/proto/slice-after";
23
+ *
24
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
25
+ *
26
+ * fruits.sliceAfter("banana"); // ["melon", "orange"]
27
+ * ```
28
+ * * * *
29
+ * @param array Array to slice
30
+ * @param item Item to slice after
31
+ * @return New array containing the items after the given item
32
+ */
33
+ declare function sliceAfter<T = unknown>(array: T[], item: T): T[];
34
+
35
+ export { sliceAfter };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * #### Slice After
3
+ *
4
+ * Returns a new array containing the items located after the first occurrence
5
+ * of the given item.
6
+ *
7
+ * If the item is not found, an empty array is returned.
8
+ *
9
+ * * * *
10
+ * Example:
11
+ * ```typescript
12
+ * import { sliceAfter } from "@telperion/js-utils/array";
13
+ *
14
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
15
+ *
16
+ * sliceAfter(fruits, "banana"); // ["melon", "orange"]
17
+ * sliceAfter(fruits, "kiwi"); // []
18
+ * ```
19
+ *
20
+ * Prototype Example:
21
+ * ```typescript
22
+ * import "@telperion/js-utils/array/proto/slice-after";
23
+ *
24
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
25
+ *
26
+ * fruits.sliceAfter("banana"); // ["melon", "orange"]
27
+ * ```
28
+ * * * *
29
+ * @param array Array to slice
30
+ * @param item Item to slice after
31
+ * @return New array containing the items after the given item
32
+ */
33
+ function sliceAfter(array, item) {
34
+ const index = array.indexOf(item);
35
+ if (index < 0) {
36
+ return [];
37
+ }
38
+ return array.slice(index + 1);
39
+ }
40
+
41
+ export { sliceAfter };
42
+ //# sourceMappingURL=slice-after.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slice-after.js","sources":["../../../../libs/js-utils/src/array/slice-after.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACG,SAAU,UAAU,CAAc,KAAU,EAAE,IAAO,EAAA;IACzD,MAAM,KAAK,GAAW,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAEzC,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,QAAA,OAAO,EAAE;IACX;IAEA,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;AAC/B;;;;"}
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * #### Slice Before
5
+ *
6
+ * Returns a new array containing the items located before the first occurrence
7
+ * of the given item.
8
+ *
9
+ * If the item is not found, an empty array is returned.
10
+ *
11
+ * * * *
12
+ * Example:
13
+ * ```typescript
14
+ * import { sliceBefore } from "@telperion/js-utils/array";
15
+ *
16
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
17
+ *
18
+ * sliceBefore(fruits, "melon"); // ["apple", "grapes", "banana"]
19
+ * sliceBefore(fruits, "kiwi"); // []
20
+ * ```
21
+ *
22
+ * Prototype Example:
23
+ * ```typescript
24
+ * import "@telperion/js-utils/array/proto/slice-before";
25
+ *
26
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
27
+ *
28
+ * fruits.sliceBefore("melon"); // ["apple", "grapes", "banana"]
29
+ * ```
30
+ * * * *
31
+ * @param array Array to slice
32
+ * @param item Item to slice before
33
+ * @return New array containing the items before the given item
34
+ */
35
+ function sliceBefore(array, item) {
36
+ const index = array.indexOf(item);
37
+ if (index < 0) {
38
+ return [];
39
+ }
40
+ return array.slice(0, index);
41
+ }
42
+
43
+ exports.sliceBefore = sliceBefore;
44
+ //# sourceMappingURL=slice-before.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slice-before.cjs","sources":["../../../../libs/js-utils/src/array/slice-before.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACG,SAAU,WAAW,CAAc,KAAU,EAAE,IAAO,EAAA;IAC1D,MAAM,KAAK,GAAW,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAEzC,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,QAAA,OAAO,EAAE;IACX;IAEA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;AAC9B;;;;"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * #### Slice Before
3
+ *
4
+ * Returns a new array containing the items located before the first occurrence
5
+ * of the given item.
6
+ *
7
+ * If the item is not found, an empty array is returned.
8
+ *
9
+ * * * *
10
+ * Example:
11
+ * ```typescript
12
+ * import { sliceBefore } from "@telperion/js-utils/array";
13
+ *
14
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
15
+ *
16
+ * sliceBefore(fruits, "melon"); // ["apple", "grapes", "banana"]
17
+ * sliceBefore(fruits, "kiwi"); // []
18
+ * ```
19
+ *
20
+ * Prototype Example:
21
+ * ```typescript
22
+ * import "@telperion/js-utils/array/proto/slice-before";
23
+ *
24
+ * const fruits = ["apple", "grapes", "banana", "melon", "orange"];
25
+ *
26
+ * fruits.sliceBefore("melon"); // ["apple", "grapes", "banana"]
27
+ * ```
28
+ * * * *
29
+ * @param array Array to slice
30
+ * @param item Item to slice before
31
+ * @return New array containing the items before the given item
32
+ */
33
+ declare function sliceBefore<T = unknown>(array: T[], item: T): T[];
34
+
35
+ export { sliceBefore };