@asd14/m 7.4.0 → 7.7.0-next.1

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 (380) hide show
  1. package/README.md +38 -28
  2. package/dist/all/all.js +15 -21
  3. package/dist/all/all.js.map +1 -1
  4. package/dist/all/all.test.js +58 -36
  5. package/dist/all/all.test.js.map +1 -1
  6. package/dist/any/any.js +16 -22
  7. package/dist/any/any.js.map +1 -1
  8. package/dist/any/any.test.js +54 -33
  9. package/dist/any/any.test.js.map +1 -1
  10. package/dist/append/append.js +9 -11
  11. package/dist/append/append.js.map +1 -1
  12. package/dist/append/append.test.js +37 -7
  13. package/dist/append/append.test.js.map +1 -1
  14. package/dist/bottom/bottom.js +23 -29
  15. package/dist/bottom/bottom.js.map +1 -1
  16. package/dist/bottom/bottom.test.js +53 -13
  17. package/dist/bottom/bottom.test.js.map +1 -1
  18. package/dist/cases/cases.js +5 -13
  19. package/dist/cases/cases.js.map +1 -1
  20. package/dist/cases/cases.test.js +67 -35
  21. package/dist/cases/cases.test.js.map +1 -1
  22. package/dist/clone/clone.js +21 -30
  23. package/dist/clone/clone.js.map +1 -1
  24. package/dist/clone/clone.test.js +38 -37
  25. package/dist/clone/clone.test.js.map +1 -1
  26. package/dist/compact/compact.js +39 -39
  27. package/dist/compact/compact.js.map +1 -1
  28. package/dist/compact/compact.test.js +83 -43
  29. package/dist/compact/compact.test.js.map +1 -1
  30. package/dist/contains/contains.js +6 -10
  31. package/dist/contains/contains.js.map +1 -1
  32. package/dist/contains/contains.test.js +7 -6
  33. package/dist/contains/contains.test.js.map +1 -1
  34. package/dist/converge/converge.js +34 -37
  35. package/dist/converge/converge.js.map +1 -1
  36. package/dist/converge/converge.test.js +62 -25
  37. package/dist/converge/converge.test.js.map +1 -1
  38. package/dist/count/count.js +36 -51
  39. package/dist/count/count.js.map +1 -1
  40. package/dist/count/count.test.js +97 -67
  41. package/dist/count/count.test.js.map +1 -1
  42. package/dist/curry/curry.js +20 -18
  43. package/dist/curry/curry.js.map +1 -1
  44. package/dist/curry/curry.test.js +8 -9
  45. package/dist/curry/curry.test.js.map +1 -1
  46. package/dist/debounce/debounce.js +15 -19
  47. package/dist/debounce/debounce.js.map +1 -1
  48. package/dist/debounce/debounce.test.js +43 -46
  49. package/dist/debounce/debounce.test.js.map +1 -1
  50. package/dist/dec/dec.js +3 -3
  51. package/dist/dec/dec.js.map +1 -1
  52. package/dist/dec/dec.test.js +4 -3
  53. package/dist/dec/dec.test.js.map +1 -1
  54. package/dist/deep-equal/deep-equal.bench.js +100 -64
  55. package/dist/deep-equal/deep-equal.bench.js.map +1 -1
  56. package/dist/deep-equal/deep-equal.js +14 -16
  57. package/dist/deep-equal/deep-equal.js.map +1 -1
  58. package/dist/deep-equal/deep-equal.own.js +57 -78
  59. package/dist/deep-equal/deep-equal.own.js.map +1 -1
  60. package/dist/deep-equal/deep-equal.test.js +127 -82
  61. package/dist/deep-equal/deep-equal.test.js.map +1 -1
  62. package/dist/distinct/distinct.bench.js +46 -31
  63. package/dist/distinct/distinct.bench.js.map +1 -1
  64. package/dist/distinct/distinct.js +15 -24
  65. package/dist/distinct/distinct.js.map +1 -1
  66. package/dist/distinct/distinct.test.js +37 -14
  67. package/dist/distinct/distinct.test.js.map +1 -1
  68. package/dist/drop-last/drop-last.js +8 -12
  69. package/dist/drop-last/drop-last.js.map +1 -1
  70. package/dist/drop-last/drop-last.test.js +34 -8
  71. package/dist/drop-last/drop-last.test.js.map +1 -1
  72. package/dist/elapsed-time/elapsed-time.js +17 -18
  73. package/dist/elapsed-time/elapsed-time.js.map +1 -1
  74. package/dist/elapsed-time/elapsed-time.test.js +9 -8
  75. package/dist/elapsed-time/elapsed-time.test.js.map +1 -1
  76. package/dist/ends-with/ends-with.js +10 -16
  77. package/dist/ends-with/ends-with.js.map +1 -1
  78. package/dist/ends-with/ends-with.test.js +8 -7
  79. package/dist/ends-with/ends-with.test.js.map +1 -1
  80. package/dist/escape/escape.js +3 -4
  81. package/dist/escape/escape.js.map +1 -1
  82. package/dist/escape-html/escape-html.js +12 -11
  83. package/dist/escape-html/escape-html.js.map +1 -1
  84. package/dist/escape-html/escape-html.test.js +6 -5
  85. package/dist/escape-html/escape-html.test.js.map +1 -1
  86. package/dist/escape-reg-exp/escape-reg-exp.js +1 -2
  87. package/dist/escape-reg-exp/escape-reg-exp.js.map +1 -1
  88. package/dist/escape-reg-exp/escape-reg-exp.test.js +9 -8
  89. package/dist/escape-reg-exp/escape-reg-exp.test.js.map +1 -1
  90. package/dist/filter/filter.js +16 -21
  91. package/dist/filter/filter.js.map +1 -1
  92. package/dist/filter/filter.test.js +94 -57
  93. package/dist/filter/filter.test.js.map +1 -1
  94. package/dist/find/find.js +38 -50
  95. package/dist/find/find.js.map +1 -1
  96. package/dist/find/find.test.js +73 -64
  97. package/dist/find/find.test.js.map +1 -1
  98. package/dist/find-index/find-index.js +16 -20
  99. package/dist/find-index/find-index.js.map +1 -1
  100. package/dist/find-index/find-index.test.js +48 -38
  101. package/dist/find-index/find-index.test.js.map +1 -1
  102. package/dist/first/first.js +3 -3
  103. package/dist/first/first.js.map +1 -1
  104. package/dist/first/first.test.js +13 -8
  105. package/dist/first/first.test.js.map +1 -1
  106. package/dist/flatten/flatten.js +19 -34
  107. package/dist/flatten/flatten.js.map +1 -1
  108. package/dist/flatten/flatten.test.js +59 -24
  109. package/dist/flatten/flatten.test.js.map +1 -1
  110. package/dist/for-each/for-each.js +10 -12
  111. package/dist/for-each/for-each.js.map +1 -1
  112. package/dist/for-each/for-each.test.js +36 -16
  113. package/dist/for-each/for-each.test.js.map +1 -1
  114. package/dist/group-by/group-by.js +13 -17
  115. package/dist/group-by/group-by.js.map +1 -1
  116. package/dist/group-by/group-by.test.js +83 -49
  117. package/dist/group-by/group-by.test.js.map +1 -1
  118. package/dist/gt/gt.js +3 -6
  119. package/dist/gt/gt.js.map +1 -1
  120. package/dist/gt/gt.test.js +7 -6
  121. package/dist/gt/gt.test.js.map +1 -1
  122. package/dist/has-key/has-key.js +3 -4
  123. package/dist/has-key/has-key.js.map +1 -1
  124. package/dist/has-key/has-key.test.js +10 -9
  125. package/dist/has-key/has-key.test.js.map +1 -1
  126. package/dist/hist/hist.js +22 -34
  127. package/dist/hist/hist.js.map +1 -1
  128. package/dist/hist/hist.test.js +43 -28
  129. package/dist/hist/hist.test.js.map +1 -1
  130. package/dist/i/i.js +3 -3
  131. package/dist/i/i.js.map +1 -1
  132. package/dist/i/i.test.js +17 -12
  133. package/dist/i/i.test.js.map +1 -1
  134. package/dist/inc/inc.js +3 -3
  135. package/dist/inc/inc.js.map +1 -1
  136. package/dist/inc/inc.test.js +4 -3
  137. package/dist/inc/inc.test.js.map +1 -1
  138. package/dist/index-by/index-by.js +12 -17
  139. package/dist/index-by/index-by.js.map +1 -1
  140. package/dist/index-by/index-by.test.js +44 -36
  141. package/dist/index-by/index-by.test.js.map +1 -1
  142. package/dist/index.js +13 -12
  143. package/dist/index.js.map +1 -1
  144. package/dist/index.test.js +7 -7
  145. package/dist/index.test.js.map +1 -1
  146. package/dist/intersect/intersect.js +41 -54
  147. package/dist/intersect/intersect.js.map +1 -1
  148. package/dist/intersect/intersect.test.js +74 -38
  149. package/dist/intersect/intersect.test.js.map +1 -1
  150. package/dist/is/is.js +13 -20
  151. package/dist/is/is.js.map +1 -1
  152. package/dist/is/is.test.js +25 -25
  153. package/dist/is/is.test.js.map +1 -1
  154. package/dist/is-between/is-between.js +9 -13
  155. package/dist/is-between/is-between.js.map +1 -1
  156. package/dist/is-between/is-between.test.js +14 -13
  157. package/dist/is-between/is-between.test.js.map +1 -1
  158. package/dist/is-empty/is-empty.js +23 -44
  159. package/dist/is-empty/is-empty.js.map +1 -1
  160. package/dist/is-empty/is-empty.test.js +31 -27
  161. package/dist/is-empty/is-empty.test.js.map +1 -1
  162. package/dist/is-equal/is-equal.js +3 -6
  163. package/dist/is-equal/is-equal.js.map +1 -1
  164. package/dist/is-equal/is-equal.test.js +19 -15
  165. package/dist/is-equal/is-equal.test.js.map +1 -1
  166. package/dist/is-match/is-match.js +16 -25
  167. package/dist/is-match/is-match.js.map +1 -1
  168. package/dist/is-match/is-match.test.js +67 -64
  169. package/dist/is-match/is-match.test.js.map +1 -1
  170. package/dist/is-uri/is-uri.js +3 -4
  171. package/dist/is-uri/is-uri.js.map +1 -1
  172. package/dist/is-uri/is-uri.test.js +13 -13
  173. package/dist/is-uri/is-uri.test.js.map +1 -1
  174. package/dist/join/join.js +42 -53
  175. package/dist/join/join.js.map +1 -1
  176. package/dist/join/join.test.js +94 -40
  177. package/dist/join/join.test.js.map +1 -1
  178. package/dist/keys/keys.js +34 -24
  179. package/dist/keys/keys.js.map +1 -1
  180. package/dist/keys/keys.test.js +21 -9
  181. package/dist/keys/keys.test.js.map +1 -1
  182. package/dist/last/last.js +3 -4
  183. package/dist/last/last.js.map +1 -1
  184. package/dist/last/last.test.js +14 -7
  185. package/dist/last/last.test.js.map +1 -1
  186. package/dist/lt/lt.js +3 -4
  187. package/dist/lt/lt.js.map +1 -1
  188. package/dist/lt/lt.test.js +6 -5
  189. package/dist/lt/lt.test.js.map +1 -1
  190. package/dist/map/map.js +12 -15
  191. package/dist/map/map.js.map +1 -1
  192. package/dist/map/map.test.js +61 -21
  193. package/dist/map/map.test.js.map +1 -1
  194. package/dist/map-matrix/map-matrix.js +12 -19
  195. package/dist/map-matrix/map-matrix.js.map +1 -1
  196. package/dist/map-matrix/map-matrix.test.js +76 -16
  197. package/dist/map-matrix/map-matrix.test.js.map +1 -1
  198. package/dist/max/max.js +27 -39
  199. package/dist/max/max.js.map +1 -1
  200. package/dist/max/max.test.js +43 -23
  201. package/dist/max/max.test.js.map +1 -1
  202. package/dist/merge/merge.js +53 -63
  203. package/dist/merge/merge.js.map +1 -1
  204. package/dist/merge/merge.test.js +57 -49
  205. package/dist/merge/merge.test.js.map +1 -1
  206. package/dist/min/min.js +27 -39
  207. package/dist/min/min.js.map +1 -1
  208. package/dist/min/min.test.js +38 -22
  209. package/dist/min/min.test.js.map +1 -1
  210. package/dist/move/move.js +23 -37
  211. package/dist/move/move.js.map +1 -1
  212. package/dist/move/move.test.js +58 -15
  213. package/dist/move/move.test.js.map +1 -1
  214. package/dist/mutate/mutate.js +76 -84
  215. package/dist/mutate/mutate.js.map +1 -1
  216. package/dist/mutate/mutate.test.js +107 -89
  217. package/dist/mutate/mutate.test.js.map +1 -1
  218. package/dist/page/page.js +7 -14
  219. package/dist/page/page.js.map +1 -1
  220. package/dist/page/page.test.js +66 -15
  221. package/dist/page/page.test.js.map +1 -1
  222. package/dist/partition/partition.js +20 -26
  223. package/dist/partition/partition.js.map +1 -1
  224. package/dist/partition/partition.test.js +96 -35
  225. package/dist/partition/partition.test.js.map +1 -1
  226. package/dist/pick/pick.js +20 -26
  227. package/dist/pick/pick.js.map +1 -1
  228. package/dist/pick/pick.test.js +22 -12
  229. package/dist/pick/pick.test.js.map +1 -1
  230. package/dist/pipe/pipe.js +15 -14
  231. package/dist/pipe/pipe.js.map +1 -1
  232. package/dist/pipe/pipe.test.js +9 -11
  233. package/dist/pipe/pipe.test.js.map +1 -1
  234. package/dist/pipe-p/pipe-p.js +18 -21
  235. package/dist/pipe-p/pipe-p.js.map +1 -1
  236. package/dist/pipe-p/pipe-p.test.js +21 -24
  237. package/dist/pipe-p/pipe-p.test.js.map +1 -1
  238. package/dist/pluck/pluck.js +27 -38
  239. package/dist/pluck/pluck.js.map +1 -1
  240. package/dist/pluck/pluck.test.js +57 -37
  241. package/dist/pluck/pluck.test.js.map +1 -1
  242. package/dist/prepend/prepend.js +9 -11
  243. package/dist/prepend/prepend.js.map +1 -1
  244. package/dist/prepend/prepend.test.js +37 -7
  245. package/dist/prepend/prepend.test.js.map +1 -1
  246. package/dist/proto-chain/proto-chain.js +8 -8
  247. package/dist/proto-chain/proto-chain.js.map +1 -1
  248. package/dist/proto-chain/proto-chain.test.js +21 -20
  249. package/dist/proto-chain/proto-chain.test.js.map +1 -1
  250. package/dist/push/push.js +9 -12
  251. package/dist/push/push.js.map +1 -1
  252. package/dist/push/push.test.js +19 -8
  253. package/dist/push/push.test.js.map +1 -1
  254. package/dist/raise/raise.js +3 -3
  255. package/dist/raise/raise.js.map +1 -1
  256. package/dist/raise/raise.test.js +6 -5
  257. package/dist/raise/raise.test.js.map +1 -1
  258. package/dist/random/random.js +4 -5
  259. package/dist/random/random.js.map +1 -1
  260. package/dist/random/random.test.js +11 -12
  261. package/dist/random/random.test.js.map +1 -1
  262. package/dist/read/read.js +41 -48
  263. package/dist/read/read.js.map +1 -1
  264. package/dist/read/read.test.js +106 -60
  265. package/dist/read/read.test.js.map +1 -1
  266. package/dist/reduce/reduce.js +24 -29
  267. package/dist/reduce/reduce.js.map +1 -1
  268. package/dist/reduce/reduce.test.js +43 -32
  269. package/dist/reduce/reduce.test.js.map +1 -1
  270. package/dist/remove/remove.js +39 -50
  271. package/dist/remove/remove.js.map +1 -1
  272. package/dist/remove/remove.test.js +92 -54
  273. package/dist/remove/remove.test.js.map +1 -1
  274. package/dist/rename/rename.js +40 -63
  275. package/dist/rename/rename.js.map +1 -1
  276. package/dist/rename/rename.test.js +45 -39
  277. package/dist/rename/rename.test.js.map +1 -1
  278. package/dist/rename-file/rename-file.js +6 -11
  279. package/dist/rename-file/rename-file.js.map +1 -1
  280. package/dist/rename-file/rename-file.test.js +9 -8
  281. package/dist/rename-file/rename-file.test.js.map +1 -1
  282. package/dist/repeat/repeat.js +23 -30
  283. package/dist/repeat/repeat.js.map +1 -1
  284. package/dist/repeat/repeat.test.js +28 -11
  285. package/dist/repeat/repeat.test.js.map +1 -1
  286. package/dist/replace/replace.js +29 -42
  287. package/dist/replace/replace.js.map +1 -1
  288. package/dist/replace/replace.test.js +127 -82
  289. package/dist/replace/replace.test.js.map +1 -1
  290. package/dist/same/same.js +5 -5
  291. package/dist/same/same.js.map +1 -1
  292. package/dist/same/same.test.js +5 -4
  293. package/dist/same/same.test.js.map +1 -1
  294. package/dist/sequence/sequence.js +31 -40
  295. package/dist/sequence/sequence.js.map +1 -1
  296. package/dist/sequence/sequence.test.js +132 -80
  297. package/dist/sequence/sequence.test.js.map +1 -1
  298. package/dist/sort/sort-with.js +90 -98
  299. package/dist/sort/sort-with.js.map +1 -1
  300. package/dist/sort/sort.js +24 -32
  301. package/dist/sort/sort.js.map +1 -1
  302. package/dist/sort/sort.test.js +407 -294
  303. package/dist/sort/sort.test.js.map +1 -1
  304. package/dist/split/split.js +22 -29
  305. package/dist/split/split.js.map +1 -1
  306. package/dist/split/split.test.js +29 -12
  307. package/dist/split/split.test.js.map +1 -1
  308. package/dist/split-in-groups-of/split-in-groups-of.js +29 -38
  309. package/dist/split-in-groups-of/split-in-groups-of.js.map +1 -1
  310. package/dist/split-in-groups-of/split-in-groups-of.test.js +84 -15
  311. package/dist/split-in-groups-of/split-in-groups-of.test.js.map +1 -1
  312. package/dist/spy/spy.js +19 -22
  313. package/dist/spy/spy.js.map +1 -1
  314. package/dist/spy/spy.test.js +32 -28
  315. package/dist/spy/spy.test.js.map +1 -1
  316. package/dist/starts-with/starts-with.js +7 -12
  317. package/dist/starts-with/starts-with.js.map +1 -1
  318. package/dist/starts-with/starts-with.test.js +12 -8
  319. package/dist/starts-with/starts-with.test.js.map +1 -1
  320. package/dist/throttle/throttle.js +24 -31
  321. package/dist/throttle/throttle.js.map +1 -1
  322. package/dist/throttle/throttle.test.js +35 -37
  323. package/dist/throttle/throttle.test.js.map +1 -1
  324. package/dist/to-lower/to-lower.js +3 -3
  325. package/dist/to-lower/to-lower.js.map +1 -1
  326. package/dist/to-lower/to-lower.test.js +5 -4
  327. package/dist/to-lower/to-lower.test.js.map +1 -1
  328. package/dist/to-upper/to-upper.js +3 -3
  329. package/dist/to-upper/to-upper.js.map +1 -1
  330. package/dist/to-upper/to-upper.test.js +5 -4
  331. package/dist/to-upper/to-upper.test.js.map +1 -1
  332. package/dist/toggle/toggle.js +9 -11
  333. package/dist/toggle/toggle.js.map +1 -1
  334. package/dist/toggle/toggle.test.js +24 -5
  335. package/dist/toggle/toggle.test.js.map +1 -1
  336. package/dist/top/top.js +23 -35
  337. package/dist/top/top.js.map +1 -1
  338. package/dist/top/top.test.js +47 -13
  339. package/dist/top/top.test.js.map +1 -1
  340. package/dist/trim/trim.js +19 -26
  341. package/dist/trim/trim.js.map +1 -1
  342. package/dist/trim/trim.test.js +6 -5
  343. package/dist/trim/trim.test.js.map +1 -1
  344. package/dist/try-catch/try-catch.js +15 -14
  345. package/dist/try-catch/try-catch.js.map +1 -1
  346. package/dist/try-catch/try-catch.test.js +9 -8
  347. package/dist/try-catch/try-catch.test.js.map +1 -1
  348. package/dist/type/type.js +3 -4
  349. package/dist/type/type.js.map +1 -1
  350. package/dist/type/type.test.js +16 -16
  351. package/dist/type/type.test.js.map +1 -1
  352. package/dist/unite/unite.js +3 -6
  353. package/dist/unite/unite.js.map +1 -1
  354. package/dist/unite/unite.test.js +8 -3
  355. package/dist/unite/unite.test.js.map +1 -1
  356. package/dist/update/update.js +74 -81
  357. package/dist/update/update.js.map +1 -1
  358. package/dist/update/update.test.js +92 -79
  359. package/dist/update/update.test.js.map +1 -1
  360. package/dist/upsert/upsert.js +14 -18
  361. package/dist/upsert/upsert.js.map +1 -1
  362. package/dist/upsert/upsert.test.js +57 -42
  363. package/dist/upsert/upsert.test.js.map +1 -1
  364. package/dist/values/values.js +38 -29
  365. package/dist/values/values.js.map +1 -1
  366. package/dist/values/values.test.js +21 -9
  367. package/dist/values/values.test.js.map +1 -1
  368. package/dist/when/when.js +27 -37
  369. package/dist/when/when.js.map +1 -1
  370. package/dist/when/when.test.js +23 -15
  371. package/dist/when/when.test.js.map +1 -1
  372. package/dist/write/write.js +6 -12
  373. package/dist/write/write.js.map +1 -1
  374. package/dist/write/write.test.js +14 -13
  375. package/dist/write/write.test.js.map +1 -1
  376. package/dist/zip-to-object/zip-to-object.js +8 -11
  377. package/dist/zip-to-object/zip-to-object.js.map +1 -1
  378. package/dist/zip-to-object/zip-to-object.test.js +29 -12
  379. package/dist/zip-to-object/zip-to-object.test.js.map +1 -1
  380. package/package.json +47 -38
@@ -1,11 +1,10 @@
1
+ import * as swcHelpers from "@swc/helpers";
1
2
  import { is } from "../is/is.js";
2
-
3
- var _bottom = function _bottom(limit, input) {
4
- if (!Array.isArray(input) && typeof input !== "string" || input.length <= 1) {
5
- return [];
6
- }
7
-
8
- return input.slice(is(limit) ? limit >= input.length ? 0 : input.length - limit : 1);
3
+ var _bottom = function(limit, input) {
4
+ if (!Array.isArray(input) && typeof input !== "string" || input.length === 0) {
5
+ return [];
6
+ }
7
+ return input.slice(is(limit) ? limit >= input.length ? 0 : input.length - limit : 1);
9
8
  };
10
9
  /**
11
10
  * Get all but first element from array
@@ -32,27 +31,22 @@ var _bottom = function _bottom(limit, input) {
32
31
  *
33
32
  * bottom(2)([1, 2, 3])
34
33
  * // => [2, 3]
35
- */
36
-
37
-
38
- export var bottom = function bottom() {
39
- for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
40
- params[_key] = arguments[_key];
41
- }
42
-
43
- // @signature (limit: Integer) => (source: Array): Array
44
- if (params.length === 1 && typeof params[0] === "number") {
45
- return function (input) {
46
- return _bottom(params[0], input);
47
- };
48
- } // @signature (source: Array): Array
49
-
50
-
51
- if (params.length === 1 && typeof params[0] !== "number") {
52
- return _bottom(undefined, params[0]);
53
- } // @signature (limit: integer, source: Array): Array
54
-
55
-
56
- return _bottom.apply(void 0, params);
34
+ */ export var bottom = function() {
35
+ for(var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++){
36
+ params[_key] = arguments[_key];
37
+ }
38
+ // @signature (limit: Integer) => (source: Array): Array
39
+ if (params.length === 1 && typeof params[0] === "number") {
40
+ return function(input) {
41
+ return _bottom(params[0], input);
42
+ };
43
+ }
44
+ // @signature (source: Array): Array
45
+ if (params.length === 1 && typeof params[0] !== "number") {
46
+ return _bottom(undefined, params[0]);
47
+ }
48
+ // @signature (limit: integer, source: Array): Array
49
+ return _bottom.apply(void 0, swcHelpers.toConsumableArray(params));
57
50
  };
51
+
58
52
  //# sourceMappingURL=bottom.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bottom/bottom.js"],"names":["is","_bottom","limit","input","Array","isArray","length","slice","bottom","params","undefined"],"mappings":"AAAA,SAASA,EAAT,QAAmB,aAAnB;;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAQC,KAAR,EAAkB;AAChC,MACG,CAACC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAD,IAAyB,OAAOA,KAAP,KAAiB,QAA3C,IACAA,KAAK,CAACG,MAAN,IAAgB,CAFlB,EAGE;AACA,WAAO,EAAP;AACD;;AAED,SAAOH,KAAK,CAACI,KAAN,CACLP,EAAE,CAACE,KAAD,CAAF,GAAaA,KAAK,IAAIC,KAAK,CAACG,MAAf,GAAwB,CAAxB,GAA4BH,KAAK,CAACG,MAAN,GAAeJ,KAAxD,GAAiE,CAD5D,CAAP;AAGD,CAXD;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAMM,MAAM,GAAG,SAATA,MAAS,GAAe;AAAA,oCAAXC,MAAW;AAAXA,IAAAA,MAAW;AAAA;;AACnC;AACA,MAAIA,MAAM,CAACH,MAAP,KAAkB,CAAlB,IAAuB,OAAOG,MAAM,CAAC,CAAD,CAAb,KAAqB,QAAhD,EAA0D;AACxD,WAAO,UAAAN,KAAK;AAAA,aAAIF,OAAO,CAACQ,MAAM,CAAC,CAAD,CAAP,EAAYN,KAAZ,CAAX;AAAA,KAAZ;AACD,GAJkC,CAMnC;;;AACA,MAAIM,MAAM,CAACH,MAAP,KAAkB,CAAlB,IAAuB,OAAOG,MAAM,CAAC,CAAD,CAAb,KAAqB,QAAhD,EAA0D;AACxD,WAAOR,OAAO,CAACS,SAAD,EAAYD,MAAM,CAAC,CAAD,CAAlB,CAAd;AACD,GATkC,CAWnC;;;AACA,SAAOR,OAAO,MAAP,SAAWQ,MAAX,CAAP;AACD,CAbM","sourcesContent":["import { is } from \"../is/is.js\"\n\nconst _bottom = (limit, input) => {\n if (\n (!Array.isArray(input) && typeof input !== \"string\") ||\n input.length <= 1\n ) {\n return []\n }\n\n return input.slice(\n is(limit) ? (limit >= input.length ? 0 : input.length - limit) : 1\n )\n}\n\n/**\n * Get all but first element from array\n *\n * @param {number} limit How many elements from the bottom\n * @param {Array} source The source\n * @param {...any} params\n *\n * @returns {any}\n *\n * @tag Array\n * @signature (limit: integer, source: Array): Array\n * @signature (source: Array): Array\n *\n * @example\n * bottom([1, 2, 3])\n * // => [1, 2]\n *\n * bottom([1]), bottom([])\n * // => []\n *\n * bottom(2, [2, 3])\n * // => [2, 3]\n *\n * bottom(2)([1, 2, 3])\n * // => [2, 3]\n */\nexport const bottom = (...params) => {\n // @signature (limit: Integer) => (source: Array): Array\n if (params.length === 1 && typeof params[0] === \"number\") {\n return input => _bottom(params[0], input)\n }\n\n // @signature (source: Array): Array\n if (params.length === 1 && typeof params[0] !== \"number\") {\n return _bottom(undefined, params[0])\n }\n\n // @signature (limit: integer, source: Array): Array\n return _bottom(...params)\n}\n"],"file":"bottom.js"}
1
+ {"version":3,"sources":["../../src/bottom/bottom.js"],"sourcesContent":["import { is } from \"../is/is.js\"\n\nconst _bottom = (limit, input) => {\n if (\n (!Array.isArray(input) && typeof input !== \"string\") ||\n input.length === 0\n ) {\n return []\n }\n\n return input.slice(\n is(limit) ? (limit >= input.length ? 0 : input.length - limit) : 1\n )\n}\n\n/**\n * Get all but first element from array\n *\n * @param {number} limit How many elements from the bottom\n * @param {Array} source The source\n * @param {...any} params\n *\n * @returns {any}\n *\n * @tag Array\n * @signature (limit: integer, source: Array): Array\n * @signature (source: Array): Array\n *\n * @example\n * bottom([1, 2, 3])\n * // => [1, 2]\n *\n * bottom([1]), bottom([])\n * // => []\n *\n * bottom(2, [2, 3])\n * // => [2, 3]\n *\n * bottom(2)([1, 2, 3])\n * // => [2, 3]\n */\nexport const bottom = (...params) => {\n // @signature (limit: Integer) => (source: Array): Array\n if (params.length === 1 && typeof params[0] === \"number\") {\n return input => _bottom(params[0], input)\n }\n\n // @signature (source: Array): Array\n if (params.length === 1 && typeof params[0] !== \"number\") {\n return _bottom(undefined, params[0])\n }\n\n // @signature (limit: integer, source: Array): Array\n return _bottom(...params)\n}\n"],"names":["is","_bottom","input","limit","Array","isArray","length","slice","bottom","params","undefined"],"mappings":";AAAA,MAAM,GAAGA,EAAE,QAAQ,CAAa;AAEhC,GAAK,CAACC,OAAO,GAAG,QAAQC,CAAPC,KAAK,EAAED,KAAK,EAAK,CAAC;IACjC,EAAE,GACEE,KAAK,CAACC,OAAO,CAACH,KAAK,KAAK,MAAM,CAACA,KAAK,KAAK,CAAQ,WACnDA,KAAK,CAACI,MAAM,KAAK,CAAC,EAClB,CAAC;QACD,MAAM,CAAC,CAAC,CAAC;IACX,CAAC;IAED,MAAM,CAACJ,KAAK,CAACK,KAAK,CAChBP,EAAE,CAACG,KAAK,IAAKA,KAAK,IAAID,KAAK,CAACI,MAAM,GAAG,CAAC,GAAGJ,KAAK,CAACI,MAAM,GAAGH,KAAK,GAAI,CAAC;AAEtE,CAAC;AAED,EAyBG,AAzBH;;;;;;;;;;;;;;;;;;;;;;;;;CAyBG,AAzBH,EAyBG,CACH,MAAM,CAAC,GAAK,CAACK,MAAM,GAAG,QAAQ,GAAO,CAAC;qCAAZC,MAAM;QAANA,MAAM;;IAC9B,EAAwD,AAAxD,sDAAwD;IACxD,EAAE,EAAEA,MAAM,CAACH,MAAM,KAAK,CAAC,IAAI,MAAM,CAACG,MAAM,CAAC,CAAC,MAAM,CAAQ,SAAE,CAAC;QACzD,MAAM,CAACP,QAAQ,CAARA,KAAK;YAAID,MAAM,CAANA,OAAO,CAACQ,MAAM,CAAC,CAAC,GAAGP,KAAK;;IAC1C,CAAC;IAED,EAAoC,AAApC,kCAAoC;IACpC,EAAE,EAAEO,MAAM,CAACH,MAAM,KAAK,CAAC,IAAI,MAAM,CAACG,MAAM,CAAC,CAAC,MAAM,CAAQ,SAAE,CAAC;QACzD,MAAM,CAACR,OAAO,CAACS,SAAS,EAAED,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,EAAoD,AAApD,kDAAoD;IACpD,MAAM,CAACR,OAAO,CAAPA,KAAkB,CAAlBA,IAAI,CAAJA,CAAO,+BAAIQ,MAAM;AAC1B,CAAC"}
@@ -1,17 +1,57 @@
1
1
  import test from "tape";
2
2
  import { bottom } from "./bottom.js";
3
- test("bottom", function (t) {
4
- t.deepEquals(bottom([1, 2, 3]), [2, 3], "3 length [] should return [] with last 2 elm");
5
- t.deepEquals(bottom([1, 2]), [2], "2 length [] should return [] with 1 elm");
6
- t.deepEquals(bottom([1]), [], "1 length [] should return empty []");
7
- t.deepEquals(bottom([]), [], "Empty [] should return empty []");
8
- t.deepEquals(bottom(2, 2), [], "Non-array should return empty []");
9
- t.deepEquals(bottom("asd", []), [], "Non-numeric Limit should return []");
10
- t.deepEquals(bottom(2)([1, 2, 3]), [2, 3], "Limit and [], curried");
11
- t.deepEquals(bottom(2, [1, 2, 3]), [2, 3], "Limit and [], un-curried");
12
- t.deepEquals(bottom(2)("asd"), "sd", "Limit and string, curried");
13
- t.deepEquals(bottom(2, "asd"), "sd", "Limit and string, un-curried");
14
- t.deepEquals(bottom(3, [1, 2]), [1, 2], "Limit grater than max elements should return all elements");
15
- t.end();
3
+ test("bottom", function(t) {
4
+ t.deepEquals(bottom([
5
+ 1,
6
+ 2,
7
+ 3
8
+ ]), [
9
+ 2,
10
+ 3
11
+ ], "3 length [] should return [] with last 2 elm");
12
+ t.deepEquals(bottom([
13
+ 1,
14
+ 2
15
+ ]), [
16
+ 2
17
+ ], "2 length [] should return [] with 1 elm");
18
+ t.deepEquals(bottom([
19
+ 1
20
+ ]), [], "1 length [] should return empty []");
21
+ t.deepEquals(bottom([]), [], "Empty [] should return empty []");
22
+ t.deepEquals(bottom(2, 2), [], "Non-array should return empty []");
23
+ t.deepEquals(bottom("asd", []), [], "Non-numeric Limit should return []");
24
+ t.deepEquals(bottom(2)([
25
+ 1,
26
+ 2,
27
+ 3
28
+ ]), [
29
+ 2,
30
+ 3
31
+ ], "Limit and [], curried");
32
+ t.deepEquals(bottom(2, [
33
+ 1,
34
+ 2,
35
+ 3
36
+ ]), [
37
+ 2,
38
+ 3
39
+ ], "Limit and [], un-curried");
40
+ t.deepEquals(bottom(2)("asd"), "sd", "Limit and string, curried");
41
+ t.deepEquals(bottom(2, "asd"), "sd", "Limit and string, un-curried");
42
+ t.deepEquals(bottom(3, [
43
+ 1,
44
+ 2
45
+ ]), [
46
+ 1,
47
+ 2
48
+ ], "Limit grater than max elements should return all elements");
49
+ t.deepEquals(bottom(3, [
50
+ 1
51
+ ]), [
52
+ 1
53
+ ], "Limit grater than max elements should return all elements");
54
+ t.end();
16
55
  });
56
+
17
57
  //# sourceMappingURL=bottom.test.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bottom/bottom.test.js"],"names":["test","bottom","t","deepEquals","end"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,MAAT,QAAuB,aAAvB;AAEAD,IAAI,CAAC,QAAD,EAAW,UAAAE,CAAC,EAAI;AAClBA,EAAAA,CAAC,CAACC,UAAF,CACEF,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAD,CADR,EAEE,CAAC,CAAD,EAAI,CAAJ,CAFF,EAGE,8CAHF;AAKAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,CAAnB,EAA6B,CAAC,CAAD,CAA7B,EAAkC,yCAAlC;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAC,CAAD,CAAD,CAAnB,EAA0B,EAA1B,EAA8B,oCAA9B;AAEAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,EAAD,CAAnB,EAAyB,EAAzB,EAA6B,iCAA7B;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,EAAI,CAAJ,CAAnB,EAA2B,EAA3B,EAA+B,kCAA/B;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,KAAD,EAAQ,EAAR,CAAnB,EAAgC,EAAhC,EAAoC,oCAApC;AAEAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,CAAN,CAAU,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAV,CAAb,EAAmC,CAAC,CAAD,EAAI,CAAJ,CAAnC,EAA2C,uBAA3C;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAJ,CAAnB,EAAmC,CAAC,CAAD,EAAI,CAAJ,CAAnC,EAA2C,0BAA3C;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,CAAN,CAAU,KAAV,CAAb,EAA+B,IAA/B,EAAqC,2BAArC;AACAC,EAAAA,CAAC,CAACC,UAAF,CAAaF,MAAM,CAAC,CAAD,EAAI,KAAJ,CAAnB,EAA+B,IAA/B,EAAqC,8BAArC;AAEAC,EAAAA,CAAC,CAACC,UAAF,CACEF,MAAM,CAAC,CAAD,EAAI,CAAC,CAAD,EAAI,CAAJ,CAAJ,CADR,EAEE,CAAC,CAAD,EAAI,CAAJ,CAFF,EAGE,2DAHF;AAMAC,EAAAA,CAAC,CAACE,GAAF;AACD,CAzBG,CAAJ","sourcesContent":["import test from \"tape\"\n\nimport { bottom } from \"./bottom.js\"\n\ntest(\"bottom\", t => {\n t.deepEquals(\n bottom([1, 2, 3]),\n [2, 3],\n \"3 length [] should return [] with last 2 elm\"\n )\n t.deepEquals(bottom([1, 2]), [2], \"2 length [] should return [] with 1 elm\")\n t.deepEquals(bottom([1]), [], \"1 length [] should return empty []\")\n\n t.deepEquals(bottom([]), [], \"Empty [] should return empty []\")\n t.deepEquals(bottom(2, 2), [], \"Non-array should return empty []\")\n t.deepEquals(bottom(\"asd\", []), [], \"Non-numeric Limit should return []\")\n\n t.deepEquals(bottom(2)([1, 2, 3]), [2, 3], \"Limit and [], curried\")\n t.deepEquals(bottom(2, [1, 2, 3]), [2, 3], \"Limit and [], un-curried\")\n t.deepEquals(bottom(2)(\"asd\"), \"sd\", \"Limit and string, curried\")\n t.deepEquals(bottom(2, \"asd\"), \"sd\", \"Limit and string, un-curried\")\n\n t.deepEquals(\n bottom(3, [1, 2]),\n [1, 2],\n \"Limit grater than max elements should return all elements\"\n )\n\n t.end()\n})\n"],"file":"bottom.test.js"}
1
+ {"version":3,"sources":["../../src/bottom/bottom.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { bottom } from \"./bottom.js\"\n\ntest(\"bottom\", t => {\n t.deepEquals(\n bottom([1, 2, 3]),\n [2, 3],\n \"3 length [] should return [] with last 2 elm\"\n )\n t.deepEquals(bottom([1, 2]), [2], \"2 length [] should return [] with 1 elm\")\n t.deepEquals(bottom([1]), [], \"1 length [] should return empty []\")\n\n t.deepEquals(bottom([]), [], \"Empty [] should return empty []\")\n t.deepEquals(bottom(2, 2), [], \"Non-array should return empty []\")\n t.deepEquals(bottom(\"asd\", []), [], \"Non-numeric Limit should return []\")\n\n t.deepEquals(bottom(2)([1, 2, 3]), [2, 3], \"Limit and [], curried\")\n t.deepEquals(bottom(2, [1, 2, 3]), [2, 3], \"Limit and [], un-curried\")\n t.deepEquals(bottom(2)(\"asd\"), \"sd\", \"Limit and string, curried\")\n t.deepEquals(bottom(2, \"asd\"), \"sd\", \"Limit and string, un-curried\")\n\n t.deepEquals(\n bottom(3, [1, 2]),\n [1, 2],\n \"Limit grater than max elements should return all elements\"\n )\n t.deepEquals(\n bottom(3, [1]),\n [1],\n \"Limit grater than max elements should return all elements\"\n )\n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,CAACF,MAAM,CAAC,CAAC,EAAE,CAAK,OAAG,CAAI,KAAE,CAA2B;IAChEC,CAAC,CAACC,UAAU,CAACF,MAAM,CAAC,CAAC,EAAE,CAAK,OAAG,CAAI,KAAE,CAA8B;IAEnEC,CAAC,CAACC,UAAU,CACVF,MAAM,CAAC,CAAC,EAAE,CAAC;AAAA,SAAC;AAAE,SAAC;IAAA,CAAC,GAChB,CAAC;AAAA,SAAC;AAAE,SAAC;IAAA,CAAC,EACN,CAA2D;IAE7DC,CAAC,CAACC,UAAU,CACVF,MAAM,CAAC,CAAC,EAAE,CAAC;AAAA,SAAC;IAAA,CAAC,GACb,CAAC;AAAA,SAAC;IAAA,CAAC,EACH,CAA2D;IAG7DC,CAAC,CAACE,GAAG;AACP,CAAC"}
@@ -1,5 +1,4 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _toArray from "@babel/runtime/helpers/toArray";
1
+ import * as swcHelpers from "@swc/helpers";
3
2
  import { when } from "../when/when.js";
4
3
  import { i } from "../i/i.js";
5
4
  /**
@@ -24,16 +23,9 @@ import { i } from "../i/i.js";
24
23
  * [x === 1, x => x],
25
24
  * ], x => x + 1)(2)
26
25
  * // => 3
27
- */
28
-
29
- export var cases = function cases(_ref) {
30
- var _ref2 = _toArray(_ref),
31
- _ref2$ = _slicedToArray(_ref2[0], 2),
32
- conditionFn = _ref2$[0],
33
- thenFn = _ref2$[1],
34
- rest = _ref2.slice(1);
35
-
36
- var otherwise = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i;
37
- return when(conditionFn, thenFn, rest.length === 0 ? otherwise : cases(rest, otherwise));
26
+ */ export var cases = function(param) {
27
+ var _param = swcHelpers.toArray(param), ref = swcHelpers.slicedToArray(_param[0], 2), conditionFn = ref[0], thenFn = ref[1], rest = _param.slice(1), otherwise = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : i;
28
+ return when(conditionFn, thenFn, rest.length === 0 ? otherwise : cases(rest, otherwise));
38
29
  };
30
+
39
31
  //# sourceMappingURL=cases.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cases/cases.js"],"names":["when","i","cases","conditionFn","thenFn","rest","otherwise","length"],"mappings":";;AAAA,SAASA,IAAT,QAAqB,iBAArB;AACA,SAASC,CAAT,QAAkB,WAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,KAAK,GAAG,SAARA,KAAQ;AAAA;AAAA;AAAA,MAAGC,WAAH;AAAA,MAAgBC,MAAhB;AAAA,MAA4BC,IAA5B;;AAAA,MAAmCC,SAAnC,uEAA+CL,CAA/C;AAAA,SACnBD,IAAI,CACFG,WADE,EAEFC,MAFE,EAGFC,IAAI,CAACE,MAAL,KAAgB,CAAhB,GAAoBD,SAApB,GAAgCJ,KAAK,CAACG,IAAD,EAAOC,SAAP,CAHnC,CADe;AAAA,CAAd","sourcesContent":["import { when } from \"../when/when.js\"\nimport { i } from \"../i/i.js\"\n\n/**\n * Functional case statement.\n *\n * @param {Array<Function, Function>} conditions List of 2-tuples of functions (if, then)\n * @param {Function} [otherwise=i] Function to call if no condition matches, Defaults to identity.\n * @param {any} source Value to check\n *\n * @returns {any}\n * The result of calling the first matching then function or the\n * otherwise function on the input.\n *\n * @name cases\n * @tag Core\n *\n * @see {@link when}\n *\n * @example\n * cases([\n * [x === 0, x => x * 2],\n * [x === 1, x => x],\n * ], x => x + 1)(2)\n * // => 3\n */\nexport const cases = ([[conditionFn, thenFn], ...rest], otherwise = i) =>\n when(\n conditionFn,\n thenFn,\n rest.length === 0 ? otherwise : cases(rest, otherwise)\n )\n"],"file":"cases.js"}
1
+ {"version":3,"sources":["../../src/cases/cases.js"],"sourcesContent":["import { when } from \"../when/when.js\"\nimport { i } from \"../i/i.js\"\n\n/**\n * Functional case statement.\n *\n * @param {Array<Function, Function>} conditions List of 2-tuples of functions (if, then)\n * @param {Function} [otherwise=i] Function to call if no condition matches, Defaults to identity.\n * @param {any} source Value to check\n *\n * @returns {any}\n * The result of calling the first matching then function or the\n * otherwise function on the input.\n *\n * @name cases\n * @tag Core\n *\n * @see {@link when}\n *\n * @example\n * cases([\n * [x === 0, x => x * 2],\n * [x === 1, x => x],\n * ], x => x + 1)(2)\n * // => 3\n */\nexport const cases = ([[conditionFn, thenFn], ...rest], otherwise = i) =>\n when(\n conditionFn,\n thenFn,\n rest.length === 0 ? otherwise : cases(rest, otherwise)\n )\n"],"names":["when","i","cases","conditionFn","thenFn","rest","otherwise","length"],"mappings":";AAAA,MAAM,GAAGA,IAAI,QAAQ,CAAiB;AACtC,MAAM,GAAGC,CAAC,QAAQ,CAAW;AAE7B,EAsBG,AAtBH;;;;;;;;;;;;;;;;;;;;;;CAsBG,AAtBH,EAsBG,CACH,MAAM,CAAC,GAAK,CAACC,KAAK,GAAG,QAAQ;0FAALC,WAAW,WAAEC,MAAM,WAAMC,IAAI,gBAAP,CAAGA,GAAOC,SAAS,oEAAGL,CAAC;IACnED,MACF,CADEA,IAAI,CACFG,WAAW,EACXC,MAAM,EACNC,IAAI,CAACE,MAAM,KAAK,CAAC,GAAGD,SAAS,GAAGJ,KAAK,CAACG,IAAI,EAAEC,SAAS"}
@@ -1,39 +1,71 @@
1
1
  import test from "tape";
2
2
  import { cases } from "./cases.js";
3
- test("cases", function (t) {
4
- t.equal(cases([[function (x) {
5
- return x % 2 === 0;
6
- }, function (x) {
7
- return x * 2;
8
- }], [function (x) {
9
- return x % 2 === 1;
10
- }, function (x) {
11
- return x + 5;
12
- }], [function (x) {
13
- return x === 2;
14
- }, function (x) {
15
- return x / 2;
16
- }]])(2), 4, "cases should evaluate the first matching function over the input");
17
- t.equal(cases([[function (x) {
18
- return x % 2 === 0;
19
- }, function (x) {
20
- return x * 2;
21
- }], [function (x) {
22
- return x === 2;
23
- }, function (x) {
24
- return x / 2;
25
- }]])(3), 3, "cases should return the original value otherwise");
26
- t.equal(cases([[function (x) {
27
- return x % 2 === 0;
28
- }, function (x) {
29
- return x * 2;
30
- }], [function (x) {
31
- return x === 2;
32
- }, function (x) {
33
- return x / 2;
34
- }]], function (x) {
35
- return x * 3;
36
- })(3), 9, "cases allows passing an alternative otherwise handler");
37
- t.end();
3
+ test("cases", function(t) {
4
+ t.equal(cases([
5
+ [
6
+ function(x) {
7
+ return x % 2 === 0;
8
+ },
9
+ function(x) {
10
+ return x * 2;
11
+ }
12
+ ],
13
+ [
14
+ function(x) {
15
+ return x % 2 === 1;
16
+ },
17
+ function(x) {
18
+ return x + 5;
19
+ }
20
+ ],
21
+ [
22
+ function(x) {
23
+ return x === 2;
24
+ },
25
+ function(x) {
26
+ return x / 2;
27
+ }
28
+ ],
29
+ ])(2), 4, "cases should evaluate the first matching function over the input");
30
+ t.equal(cases([
31
+ [
32
+ function(x) {
33
+ return x % 2 === 0;
34
+ },
35
+ function(x) {
36
+ return x * 2;
37
+ }
38
+ ],
39
+ [
40
+ function(x) {
41
+ return x === 2;
42
+ },
43
+ function(x) {
44
+ return x / 2;
45
+ }
46
+ ],
47
+ ])(3), 3, "cases should return the original value otherwise");
48
+ t.equal(cases([
49
+ [
50
+ function(x) {
51
+ return x % 2 === 0;
52
+ },
53
+ function(x) {
54
+ return x * 2;
55
+ }
56
+ ],
57
+ [
58
+ function(x) {
59
+ return x === 2;
60
+ },
61
+ function(x) {
62
+ return x / 2;
63
+ }
64
+ ],
65
+ ], function(x) {
66
+ return x * 3;
67
+ })(3), 9, "cases allows passing an alternative otherwise handler");
68
+ t.end();
38
69
  });
70
+
39
71
  //# sourceMappingURL=cases.test.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cases/cases.test.js"],"names":["test","cases","t","equal","x","end"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,SAASC,KAAT,QAAsB,YAAtB;AAEAD,IAAI,CAAC,OAAD,EAAU,UAAAE,CAAC,EAAI;AACjBA,EAAAA,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CAAR;AAAA,GAAhB,CAFF,CADG,EAKH,UAAAA,CAAC;AAAA,WAAIA,CAAC,GAAG,CAAR;AAAA,GALE,CAAL,CAME,CANF,CADF,EAQE,CARF,EASE,uDATF;AAYAF,EAAAA,CAAC,CAACG,GAAF;AACD,CAjCG,CAAJ","sourcesContent":["import test from \"tape\"\n\nimport { cases } from \"./cases.js\"\n\ntest(\"cases\", t => {\n t.equal(\n cases([\n [x => x % 2 === 0, x => x * 2],\n [x => x % 2 === 1, x => x + 5],\n [x => x === 2, x => x / 2],\n ])(2),\n 4,\n \"cases should evaluate the first matching function over the input\"\n )\n\n t.equal(\n cases([\n [x => x % 2 === 0, x => x * 2],\n [x => x === 2, x => x / 2],\n ])(3),\n 3,\n \"cases should return the original value otherwise\"\n )\n\n t.equal(\n cases(\n [\n [x => x % 2 === 0, x => x * 2],\n [x => x === 2, x => x / 2],\n ],\n x => x * 3\n )(3),\n 9,\n \"cases allows passing an alternative otherwise handler\"\n )\n\n t.end()\n})\n"],"file":"cases.test.js"}
1
+ {"version":3,"sources":["../../src/cases/cases.test.js"],"sourcesContent":["import test from \"tape\"\n\nimport { cases } from \"./cases.js\"\n\ntest(\"cases\", t => {\n t.equal(\n cases([\n [x => x % 2 === 0, x => x * 2],\n [x => x % 2 === 1, x => x + 5],\n [x => x === 2, x => x / 2],\n ])(2),\n 4,\n \"cases should evaluate the first matching function over the input\"\n )\n\n t.equal(\n cases([\n [x => x % 2 === 0, x => x * 2],\n [x => x === 2, x => x / 2],\n ])(3),\n 3,\n \"cases should return the original value otherwise\"\n )\n\n t.equal(\n cases(\n [\n [x => x % 2 === 0, x => x * 2],\n [x => x === 2, x => x / 2],\n ],\n x => x * 3\n )(3),\n 9,\n \"cases allows passing an alternative otherwise handler\"\n )\n\n t.end()\n})\n"],"names":["test","cases","t","equal","x","end"],"mappings":"AAAA,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,KAAK,QAAQ,CAAY;AAElCD,IAAI,CAA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IA,MAAM,CAANA,CAAC,GAAG,CAAC;;QAAA,CAAC;QAC9B,CAACA;YAAAA,QAAQ,CAARA,CAAC;gBAAIA,MAAM,CAANA,CAAC,KAAK,CAAC;;YAAEA,QAAQ,CAARA,CAAC;gBAAIA,MAAM,CAANA,CAAC,GAAG,CAAC;;QAAA,CAAC;IAC5B,CAAC,EACDA,QAAQ,CAARA,CAAC;QAAIA,MACX,CADWA,CAAC,GAAG,CAAC;OACV,CAAC,GACH,CAAC,EACD,CAAuD;IAGzDF,CAAC,CAACG,GAAG;AACP,CAAC"}
@@ -1,4 +1,4 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
+ import * as swcHelpers from "@swc/helpers";
2
2
  import { map } from "../map/map.js";
3
3
  import { reduce } from "../reduce/reduce.js";
4
4
  import { type } from "../type/type.js";
@@ -24,34 +24,25 @@ import { type } from "../type/type.js";
24
24
  *
25
25
  * close(x) === x
26
26
  * // => false
27
- */
28
-
29
- export var clone = function clone(input) {
30
- var inputType = type(input);
31
-
32
- if (inputType === "Array") {
33
- return map(clone, input);
34
- }
35
-
36
- if (inputType === "Object") {
37
- return reduce(function (acc, _ref) {
38
- var _ref2 = _slicedToArray(_ref, 2),
39
- key = _ref2[0],
40
- elm = _ref2[1];
41
-
42
- acc[key] = clone(elm);
43
- return acc;
44
- }, {}, Object.entries(input));
45
- }
46
-
47
- if (inputType === "Date") {
48
- return new Date(input.getTime());
49
- }
50
-
51
- if (inputType === "RegExp") {
52
- return new RegExp(inputType.toString());
53
- }
54
-
55
- return input;
27
+ */ export var clone = function(input) {
28
+ var inputType = type(input);
29
+ if (inputType === "Array") {
30
+ return map(clone, input);
31
+ }
32
+ if (inputType === "Object") {
33
+ return reduce(function(acc, param) {
34
+ var _param = swcHelpers.slicedToArray(param, 2), key = _param[0], elm = _param[1];
35
+ acc[key] = clone(elm);
36
+ return acc;
37
+ }, {}, Object.entries(input));
38
+ }
39
+ if (inputType === "Date") {
40
+ return new Date(input.getTime());
41
+ }
42
+ if (inputType === "RegExp") {
43
+ return new RegExp(inputType.toString());
44
+ }
45
+ return input;
56
46
  };
47
+
57
48
  //# sourceMappingURL=clone.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/clone/clone.js"],"names":["map","reduce","type","clone","input","inputType","acc","key","elm","Object","entries","Date","getTime","RegExp","toString"],"mappings":";AAAA,SAASA,GAAT,QAAoB,eAApB;AACA,SAASC,MAAT,QAAuB,qBAAvB;AACA,SAASC,IAAT,QAAqB,iBAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAAAC,KAAK,EAAI;AAC5B,MAAMC,SAAS,GAAGH,IAAI,CAACE,KAAD,CAAtB;;AAEA,MAAIC,SAAS,KAAK,OAAlB,EAA2B;AACzB,WAAOL,GAAG,CAACG,KAAD,EAAQC,KAAR,CAAV;AACD;;AAED,MAAIC,SAAS,KAAK,QAAlB,EAA4B;AAC1B,WAAOJ,MAAM,CACX,UAACK,GAAD,QAAqB;AAAA;AAAA,UAAdC,GAAc;AAAA,UAATC,GAAS;;AACnBF,MAAAA,GAAG,CAACC,GAAD,CAAH,GAAWJ,KAAK,CAACK,GAAD,CAAhB;AAEA,aAAOF,GAAP;AACD,KALU,EAMX,EANW,EAOXG,MAAM,CAACC,OAAP,CAAeN,KAAf,CAPW,CAAb;AASD;;AAED,MAAIC,SAAS,KAAK,MAAlB,EAA0B;AACxB,WAAO,IAAIM,IAAJ,CAASP,KAAK,CAACQ,OAAN,EAAT,CAAP;AACD;;AAED,MAAIP,SAAS,KAAK,QAAlB,EAA4B;AAC1B,WAAO,IAAIQ,MAAJ,CAAWR,SAAS,CAACS,QAAV,EAAX,CAAP;AACD;;AAED,SAAOV,KAAP;AACD,CA5BM","sourcesContent":["import { map } from \"../map/map.js\"\nimport { reduce } from \"../reduce/reduce.js\"\nimport { type } from \"../type/type.js\"\n\n/**\n * Creates a new instance of the object with same properties than original.\n * Will not inherit prototype, only own enumerable properties.\n *\n * @param {any} input Source input value\n *\n * @returns {any} New instance of source\n *\n * @name clone\n * @tag Core\n * @signature (source: Any): Any\n *\n * @see {@link deepEqual}\n *\n * @example\n * let x = {a: [1]}\n *\n * clone(x)\n * // => {a: [1]}\n *\n * close(x) === x\n * // => false\n */\nexport const clone = input => {\n const inputType = type(input)\n\n if (inputType === \"Array\") {\n return map(clone, input)\n }\n\n if (inputType === \"Object\") {\n return reduce(\n (acc, [key, elm]) => {\n acc[key] = clone(elm)\n\n return acc\n },\n {},\n Object.entries(input)\n )\n }\n\n if (inputType === \"Date\") {\n return new Date(input.getTime())\n }\n\n if (inputType === \"RegExp\") {\n return new RegExp(inputType.toString())\n }\n\n return input\n}\n"],"file":"clone.js"}
1
+ {"version":3,"sources":["../../src/clone/clone.js"],"sourcesContent":["import { map } from \"../map/map.js\"\nimport { reduce } from \"../reduce/reduce.js\"\nimport { type } from \"../type/type.js\"\n\n/**\n * Creates a new instance of the object with same properties than original.\n * Will not inherit prototype, only own enumerable properties.\n *\n * @param {any} input Source input value\n *\n * @returns {any} New instance of source\n *\n * @name clone\n * @tag Core\n * @signature (source: Any): Any\n *\n * @see {@link deepEqual}\n *\n * @example\n * let x = {a: [1]}\n *\n * clone(x)\n * // => {a: [1]}\n *\n * close(x) === x\n * // => false\n */\nexport const clone = input => {\n const inputType = type(input)\n\n if (inputType === \"Array\") {\n return map(clone, input)\n }\n\n if (inputType === \"Object\") {\n return reduce(\n (acc, [key, elm]) => {\n acc[key] = clone(elm)\n\n return acc\n },\n {},\n Object.entries(input)\n )\n }\n\n if (inputType === \"Date\") {\n return new Date(input.getTime())\n }\n\n if (inputType === \"RegExp\") {\n return new RegExp(inputType.toString())\n }\n\n return input\n}\n"],"names":["map","reduce","type","clone","input","inputType","acc","key","elm","Object","entries","Date","getTime","RegExp","toString"],"mappings":";AAAA,MAAM,GAAGA,GAAG,QAAQ,CAAe;AACnC,MAAM,GAAGC,MAAM,QAAQ,CAAqB;AAC5C,MAAM,GAAGC,IAAI,QAAQ,CAAiB;AAEtC,EAsBG,AAtBH;;;;;;;;;;;;;;;;;;;;;;CAsBG,AAtBH,EAsBG,CACH,MAAM,CAAC,GAAK,CAACC,KAAK,GAAGC,QAAQ,CAARA,KAAK,EAAI,CAAC;IAC7B,GAAK,CAACC,SAAS,GAAGH,IAAI,CAACE,KAAK;IAE5B,EAAE,EAAEC,SAAS,KAAK,CAAO,QAAE,CAAC;QAC1B,MAAM,CAACL,GAAG,CAACG,KAAK,EAAEC,KAAK;IACzB,CAAC;IAED,EAAE,EAAEC,SAAS,KAAK,CAAQ,SAAE,CAAC;QAC3B,MAAM,CAACJ,MAAM,CACX,QAAQ,CAAPK,GAAG,SAAiB,CAAC;6DAAfC,GAAG,cAAEC,GAAG;YACbF,GAAG,CAACC,GAAG,IAAIJ,KAAK,CAACK,GAAG;YAEpB,MAAM,CAACF,GAAG;QACZ,CAAC,EACD,CAAC,CAAC,EACFG,MAAM,CAACC,OAAO,CAACN,KAAK;IAExB,CAAC;IAED,EAAE,EAAEC,SAAS,KAAK,CAAM,OAAE,CAAC;QACzB,MAAM,CAAC,GAAG,CAACM,IAAI,CAACP,KAAK,CAACQ,OAAO;IAC/B,CAAC;IAED,EAAE,EAAEP,SAAS,KAAK,CAAQ,SAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAACQ,MAAM,CAACR,SAAS,CAACS,QAAQ;IACtC,CAAC;IAED,MAAM,CAACV,KAAK;AACd,CAAC"}
@@ -1,44 +1,45 @@
1
- /* eslint-disable unicorn/no-null */
2
- import test from "tape";
1
+ /* eslint-disable unicorn/no-null */ import test from "tape";
3
2
  import { clone } from "./clone.js";
4
- test("clone", function (t) {
5
- /*
3
+ test("clone", function(t) {
4
+ /*
6
5
  * Primitives
7
- */
8
- t.equal(clone(null), null, "Clone null");
9
- t.equal(clone(), undefined, "Clone undefined");
10
- t.equal(clone(2), 2, "Clone number");
11
- t.equal(clone("3"), "3", "Clone number");
12
- t.equal(clone(true), true, "Clone boolean");
13
- /*
6
+ */ t.equal(clone(null), null, "Clone null");
7
+ t.equal(clone(), undefined, "Clone undefined");
8
+ t.equal(clone(2), 2, "Clone number");
9
+ t.equal(clone("3"), "3", "Clone number");
10
+ t.equal(clone(true), true, "Clone boolean");
11
+ /*
14
12
  * Date
15
- */
16
-
17
- var date = new Date(86400000);
18
- t.notEqual(clone(date), date, "Imutable date");
19
- t.equal(clone(date).getTime(), 86400000, "Clone date");
20
- /*
13
+ */ var date = new Date(86400000);
14
+ t.notEqual(clone(date), date, "Imutable date");
15
+ t.equal(clone(date).getTime(), 86400000, "Clone date");
16
+ /*
21
17
  * Array
22
- */
23
-
24
- var array = [1, 2, 3];
25
- t.notEqual(clone(array), array, "Imutable array");
26
- t.deepEqual(clone(array), [1, 2, 3], "Clone array");
27
- /*
18
+ */ var array = [
19
+ 1,
20
+ 2,
21
+ 3
22
+ ];
23
+ t.notEqual(clone(array), array, "Imutable array");
24
+ t.deepEqual(clone(array), [
25
+ 1,
26
+ 2,
27
+ 3
28
+ ], "Clone array");
29
+ /*
28
30
  * Object
29
- */
30
-
31
- var object = {
32
- a: 1,
33
- b: 2,
34
- c: 3
35
- };
36
- t.notEqual(clone(object), object, "Imutable array");
37
- t.deepEqual(clone(object), {
38
- a: 1,
39
- b: 2,
40
- c: 3
41
- }, "Clone array");
42
- t.end();
31
+ */ var object = {
32
+ a: 1,
33
+ b: 2,
34
+ c: 3
35
+ };
36
+ t.notEqual(clone(object), object, "Imutable array");
37
+ t.deepEqual(clone(object), {
38
+ a: 1,
39
+ b: 2,
40
+ c: 3
41
+ }, "Clone array");
42
+ t.end();
43
43
  });
44
+
44
45
  //# sourceMappingURL=clone.test.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/clone/clone.test.js"],"names":["test","clone","t","equal","undefined","date","Date","notEqual","getTime","array","deepEqual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AAG;AAAEC,IAAAA,CAAC,EAAE,CAAL;AAAQC,IAAAA,CAAC,EAAE,CAAX;AAAcC,IAAAA,CAAC,EAAE;AAAjB,GAAf;AAEAZ,EAAAA,CAAC,CAACK,QAAF,CAAWN,KAAK,CAACU,MAAD,CAAhB,EAA0BA,MAA1B,EAAkC,gBAAlC;AACAT,EAAAA,CAAC,CAACQ,SAAF,CAAYT,KAAK,CAACU,MAAD,CAAjB,EAA2B;AAAEC,IAAAA,CAAC,EAAE,CAAL;AAAQC,IAAAA,CAAC,EAAE,CAAX;AAAcC,IAAAA,CAAC,EAAE;AAAjB,GAA3B,EAAiD,aAAjD;AAEAZ,EAAAA,CAAC,CAACa,GAAF;AACD,CAnCG,CAAJ","sourcesContent":["/* eslint-disable unicorn/no-null */\n\nimport test from \"tape\"\n\nimport { clone } from \"./clone.js\"\n\ntest(\"clone\", t => {\n /*\n * Primitives\n */\n t.equal(clone(null), null, \"Clone null\")\n t.equal(clone(), undefined, \"Clone undefined\")\n t.equal(clone(2), 2, \"Clone number\")\n t.equal(clone(\"3\"), \"3\", \"Clone number\")\n t.equal(clone(true), true, \"Clone boolean\")\n\n /*\n * Date\n */\n const date = new Date(86_400_000)\n\n t.notEqual(clone(date), date, \"Imutable date\")\n t.equal(clone(date).getTime(), 86_400_000, \"Clone date\")\n\n /*\n * Array\n */\n const array = [1, 2, 3]\n\n t.notEqual(clone(array), array, \"Imutable array\")\n t.deepEqual(clone(array), [1, 2, 3], \"Clone array\")\n\n /*\n * Object\n */\n const object = { a: 1, b: 2, c: 3 }\n\n t.notEqual(clone(object), object, \"Imutable array\")\n t.deepEqual(clone(object), { a: 1, b: 2, c: 3 }, \"Clone array\")\n\n t.end()\n})\n"],"file":"clone.test.js"}
1
+ {"version":3,"sources":["../../src/clone/clone.test.js"],"sourcesContent":["/* eslint-disable unicorn/no-null */\n\nimport test from \"tape\"\n\nimport { clone } from \"./clone.js\"\n\ntest(\"clone\", t => {\n /*\n * Primitives\n */\n t.equal(clone(null), null, \"Clone null\")\n t.equal(clone(), undefined, \"Clone undefined\")\n t.equal(clone(2), 2, \"Clone number\")\n t.equal(clone(\"3\"), \"3\", \"Clone number\")\n t.equal(clone(true), true, \"Clone boolean\")\n\n /*\n * Date\n */\n const date = new Date(86_400_000)\n\n t.notEqual(clone(date), date, \"Imutable date\")\n t.equal(clone(date).getTime(), 86_400_000, \"Clone date\")\n\n /*\n * Array\n */\n const array = [1, 2, 3]\n\n t.notEqual(clone(array), array, \"Imutable array\")\n t.deepEqual(clone(array), [1, 2, 3], \"Clone array\")\n\n /*\n * Object\n */\n const object = { a: 1, b: 2, c: 3 }\n\n t.notEqual(clone(object), object, \"Imutable array\")\n t.deepEqual(clone(object), { a: 1, b: 2, c: 3 }, \"Clone array\")\n\n t.end()\n})\n"],"names":["test","clone","t","equal","undefined","date","Date","notEqual","getTime","array","deepEqual","object","a","b","c","end"],"mappings":"AAAA,EAAoC,AAApC,gCAAoC,AAApC,EAAoC,CAEpC,MAAM,CAACA,IAAI,MAAM,CAAM;AAEvB,MAAM,GAAGC,KAAK,QAAQ,CAAY;AAElCD,IAAI,CAAC,CAAO,QAAEE,QACb,CADaA,CAAC,EAAI,CAAC;IAClB,EAEG,AAFH;;GAEG,AAFH,EAEG,CACHA,CAAC,CAACC,KAAK,CAACF,KAAK,CAAC,IAAI,GAAG,IAAI,EAAE,CAAY;IACvCC,CAAC,CAACC,KAAK,CAACF,KAAK,IAAIG,SAAS,EAAE,CAAiB;IAC7CF,CAAC,CAACC,KAAK,CAACF,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAc;IACnCC,CAAC,CAACC,KAAK,CAACF,KAAK,CAAC,CAAG,KAAG,CAAG,IAAE,CAAc;IACvCC,CAAC,CAACC,KAAK,CAACF,KAAK,CAAC,IAAI,GAAG,IAAI,EAAE,CAAe;IAE1C,EAEG,AAFH;;GAEG,AAFH,EAEG,CACH,GAAK,CAACI,IAAI,GAAG,GAAG,CAACC,IAAI,CAAC,QAAU;IAEhCJ,CAAC,CAACK,QAAQ,CAACN,KAAK,CAACI,IAAI,GAAGA,IAAI,EAAE,CAAe;IAC7CH,CAAC,CAACC,KAAK,CAACF,KAAK,CAACI,IAAI,EAAEG,OAAO,IAAI,QAAU,EAAE,CAAY;IAEvD,EAEG,AAFH;;GAEG,AAFH,EAEG,CACH,GAAK,CAACC,KAAK,GAAG,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC;IAEvBP,CAAC,CAACK,QAAQ,CAACN,KAAK,CAACQ,KAAK,GAAGA,KAAK,EAAE,CAAgB;IAChDP,CAAC,CAACQ,SAAS,CAACT,KAAK,CAACQ,KAAK,GAAG,CAAC;AAAA,SAAC;AAAE,SAAC;AAAE,SAAC;IAAA,CAAC,EAAE,CAAa;IAElD,EAEG,AAFH;;GAEG,AAFH,EAEG,CACH,GAAK,CAACE,MAAM,GAAG,CAAC;QAACC,CAAC,EAAE,CAAC;QAAEC,CAAC,EAAE,CAAC;QAAEC,CAAC,EAAE,CAAC;IAAC,CAAC;IAEnCZ,CAAC,CAACK,QAAQ,CAACN,KAAK,CAACU,MAAM,GAAGA,MAAM,EAAE,CAAgB;IAClDT,CAAC,CAACQ,SAAS,CAACT,KAAK,CAACU,MAAM,GAAG,CAAC;QAACC,CAAC,EAAE,CAAC;QAAEC,CAAC,EAAE,CAAC;QAAEC,CAAC,EAAE,CAAC;IAAC,CAAC,EAAE,CAAa;IAE9DZ,CAAC,CAACa,GAAG;AACP,CAAC"}
@@ -1,32 +1,37 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
-
1
+ import * as swcHelpers from "@swc/helpers";
7
2
  import { is } from "../is/is.js";
8
3
  import { map } from "../map/map.js";
9
4
  import { filter } from "../filter/filter.js";
10
5
  import { type } from "../type/type.js";
11
-
12
- var _compactObject = function _compactObject(input) {
13
- var result = _objectSpread({}, input);
14
-
15
- var keys = Object.keys(result);
16
-
17
- for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
18
- var key = _keys[_i];
19
-
20
- if (!is(result[key])) {
21
- delete result[key];
6
+ var _compactObject = function(input) {
7
+ var result = swcHelpers.objectSpread({}, input);
8
+ var keys = Object.keys(result);
9
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
10
+ try {
11
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
12
+ var key = _step.value;
13
+ if (!is(result[key])) {
14
+ delete result[key];
15
+ }
16
+ }
17
+ } catch (err) {
18
+ _didIteratorError = true;
19
+ _iteratorError = err;
20
+ } finally{
21
+ try {
22
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
23
+ _iterator.return();
24
+ }
25
+ } finally{
26
+ if (_didIteratorError) {
27
+ throw _iteratorError;
28
+ }
29
+ }
22
30
  }
23
- }
24
-
25
- return result;
31
+ return result;
26
32
  };
27
-
28
- var _compactArray = function _compactArray(input) {
29
- return filter(is, input);
33
+ var _compactArray = function(input) {
34
+ return filter(is, input);
30
35
  };
31
36
  /**
32
37
  * Returns a copy of the object or array with all null or undefined values
@@ -59,22 +64,17 @@ var _compactArray = function _compactArray(input) {
59
64
  * // d: false,
60
65
  * // f: lambda
61
66
  * // }
62
- */
63
-
64
-
65
- export var compact = function compact(input) {
66
- var inputType = type(input);
67
-
68
- switch (inputType) {
69
- case "Array":
70
- return _compactArray(input);
71
-
72
- case "Object":
73
- return _compactObject(input);
74
-
75
- default:
76
- return input;
77
- }
67
+ */ export var compact = function(input) {
68
+ var inputType = type(input);
69
+ switch(inputType){
70
+ case "Array":
71
+ return _compactArray(input);
72
+ case "Object":
73
+ return _compactObject(input);
74
+ default:
75
+ return input;
76
+ }
78
77
  };
79
78
  export var compactMany = map(compact);
79
+
80
80
  //# sourceMappingURL=compact.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/compact/compact.js"],"names":["is","map","filter","type","_compactObject","input","result","keys","Object","key","_compactArray","compact","inputType","compactMany"],"mappings":";;;;;;AAAA,SAASA,EAAT,QAAmB,aAAnB;AACA,SAASC,GAAT,QAAoB,eAApB;AACA,SAASC,MAAT,QAAuB,qBAAvB;AACA,SAASC,IAAT,QAAqB,iBAArB;;AAEA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,KAAK,EAAI;AAC9B,MAAMC,MAAM,qBAAQD,KAAR,CAAZ;;AACA,MAAME,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAYD,MAAZ,CAAb;;AAEA,2BAAkBC,IAAlB,2BAAwB;AAAnB,QAAME,GAAG,YAAT;;AACH,QAAI,CAACT,EAAE,CAACM,MAAM,CAACG,GAAD,CAAP,CAAP,EAAsB;AACpB,aAAOH,MAAM,CAACG,GAAD,CAAb;AACD;AACF;;AAED,SAAOH,MAAP;AACD,CAXD;;AAaA,IAAMI,aAAa,GAAG,SAAhBA,aAAgB,CAAAL,KAAK;AAAA,SAAIH,MAAM,CAACF,EAAD,EAAKK,KAAL,CAAV;AAAA,CAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAMM,OAAO,GAAG,SAAVA,OAAU,CAAAN,KAAK,EAAI;AAC9B,MAAMO,SAAS,GAAGT,IAAI,CAACE,KAAD,CAAtB;;AAEA,UAAQO,SAAR;AACE,SAAK,OAAL;AACE,aAAOF,aAAa,CAACL,KAAD,CAApB;;AAEF,SAAK,QAAL;AACE,aAAOD,cAAc,CAACC,KAAD,CAArB;;AAEF;AACE,aAAOA,KAAP;AARJ;AAUD,CAbM;AAeP,OAAO,IAAMQ,WAAW,GAAGZ,GAAG,CAACU,OAAD,CAAvB","sourcesContent":["import { is } from \"../is/is.js\"\nimport { map } from \"../map/map.js\"\nimport { filter } from \"../filter/filter.js\"\nimport { type } from \"../type/type.js\"\n\nconst _compactObject = input => {\n const result = { ...input }\n const keys = Object.keys(result)\n\n for (const key of keys) {\n if (!is(result[key])) {\n delete result[key]\n }\n }\n\n return result\n}\n\nconst _compactArray = input => filter(is, input)\n\n/**\n * Returns a copy of the object or array with all null or undefined values\n * removed.\n *\n * @param {Array|Object} input\n *\n * @returns {Array|Object}\n *\n * @name compact\n * @tag Array,Object\n * @signature (source: Array|Object): Array|Object\n *\n * @see {@link compactMany}\n * @see {@link is}\n *\n * @example\n * compact([1, null, undefined, {}])\n * // => [1, {}]\n *\n * compact({\n * a: \"Lorem Ipsum\",\n * b: null,\n * c: undefined,\n * d: false,\n * f: lambda,\n * }),\n * // => {\n * // a: \"Lorem Ipsum\",\n * // d: false,\n * // f: lambda\n * // }\n */\nexport const compact = input => {\n const inputType = type(input)\n\n switch (inputType) {\n case \"Array\":\n return _compactArray(input)\n\n case \"Object\":\n return _compactObject(input)\n\n default:\n return input\n }\n}\n\nexport const compactMany = map(compact)\n"],"file":"compact.js"}
1
+ {"version":3,"sources":["../../src/compact/compact.js"],"sourcesContent":["import { is } from \"../is/is.js\"\nimport { map } from \"../map/map.js\"\nimport { filter } from \"../filter/filter.js\"\nimport { type } from \"../type/type.js\"\n\nconst _compactObject = input => {\n const result = { ...input }\n const keys = Object.keys(result)\n\n for (const key of keys) {\n if (!is(result[key])) {\n delete result[key]\n }\n }\n\n return result\n}\n\nconst _compactArray = input => filter(is, input)\n\n/**\n * Returns a copy of the object or array with all null or undefined values\n * removed.\n *\n * @param {Array|Object} input\n *\n * @returns {Array|Object}\n *\n * @name compact\n * @tag Array,Object\n * @signature (source: Array|Object): Array|Object\n *\n * @see {@link compactMany}\n * @see {@link is}\n *\n * @example\n * compact([1, null, undefined, {}])\n * // => [1, {}]\n *\n * compact({\n * a: \"Lorem Ipsum\",\n * b: null,\n * c: undefined,\n * d: false,\n * f: lambda,\n * }),\n * // => {\n * // a: \"Lorem Ipsum\",\n * // d: false,\n * // f: lambda\n * // }\n */\nexport const compact = input => {\n const inputType = type(input)\n\n switch (inputType) {\n case \"Array\":\n return _compactArray(input)\n\n case \"Object\":\n return _compactObject(input)\n\n default:\n return input\n }\n}\n\nexport const compactMany = map(compact)\n"],"names":["is","map","filter","type","_compactObject","input","result","keys","Object","key","_compactArray","compact","inputType","compactMany"],"mappings":";AAAA,MAAM,GAAGA,EAAE,QAAQ,CAAa;AAChC,MAAM,GAAGC,GAAG,QAAQ,CAAe;AACnC,MAAM,GAAGC,MAAM,QAAQ,CAAqB;AAC5C,MAAM,GAAGC,IAAI,QAAQ,CAAiB;AAEtC,GAAK,CAACC,cAAc,GAAGC,QAAQ,CAARA,KAAK,EAAI,CAAC;IAC/B,GAAK,CAACC,MAAM,+BAAQD,KAAK;IACzB,GAAK,CAACE,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,MAAM;QAE1B,yBAAS,SAAT,iBAAS,UAAT,cAAS;;QAAd,GAAG,KAAE,SAAS,GAAIC,IAAI,qBAAjB,KAAS,IAAT,yBAAS,IAAT,KAAS,GAAT,SAAS,gBAAT,yBAAS,QAAU,CAAC;YAApB,GAAK,CAACE,GAAG,GAAT,KAAS;YACZ,EAAE,GAAGT,EAAE,CAACM,MAAM,CAACG,GAAG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