@oscarpalmer/atoms 0.221.0 → 0.223.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 (331) hide show
  1. package/dist/array/difference.d.mts +1 -3
  2. package/dist/array/difference.mjs +2 -3
  3. package/dist/array/exists.d.mts +1 -3
  4. package/dist/array/exists.mjs +11 -6
  5. package/dist/array/filter.d.mts +1 -3
  6. package/dist/array/filter.mjs +15 -6
  7. package/dist/array/find.d.mts +1 -3
  8. package/dist/array/find.mjs +9 -5
  9. package/dist/array/first.d.mts +1 -3
  10. package/dist/array/first.mjs +10 -5
  11. package/dist/array/flatten.d.mts +1 -3
  12. package/dist/array/flatten.mjs +1 -2
  13. package/dist/array/from.d.mts +1 -3
  14. package/dist/array/from.mjs +1 -2
  15. package/dist/array/group-by.d.mts +1 -3
  16. package/dist/array/group-by.mjs +1 -2
  17. package/dist/array/index.d.mts +4 -4
  18. package/dist/array/insert.d.mts +1 -3
  19. package/dist/array/insert.mjs +2 -3
  20. package/dist/array/intersection.d.mts +1 -3
  21. package/dist/array/intersection.mjs +2 -3
  22. package/dist/array/last.d.mts +1 -3
  23. package/dist/array/last.mjs +12 -5
  24. package/dist/array/move.d.mts +1 -3
  25. package/dist/array/move.mjs +1 -2
  26. package/dist/array/partition.d.mts +1 -3
  27. package/dist/array/partition.mjs +24 -5
  28. package/dist/array/push.d.mts +0 -2
  29. package/dist/array/push.mjs +2 -3
  30. package/dist/array/reverse.d.mts +1 -3
  31. package/dist/array/reverse.mjs +1 -2
  32. package/dist/array/select.d.mts +0 -2
  33. package/dist/array/select.mjs +40 -9
  34. package/dist/array/single.d.mts +1 -3
  35. package/dist/array/single.mjs +9 -7
  36. package/dist/array/slice.d.mts +1 -3
  37. package/dist/array/slice.mjs +1 -2
  38. package/dist/array/sort.d.mts +0 -2
  39. package/dist/array/sort.mjs +2 -3
  40. package/dist/array/splice.d.mts +1 -3
  41. package/dist/array/splice.mjs +2 -3
  42. package/dist/array/swap.d.mts +0 -2
  43. package/dist/array/swap.mjs +2 -3
  44. package/dist/array/to-map.d.mts +1 -3
  45. package/dist/array/to-map.mjs +1 -2
  46. package/dist/array/to-record.d.mts +1 -3
  47. package/dist/array/to-record.mjs +1 -2
  48. package/dist/array/to-set.d.mts +1 -3
  49. package/dist/array/to-set.mjs +1 -2
  50. package/dist/array/toggle.d.mts +1 -3
  51. package/dist/array/toggle.mjs +1 -2
  52. package/dist/array/union.d.mts +1 -3
  53. package/dist/array/union.mjs +2 -3
  54. package/dist/array/unique.d.mts +1 -3
  55. package/dist/array/unique.mjs +18 -5
  56. package/dist/array/update.d.mts +1 -3
  57. package/dist/array/update.mjs +1 -2
  58. package/dist/beacon.d.mts +3 -13
  59. package/dist/beacon.mjs +10 -21
  60. package/dist/color/constants.d.mts +1 -7
  61. package/dist/color/constants.mjs +3 -11
  62. package/dist/color/index.d.mts +0 -2
  63. package/dist/color/index.mjs +4 -5
  64. package/dist/color/instance.d.mts +1 -3
  65. package/dist/color/instance.mjs +5 -8
  66. package/dist/color/misc/alpha.d.mts +1 -3
  67. package/dist/color/misc/alpha.mjs +1 -2
  68. package/dist/color/misc/format.d.mts +1 -3
  69. package/dist/color/misc/format.mjs +1 -2
  70. package/dist/color/misc/get.d.mts +1 -3
  71. package/dist/color/misc/get.mjs +2 -3
  72. package/dist/color/misc/is.d.mts +1 -11
  73. package/dist/color/misc/is.mjs +4 -16
  74. package/dist/color/misc/state.d.mts +1 -3
  75. package/dist/color/misc/state.mjs +4 -5
  76. package/dist/color/space/hex.d.mts +1 -3
  77. package/dist/color/space/hex.mjs +2 -3
  78. package/dist/color/space/hsl.d.mts +1 -3
  79. package/dist/color/space/hsl.mjs +2 -3
  80. package/dist/color/space/hwb.d.mts +1 -3
  81. package/dist/color/space/hwb.mjs +3 -4
  82. package/dist/color/space/rgb.d.mts +1 -3
  83. package/dist/color/space/rgb.mjs +1 -2
  84. package/dist/function/limit.d.mts +1 -3
  85. package/dist/function/limit.mjs +2 -3
  86. package/dist/function/once.d.mts +1 -3
  87. package/dist/function/once.mjs +8 -9
  88. package/dist/function/retry.d.mts +1 -3
  89. package/dist/function/retry.mjs +11 -12
  90. package/dist/herald.d.mts +2 -2
  91. package/dist/herald.mjs +1 -1
  92. package/dist/index.d.mts +81 -359
  93. package/dist/index.mjs +514 -661
  94. package/dist/internal/aborter.d.mts +1 -3
  95. package/dist/internal/aborter.mjs +1 -2
  96. package/dist/internal/array/callbacks.d.mts +2 -4
  97. package/dist/internal/array/callbacks.mjs +1 -2
  98. package/dist/internal/array/chunk.d.mts +1 -3
  99. package/dist/internal/array/chunk.mjs +1 -2
  100. package/dist/internal/array/compact.d.mts +1 -3
  101. package/dist/internal/array/compact.mjs +1 -2
  102. package/dist/internal/array/find.d.mts +2 -8
  103. package/dist/internal/array/find.mjs +31 -124
  104. package/dist/internal/array/get.d.mts +1 -3
  105. package/dist/internal/array/get.mjs +1 -2
  106. package/dist/internal/array/group.d.mts +1 -3
  107. package/dist/internal/array/group.mjs +1 -2
  108. package/dist/internal/array/index-of.d.mts +1 -3
  109. package/dist/internal/array/index-of.mjs +10 -5
  110. package/dist/internal/array/insert.d.mts +1 -3
  111. package/dist/internal/array/insert.mjs +2 -3
  112. package/dist/internal/array/match.d.mts +2 -4
  113. package/dist/internal/array/match.mjs +2 -3
  114. package/dist/internal/array/overlap.d.mts +1 -3
  115. package/dist/internal/array/overlap.mjs +1 -2
  116. package/dist/internal/array/sets.d.mts +1 -3
  117. package/dist/internal/array/sets.mjs +5 -6
  118. package/dist/internal/array/shuffle.d.mts +1 -3
  119. package/dist/internal/array/shuffle.mjs +1 -2
  120. package/dist/internal/array/update.d.mts +1 -3
  121. package/dist/internal/array/update.mjs +1 -2
  122. package/dist/internal/defaults.d.mts +1 -3
  123. package/dist/internal/defaults.mjs +1 -2
  124. package/dist/internal/function/assert.d.mts +1 -3
  125. package/dist/internal/function/assert.mjs +1 -2
  126. package/dist/internal/function/limit.d.mts +2 -4
  127. package/dist/internal/function/limit.mjs +8 -9
  128. package/dist/internal/function/memoize.d.mts +1 -3
  129. package/dist/internal/function/memoize.mjs +4 -5
  130. package/dist/internal/function/misc.d.mts +1 -2
  131. package/dist/internal/function/misc.mjs +7 -3
  132. package/dist/internal/function/work.d.mts +1 -3
  133. package/dist/internal/function/work.mjs +5 -13
  134. package/dist/internal/herald.d.mts +2 -12
  135. package/dist/internal/herald.mjs +9 -33
  136. package/dist/internal/is.d.mts +1 -3
  137. package/dist/internal/is.mjs +1 -2
  138. package/dist/internal/math/aggregate.d.mts +1 -3
  139. package/dist/internal/math/aggregate.mjs +2 -3
  140. package/dist/internal/math/misc.d.mts +1 -3
  141. package/dist/internal/math/misc.mjs +1 -2
  142. package/dist/internal/number.d.mts +1 -3
  143. package/dist/internal/number.mjs +2 -3
  144. package/dist/internal/plan/index.d.mts +1 -3
  145. package/dist/internal/plan/index.mjs +2 -3
  146. package/dist/internal/plan/plan.generate.d.mts +1 -3
  147. package/dist/internal/plan/plan.generate.mjs +67 -22
  148. package/dist/internal/random.d.mts +1 -3
  149. package/dist/internal/random.mjs +1 -2
  150. package/dist/internal/result/attempt.d.mts +1 -3
  151. package/dist/internal/result/attempt.mjs +1 -2
  152. package/dist/internal/result/misc.d.mts +1 -3
  153. package/dist/internal/result/misc.mjs +1 -2
  154. package/dist/internal/sized/map.d.mts +4 -3
  155. package/dist/internal/sized/map.mjs +4 -2
  156. package/dist/internal/sized/misc.d.mts +1 -3
  157. package/dist/internal/sized/misc.mjs +1 -2
  158. package/dist/internal/string/case.d.mts +1 -3
  159. package/dist/internal/string/case.mjs +3 -4
  160. package/dist/internal/string/misc.d.mts +1 -3
  161. package/dist/internal/string/misc.mjs +1 -2
  162. package/dist/internal/subscription.d.mts +1 -3
  163. package/dist/internal/subscription.mjs +16 -29
  164. package/dist/internal/value/compare.d.mts +1 -3
  165. package/dist/internal/value/compare.mjs +2 -3
  166. package/dist/internal/value/equal.d.mts +1 -3
  167. package/dist/internal/value/equal.mjs +3 -4
  168. package/dist/internal/value/get.d.mts +1 -3
  169. package/dist/internal/value/get.mjs +1 -2
  170. package/dist/internal/value/handlers.d.mts +1 -3
  171. package/dist/internal/value/handlers.mjs +1 -2
  172. package/dist/internal/value/has.d.mts +1 -3
  173. package/dist/internal/value/has.mjs +1 -2
  174. package/dist/internal/value/misc.d.mts +1 -3
  175. package/dist/internal/value/misc.mjs +2 -3
  176. package/dist/internal/value/partial.d.mts +1 -3
  177. package/dist/internal/value/partial.mjs +1 -2
  178. package/dist/internal/value/set.d.mts +1 -3
  179. package/dist/internal/value/set.mjs +2 -3
  180. package/dist/is.d.mts +0 -2
  181. package/dist/is.mjs +2 -3
  182. package/dist/logger.d.mts +0 -2
  183. package/dist/logger.mjs +7 -7
  184. package/dist/math.d.mts +0 -2
  185. package/dist/math.mjs +2 -3
  186. package/dist/models/aborter.model.d.mts +1 -3
  187. package/dist/models/aborter.model.mjs +1 -2
  188. package/dist/models/array/array.match.model.d.mts +1 -3
  189. package/dist/models/array/array.match.model.mjs +1 -2
  190. package/dist/models/array/array.misc.model.d.mts +11 -2
  191. package/dist/models/array/array.misc.model.mjs +3 -3
  192. package/dist/models/array/array.sort.model.d.mts +1 -3
  193. package/dist/models/array/array.sort.model.mjs +1 -2
  194. package/dist/models/beacon.model.d.mts +4 -6
  195. package/dist/models/beacon.model.mjs +3 -10
  196. package/dist/models/color.model.d.mts +2 -4
  197. package/dist/models/function/assert.model.d.mts +1 -3
  198. package/dist/models/function/assert.model.mjs +1 -2
  199. package/dist/models/function/limiter.model.d.mts +2 -4
  200. package/dist/models/function/limiter.model.mjs +2 -4
  201. package/dist/models/function/memoize.model.d.mts +2 -4
  202. package/dist/models/function/memoize.model.mjs +1 -2
  203. package/dist/models/function/once.model.d.mts +0 -3
  204. package/dist/models/function/once.model.mjs +3 -5
  205. package/dist/models/function/retry.model.d.mts +1 -3
  206. package/dist/models/function/retry.model.mjs +1 -2
  207. package/dist/models/function/work.model.d.mts +2 -4
  208. package/dist/models/function/work.model.mjs +1 -2
  209. package/dist/models/herald.model.d.mts +8 -7
  210. package/dist/models/herald.model.mjs +3 -10
  211. package/dist/models/index.d.mts +0 -2
  212. package/dist/models/logger.model.d.mts +1 -4
  213. package/dist/models/logger.model.mjs +3 -5
  214. package/dist/models/math.model.d.mts +1 -3
  215. package/dist/models/math.model.mjs +1 -2
  216. package/dist/models/misc.model.d.mts +1 -3
  217. package/dist/models/misc.model.mjs +1 -2
  218. package/dist/models/plan.model.d.mts +35 -37
  219. package/dist/models/plan.model.mjs +1 -2
  220. package/dist/models/promise.model.d.mts +8 -10
  221. package/dist/models/promise.model.mjs +4 -5
  222. package/dist/models/query.model.d.mts +1 -3
  223. package/dist/models/query.model.mjs +1 -2
  224. package/dist/models/queue.model.d.mts +0 -3
  225. package/dist/models/queue.model.mjs +3 -5
  226. package/dist/models/random.model.d.mts +1 -3
  227. package/dist/models/random.model.mjs +1 -2
  228. package/dist/models/result.model.d.mts +0 -2
  229. package/dist/models/string/string.case.model.d.mts +1 -3
  230. package/dist/models/string/string.case.model.mjs +1 -2
  231. package/dist/models/string/string.fuzzy.model.d.mts +0 -3
  232. package/dist/models/string/string.fuzzy.model.mjs +3 -5
  233. package/dist/models/string/string.misc.model.d.mts +1 -3
  234. package/dist/models/string/string.misc.model.mjs +1 -2
  235. package/dist/models/string/string.normalize.model.d.mts +1 -3
  236. package/dist/models/string/string.normalize.model.mjs +1 -2
  237. package/dist/models/string/string.template.model.d.mts +1 -3
  238. package/dist/models/string/string.template.model.mjs +1 -2
  239. package/dist/models/subscription.model.d.mts +4 -23
  240. package/dist/models/subscription.model.mjs +3 -5
  241. package/dist/models/value/value.clone.model.d.mts +1 -3
  242. package/dist/models/value/value.clone.model.mjs +1 -2
  243. package/dist/models/value/value.diff.model.d.mts +1 -3
  244. package/dist/models/value/value.diff.model.mjs +1 -2
  245. package/dist/models/value/value.equal.model.d.mts +0 -2
  246. package/dist/models/value/value.equal.model.mjs +1 -2
  247. package/dist/models/value/value.handler.model.d.mts +1 -3
  248. package/dist/models/value/value.merge.model.d.mts +0 -2
  249. package/dist/models/value/value.merge.model.mjs +1 -2
  250. package/dist/models/value/value.misc.model.d.mts +0 -2
  251. package/dist/models/value/value.misc.model.mjs +1 -2
  252. package/dist/models/value/value.transform.model.d.mts +1 -3
  253. package/dist/models/value/value.transform.model.mjs +1 -2
  254. package/dist/plan/index.d.mts +1 -3
  255. package/dist/plan/index.mjs +2 -3
  256. package/dist/plan/is.d.mts +1 -3
  257. package/dist/plan/is.mjs +1 -2
  258. package/dist/plan/misc.d.mts +1 -3
  259. package/dist/plan/misc.mjs +2 -3
  260. package/dist/plan/models.d.mts +2 -2
  261. package/dist/plan/result.d.mts +8 -10
  262. package/dist/plan/result.mjs +2 -3
  263. package/dist/plan/run.d.mts +8 -10
  264. package/dist/plan/run.mjs +2 -3
  265. package/dist/plan/use.d.mts +1 -3
  266. package/dist/plan/use.mjs +14 -9
  267. package/dist/promise/delay.d.mts +1 -3
  268. package/dist/promise/delay.mjs +2 -3
  269. package/dist/promise/helpers.d.mts +1 -3
  270. package/dist/promise/helpers.mjs +2 -3
  271. package/dist/promise/index.d.mts +0 -2
  272. package/dist/promise/index.mjs +5 -6
  273. package/dist/promise/misc.d.mts +1 -3
  274. package/dist/promise/misc.mjs +2 -3
  275. package/dist/promise/models.d.mts +2 -2
  276. package/dist/promise/models.mjs +1 -1
  277. package/dist/promise/timed.d.mts +1 -3
  278. package/dist/promise/timed.mjs +4 -5
  279. package/dist/query.d.mts +1 -3
  280. package/dist/query.mjs +2 -3
  281. package/dist/queue.d.mts +0 -2
  282. package/dist/queue.mjs +11 -12
  283. package/dist/random.d.mts +0 -2
  284. package/dist/random.mjs +2 -3
  285. package/dist/result/match.d.mts +1 -3
  286. package/dist/result/match.mjs +1 -2
  287. package/dist/result/misc.d.mts +0 -2
  288. package/dist/result/misc.mjs +1 -2
  289. package/dist/result/work/flow.d.mts +1 -3
  290. package/dist/result/work/flow.mjs +5 -12
  291. package/dist/result/work/pipe.d.mts +0 -2
  292. package/dist/result/work/pipe.mjs +2 -3
  293. package/dist/sized/set.d.mts +4 -3
  294. package/dist/sized/set.mjs +4 -2
  295. package/dist/string/fuzzy.d.mts +0 -2
  296. package/dist/string/fuzzy.mjs +5 -7
  297. package/dist/string/index.d.mts +0 -2
  298. package/dist/string/index.mjs +2 -3
  299. package/dist/string/match.d.mts +1 -3
  300. package/dist/string/match.mjs +2 -3
  301. package/dist/string/normalize.d.mts +0 -2
  302. package/dist/string/normalize.mjs +3 -4
  303. package/dist/string/template.d.mts +0 -2
  304. package/dist/string/template.mjs +1 -2
  305. package/dist/subscription.d.mts +2 -2
  306. package/dist/value/clone.d.mts +1 -3
  307. package/dist/value/clone.mjs +2 -3
  308. package/dist/value/collection.d.mts +1 -3
  309. package/dist/value/collection.mjs +1 -2
  310. package/dist/value/diff.d.mts +0 -2
  311. package/dist/value/diff.mjs +1 -2
  312. package/dist/value/freeze.d.mts +1 -3
  313. package/dist/value/freeze.mjs +1 -2
  314. package/dist/value/handle.mjs +1 -1
  315. package/dist/value/merge.d.mts +0 -2
  316. package/dist/value/merge.mjs +1 -2
  317. package/dist/value/omit.d.mts +1 -3
  318. package/dist/value/omit.mjs +1 -2
  319. package/dist/value/pick.d.mts +1 -3
  320. package/dist/value/pick.mjs +1 -2
  321. package/dist/value/shake.d.mts +0 -2
  322. package/dist/value/shake.mjs +1 -2
  323. package/dist/value/smush.d.mts +0 -2
  324. package/dist/value/smush.mjs +2 -3
  325. package/dist/value/transform.d.mts +0 -2
  326. package/dist/value/transform.mjs +1 -2
  327. package/dist/value/unsmush.d.mts +0 -2
  328. package/dist/value/unsmush.mjs +1 -2
  329. package/package.json +6 -6
  330. package/dist/models/array/array.find.model.d.mts +0 -48
  331. package/dist/models/array/array.find.model.mjs +0 -8
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/difference.d.ts
3
2
  /**
4
3
  * Get the items from the first array that are not in the second array
5
4
  *
@@ -51,5 +50,4 @@ export declare function difference<First extends PlainObject, Second extends Pla
51
50
  * ); // => [1, 3]
52
51
  * ```
53
52
  */
54
- export declare function difference<First, Second>(first: First[], second: Second[]): First[];
55
- //#endregion
53
+ export declare function difference<First, Second>(first: First[], second: Second[]): First[];
@@ -1,8 +1,7 @@
1
- import { ARRAY_SETS_COMPARE_DIFFERENCE } from "../models/array/array.misc.model.mjs";
2
1
  import { compareSets } from "../internal/array/sets.mjs";
3
- //#region src/array/difference.ts
2
+ import { ARRAY_SETS_COMPARE_DIFFERENCE } from "../models/array/array.misc.model.mjs";
3
+ // src/array/difference.ts
4
4
  function difference(first, second, key) {
5
5
  return compareSets(ARRAY_SETS_COMPARE_DIFFERENCE, first, second, key);
6
6
  }
7
- //#endregion
8
7
  export { difference };
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/exists.d.ts
3
2
  /**
4
3
  * Does an item with a specific value exist in the array?
5
4
  *
@@ -64,5 +63,4 @@ export declare function exists<Item>(array: Item[], filter: (item: Item, index:
64
63
  * exists([1, 2, 3], 2); // => true
65
64
  * ```
66
65
  */
67
- export declare function exists<Item>(array: Item[], item: Item): boolean;
68
- //#endregion
66
+ export declare function exists<Item>(array: Item[], item: Item): boolean;
@@ -1,9 +1,14 @@
1
- import { ARRAY_FIND_VALUE_INDEX } from "../models/array/array.find.model.mjs";
2
- import { findValue } from "../internal/array/find.mjs";
3
- //#region src/array/exists.ts
1
+ // src/array/exists.ts
4
2
  function exists(array, ...parameters) {
5
- if (parameters.length === 1 && typeof parameters[0] !== "function") return Array.isArray(array) ? array.includes(parameters[0]) : false;
6
- return findValue(ARRAY_FIND_VALUE_INDEX, array, parameters, false) > -1;
3
+ if (!Array.isArray(array)) return false;
4
+ if (array.length === 0) return false;
5
+ const [first, second] = parameters;
6
+ const { length } = parameters;
7
+ if (length === 1) return typeof first === "function" ? array.some((item, index, array) => first(item, index, array)) : array.includes(first);
8
+ let callback;
9
+ if (typeof first === "function") callback = first;
10
+ else if (typeof first === "number" || typeof first === "string") callback = (item) => item[first];
11
+ if (callback == null) return false;
12
+ return array.some((item, index, array) => Object.is(callback(item, index, array), second));
7
13
  }
8
- //#endregion
9
14
  export { exists };
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/filter.d.ts
3
2
  /**
4
3
  * Get a filtered array of items that do not match the value
5
4
  *
@@ -174,5 +173,4 @@ export declare function filter<Item>(array: Item[], filter: (item: Item, index:
174
173
  export declare function filter<Item>(array: Item[], item: Item): Item[];
175
174
  export declare namespace filter {
176
175
  export var remove: typeof exclude;
177
- }
178
- //#endregion
176
+ }
@@ -1,12 +1,21 @@
1
- import "../models/array/array.find.model.mjs";
2
- import { findValues } from "../internal/array/find.mjs";
3
- //#region src/array/filter.ts
1
+ // src/array/filter.ts
4
2
  function exclude(array, ...parameters) {
5
- return findValues("all", array, parameters).notMatched;
3
+ return filterValues(array, parameters, false);
6
4
  }
7
5
  function filter(array, ...parameters) {
8
- return findValues("all", array, parameters).matched;
6
+ return filterValues(array, parameters, true);
7
+ }
8
+ function filterValues(array, parameters, include) {
9
+ if (!Array.isArray(array)) return [];
10
+ if (array.length === 0) return [];
11
+ const [first, second] = parameters;
12
+ const { length } = parameters;
13
+ if (length === 1) return typeof first === "function" ? array.filter((item, index, array) => first(item, index, array) === include) : array.filter((item) => Object.is(item, first) === include);
14
+ let callback;
15
+ if (typeof first === "function") callback = first;
16
+ else if (typeof first === "number" || typeof first === "string") callback = (item) => item[first];
17
+ if (callback == null) return [];
18
+ return array.filter((item, index, array) => Object.is(callback(item, index, array), second) === include);
9
19
  }
10
20
  filter.remove = exclude;
11
- //#endregion
12
21
  export { exclude, filter };
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/find.d.ts
3
2
  /**
4
3
  * Get the first item matching the given value
5
4
  *
@@ -174,5 +173,4 @@ export declare function findLast<Item>(array: Item[], filter: (item: Item, index
174
173
  export declare function findLast<Item>(array: Item[], value: Item): Item | undefined;
175
174
  export declare namespace find {
176
175
  export var last: typeof findLast;
177
- }
178
- //#endregion
176
+ }
@@ -1,12 +1,16 @@
1
- import { ARRAY_FIND_VALUE_ITEM } from "../models/array/array.find.model.mjs";
2
1
  import { findValue } from "../internal/array/find.mjs";
3
- //#region src/array/find.ts
2
+ // src/array/find.ts
4
3
  function find(array, ...parameters) {
5
- return findValue(ARRAY_FIND_VALUE_ITEM, array, parameters, false);
4
+ return findValue(array, {
5
+ input: parameters,
6
+ reverse: false
7
+ })?.values[0];
6
8
  }
7
9
  function findLast(array, ...parameters) {
8
- return findValue(ARRAY_FIND_VALUE_ITEM, array, parameters, true);
10
+ return findValue(array, {
11
+ input: parameters,
12
+ reverse: true
13
+ })?.values[0];
9
14
  }
10
15
  find.last = findLast;
11
- //#endregion
12
16
  export { find, findLast };
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/first.d.ts
3
2
  /**
4
3
  * Get the first item matching the given value
5
4
  *
@@ -183,5 +182,4 @@ export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item,
183
182
  export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item): Item;
184
183
  export declare namespace first {
185
184
  export var defaulted: typeof firstOrDefault;
186
- }
187
- //#endregion
185
+ }
@@ -1,11 +1,16 @@
1
- import { findAbsoluteValueOrDefault } from "../internal/array/find.mjs";
2
- //#region src/array/first.ts
1
+ import { findValue } from "../internal/array/find.mjs";
2
+ // src/array/first.ts
3
3
  function first(array, ...parameters) {
4
- return findAbsoluteValueOrDefault(array, parameters, void 0, false, false);
4
+ return findValue(array, {
5
+ bare: true,
6
+ input: parameters
7
+ })?.values[0];
5
8
  }
6
9
  function firstOrDefault(array, defaultValue, ...parameters) {
7
- return findAbsoluteValueOrDefault(array, parameters, defaultValue, true, false);
10
+ return findValue(array, {
11
+ bare: true,
12
+ input: parameters
13
+ })?.values[0] ?? defaultValue;
8
14
  }
9
15
  first.defaulted = firstOrDefault;
10
- //#endregion
11
16
  export { first, firstOrDefault };
@@ -1,5 +1,4 @@
1
1
  import { NestedArray } from "../models/index.mjs";
2
- //#region src/array/flatten.d.ts
3
2
  /**
4
3
  * Flatten an array _(using native `flat` and maximum depth)_
5
4
  *
@@ -11,5 +10,4 @@ import { NestedArray } from "../models/index.mjs";
11
10
  * flatten([1, [2, [3, 4], 5], 6]); // => [1, 2, 3, 4, 5, 6]
12
11
  * ```
13
12
  */
14
- export declare function flatten<Item>(array: Item[]): Array<NestedArray<Item>>;
15
- //#endregion
13
+ export declare function flatten<Item>(array: Item[]): Array<NestedArray<Item>>;
@@ -1,4 +1,4 @@
1
- //#region src/array/flatten.ts
1
+ // src/array/flatten.ts
2
2
  /**
3
3
  * Flatten an array _(using native `flat` and maximum depth)_
4
4
  *
@@ -13,5 +13,4 @@
13
13
  function flatten(array) {
14
14
  return Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : [];
15
15
  }
16
- //#endregion
17
16
  export { flatten };
@@ -1,4 +1,3 @@
1
- //#region src/array/from.d.ts
2
1
  /**
3
2
  * Get an array with a specified length, filled with indices
4
3
  *
@@ -75,5 +74,4 @@ export declare function times<Callback extends (index: number) => unknown>(lengt
75
74
  * times(5, 'a'); // => ['a', 'a', 'a', 'a', 'a']
76
75
  * ```
77
76
  */
78
- export declare function times<Value>(length: number, value: Value): Value[];
79
- //#endregion
77
+ export declare function times<Value>(length: number, value: Value): Value[];
@@ -1,4 +1,4 @@
1
- //#region src/array/from.ts
1
+ // src/array/from.ts
2
2
  function range(first, second, third) {
3
3
  const start = typeof second === "number" ? first : 0;
4
4
  const end = typeof second === "number" ? second : first;
@@ -16,5 +16,4 @@ function times(length, value) {
16
16
  for (let index = 0; index < length; index += 1) values.push(isFunction ? value(index) : value ?? index);
17
17
  return values;
18
18
  }
19
- //#endregion
20
19
  export { range, times };
@@ -1,5 +1,4 @@
1
1
  import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue, Simplify } from "../models/index.mjs";
2
- //#region src/array/group-by.d.ts
3
2
  /**
4
3
  * Create a record from an array of items using a specific key
5
4
  *
@@ -98,5 +97,4 @@ export declare function groupArraysBy<Item, KeyArg extends KeyOrCallback<Item, K
98
97
  export declare function groupArraysBy<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
99
98
  export declare namespace groupBy {
100
99
  export var arrays: typeof groupArraysBy;
101
- }
102
- //#endregion
100
+ }
@@ -1,5 +1,5 @@
1
1
  import { groupValues } from "../internal/array/group.mjs";
2
- //#region src/array/group-by.ts
2
+ // src/array/group-by.ts
3
3
  function groupBy(array, first, second) {
4
4
  return groupValues(array, first, second, false);
5
5
  }
@@ -7,5 +7,4 @@ function groupArraysBy(array, first, second) {
7
7
  return groupValues(array, first, second, true);
8
8
  }
9
9
  groupBy.arrays = groupArraysBy;
10
- //#endregion
11
10
  export { groupArraysBy, groupBy };
@@ -1,12 +1,12 @@
1
- import { difference } from "./difference.mjs";
2
- import { exists } from "./exists.mjs";
3
- import { flatten } from "./flatten.mjs";
4
- import { range, times } from "./from.mjs";
5
1
  import { chunk } from "../internal/array/chunk.mjs";
6
2
  import { compact } from "../internal/array/compact.mjs";
7
3
  import { getArray } from "../internal/array/get.mjs";
8
4
  import { endsWithArray, getArrayComparison, includesArray, indexOfArray, startsWithArray } from "../internal/array/match.mjs";
9
5
  import { shuffle } from "../internal/array/shuffle.mjs";
6
+ import { difference } from "./difference.mjs";
7
+ import { exists } from "./exists.mjs";
8
+ import { flatten } from "./flatten.mjs";
9
+ import { range, times } from "./from.mjs";
10
10
  import { insert } from "./insert.mjs";
11
11
  import { intersection } from "./intersection.mjs";
12
12
  import { partition } from "./partition.mjs";
@@ -1,4 +1,3 @@
1
- //#region src/array/insert.d.ts
2
1
  /**
3
2
  * Insert items into an array at a specified index
4
3
  *
@@ -29,5 +28,4 @@ export declare function insert<Item>(array: Item[], index: number, items: Item[]
29
28
  * insert([1, 2, 3], [4, 5]); // => [1, 2, 3, 4, 5]
30
29
  * ```
31
30
  */
32
- export declare function insert<Item>(array: Item[], items: Item[]): Item[];
33
- //#endregion
31
+ export declare function insert<Item>(array: Item[], items: Item[]): Item[];
@@ -1,8 +1,7 @@
1
- import { ARRAY_INSERT_TYPE_INSERT } from "../models/array/array.misc.model.mjs";
2
1
  import { insertValues } from "../internal/array/insert.mjs";
3
- //#region src/array/insert.ts
2
+ import { ARRAY_INSERT_TYPE_INSERT } from "../models/array/array.misc.model.mjs";
3
+ // src/array/insert.ts
4
4
  function insert(array, indexOrItems, items) {
5
5
  return insertValues(ARRAY_INSERT_TYPE_INSERT, array, items ?? indexOrItems, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
6
6
  }
7
- //#endregion
8
7
  export { insert };
@@ -1,4 +1,3 @@
1
- //#region src/array/intersection.d.ts
2
1
  /**
3
2
  * Get the common values between two arrays
4
3
  *
@@ -50,5 +49,4 @@ export declare function intersection<First extends Record<string, unknown>, Seco
50
49
  * ); // => [2, 3]
51
50
  * ```
52
51
  */
53
- export declare function intersection<First, Second>(first: First[], second: Second[]): First[];
54
- //#endregion
52
+ export declare function intersection<First, Second>(first: First[], second: Second[]): First[];
@@ -1,8 +1,7 @@
1
- import { ARRAY_SETS_COMPARE_INTERSECTION } from "../models/array/array.misc.model.mjs";
2
1
  import { compareSets } from "../internal/array/sets.mjs";
3
- //#region src/array/intersection.ts
2
+ import { ARRAY_SETS_COMPARE_INTERSECTION } from "../models/array/array.misc.model.mjs";
3
+ // src/array/intersection.ts
4
4
  function intersection(first, second, key) {
5
5
  return compareSets(ARRAY_SETS_COMPARE_INTERSECTION, first, second, key);
6
6
  }
7
- //#endregion
8
7
  export { intersection };
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/last.d.ts
3
2
  /**
4
3
  * Get the last item matching the given value
5
4
  *
@@ -181,5 +180,4 @@ export declare function lastOrDefault<Item>(array: Item[], defaultValue: Item, f
181
180
  export declare function lastOrDefault<Item>(array: Item[], defaultValue: Item): Item;
182
181
  export declare namespace last {
183
182
  export var defaulted: typeof lastOrDefault;
184
- }
185
- //#endregion
183
+ }
@@ -1,11 +1,18 @@
1
- import { findAbsoluteValueOrDefault } from "../internal/array/find.mjs";
2
- //#region src/array/last.ts
1
+ import { findValue } from "../internal/array/find.mjs";
2
+ // src/array/last.ts
3
3
  function last(array, ...parameters) {
4
- return findAbsoluteValueOrDefault(array, parameters, void 0, false, true);
4
+ return findValue(array, {
5
+ bare: true,
6
+ input: parameters,
7
+ reverse: true
8
+ })?.values[0];
5
9
  }
6
10
  function lastOrDefault(array, defaultValue, ...parameters) {
7
- return findAbsoluteValueOrDefault(array, parameters, defaultValue, true, true);
11
+ return findValue(array, {
12
+ bare: true,
13
+ input: parameters,
14
+ reverse: true
15
+ })?.values[0] ?? defaultValue;
8
16
  }
9
17
  last.defaulted = lastOrDefault;
10
- //#endregion
11
18
  export { last, lastOrDefault };
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/move.d.ts
3
2
  /**
4
3
  * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
5
4
  *
@@ -161,5 +160,4 @@ export declare function moveToIndex<Item>(array: Item[], value: Item | Item[], i
161
160
  export declare namespace move {
162
161
  export var indices: typeof moveIndices;
163
162
  export var toIndex: typeof moveToIndex;
164
- }
165
- //#endregion
163
+ }
@@ -1,6 +1,6 @@
1
1
  import { indexOfArray } from "../internal/array/match.mjs";
2
2
  import { arraysOverlap } from "../internal/array/overlap.mjs";
3
- //#region src/array/move.ts
3
+ // src/array/move.ts
4
4
  function move(array, from, to, key) {
5
5
  if (!Array.isArray(array)) return [];
6
6
  const firstArray = Array.isArray(from) ? from : [from];
@@ -72,5 +72,4 @@ function moveToIndex(array, value, index, key) {
72
72
  }
73
73
  move.indices = moveIndices;
74
74
  move.toIndex = moveToIndex;
75
- //#endregion
76
75
  export { move, moveIndices, moveToIndex };
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/partition.d.ts
3
2
  /**
4
3
  * Get a partitioned array of items
5
4
  *
@@ -80,5 +79,4 @@ export declare function partition<Item>(array: Item[], filter: (item: Item, inde
80
79
  * partition([1, 2, 3, 4, 5], 3); // => [[3], [1, 2, 4, 5]]
81
80
  * ```
82
81
  */
83
- export declare function partition<Item>(array: Item[], item: Item): [Item[], Item[]];
84
- //#endregion
82
+ export declare function partition<Item>(array: Item[], item: Item): [Item[], Item[]];
@@ -1,9 +1,28 @@
1
- import "../models/array/array.find.model.mjs";
2
- import { findValues } from "../internal/array/find.mjs";
3
- //#region src/array/partition.ts
1
+ // src/array/partition.ts
2
+ function getCallback(first, second, length) {
3
+ if (length === 1 && typeof first === "function") return first;
4
+ switch (true) {
5
+ case length === 1: return (item) => Object.is(item, first);
6
+ case typeof first === "function": return (item, index, array) => Object.is(first(item, index, array), second);
7
+ case typeof first === "number" || typeof first === "string": return (item) => Object.is(item[first], second);
8
+ default: return;
9
+ }
10
+ }
4
11
  function partition(array, ...parameters) {
5
- const { matched, notMatched } = findValues("all", array, parameters);
12
+ if (!Array.isArray(array)) return [[], []];
13
+ const arrayLength = array.length;
14
+ if (arrayLength === 0) return [[], []];
15
+ const parametersLength = parameters.length;
16
+ const [first, second] = parameters;
17
+ const callback = getCallback(first, second, parametersLength);
18
+ if (callback == null) return [[], []];
19
+ const matched = [];
20
+ const notMatched = [];
21
+ for (let index = 0; index < arrayLength; index += 1) {
22
+ const item = array[index];
23
+ if (callback(item, index, array)) matched.push(item);
24
+ else notMatched.push(item);
25
+ }
6
26
  return [matched, notMatched];
7
27
  }
8
- //#endregion
9
28
  export { partition };
@@ -1,4 +1,3 @@
1
- //#region src/array/push.d.ts
2
1
  /**
3
2
  * Push items into an array _(at the end)_
4
3
  *
@@ -14,5 +13,4 @@
14
13
  * ```
15
14
  */
16
15
  export declare function push<Item>(array: Item[], pushed: Item[]): number;
17
- //#endregion
18
16
  export { push as append };
@@ -1,6 +1,6 @@
1
- import { ARRAY_INSERT_TYPE_PUSH } from "../models/array/array.misc.model.mjs";
2
1
  import { insertValues } from "../internal/array/insert.mjs";
3
- //#region src/array/push.ts
2
+ import { ARRAY_INSERT_TYPE_PUSH } from "../models/array/array.misc.model.mjs";
3
+ // src/array/push.ts
4
4
  /**
5
5
  * Push items into an array _(at the end)_
6
6
  *
@@ -18,5 +18,4 @@ import { insertValues } from "../internal/array/insert.mjs";
18
18
  function push(array, pushed) {
19
19
  return insertValues(ARRAY_INSERT_TYPE_PUSH, array, pushed, array.length, 0);
20
20
  }
21
- //#endregion
22
21
  export { push as append, push };
@@ -1,4 +1,3 @@
1
- //#region src/array/reverse.d.ts
2
1
  /**
3
2
  * Reverse the order of items in an array
4
3
  *
@@ -11,5 +10,4 @@
11
10
  * reverse(['a', 'b', 'c']); // => ['c', 'b', 'a']
12
11
  * ```
13
12
  */
14
- export declare function reverse<Item>(array: Item[]): Item[];
15
- //#endregion
13
+ export declare function reverse<Item>(array: Item[]): Item[];
@@ -1,5 +1,5 @@
1
1
  import { floor } from "../internal/math/misc.mjs";
2
- //#region src/array/reverse.ts
2
+ // src/array/reverse.ts
3
3
  /**
4
4
  * Reverse the order of items in an array
5
5
  *
@@ -25,5 +25,4 @@ function reverse(array) {
25
25
  }
26
26
  return array;
27
27
  }
28
- //#endregion
29
28
  export { reverse };
@@ -1,5 +1,4 @@
1
1
  import { ArrayFlattened } from "../models/array/array.misc.model.mjs";
2
- //#region src/array/select.d.ts
3
2
  /**
4
3
  * Get a narrowed, mapped, and flattened array of items
5
4
  *
@@ -167,5 +166,4 @@ export declare namespace filterAndMap {
167
166
  export declare namespace mapAndFilter {
168
167
  export var flat: typeof flatMapAndFilter;
169
168
  }
170
- //#endregion
171
169
  export { filterAndMap as select, mapAndFilter as reverseSelect };
@@ -1,6 +1,4 @@
1
- import "../models/array/array.find.model.mjs";
2
- import { findValues } from "../internal/array/find.mjs";
3
- //#region src/array/select.ts
1
+ // src/array/select.ts
4
2
  function filterAndFlatMap(array, filter, mapper) {
5
3
  return selectValues(array, filter, mapper, true, false);
6
4
  }
@@ -13,15 +11,48 @@ function flatMapAndFilter(array, mapper, filter) {
13
11
  function mapAndFilter(array, mapper, filter) {
14
12
  return selectValues(array, filter, mapper, false, true);
15
13
  }
14
+ function selectBareValues(array, length, filter, mapper, reverse) {
15
+ const selected = [];
16
+ for (let index = 0; index < length; index += 1) {
17
+ const item = array[index];
18
+ const mapped = reverse ? mapper(item, index, array) : item;
19
+ if (filter(mapped, index, array)) selected.push(reverse ? mapped : mapper(item, index, array));
20
+ }
21
+ return selected;
22
+ }
23
+ function selectFlatValues(array, arrayLength, filter, mapper, reverse) {
24
+ if (reverse) return selectFlatValuesReversed(array, arrayLength, filter, mapper);
25
+ const selected = [];
26
+ for (let arrayIndex = 0; arrayIndex < arrayLength; arrayIndex += 1) {
27
+ const item = array[arrayIndex];
28
+ if (!filter(item, arrayIndex, array)) continue;
29
+ const mapped = mapper(item, arrayIndex, array);
30
+ if (Array.isArray(mapped)) selected.push(...mapped);
31
+ else selected.push(mapped);
32
+ }
33
+ return selected;
34
+ }
35
+ function selectFlatValuesReversed(array, arrayLength, filter, mapper) {
36
+ const selected = [];
37
+ for (let arrayIndex = 0; arrayIndex < arrayLength; arrayIndex += 1) {
38
+ const item = array[arrayIndex];
39
+ const mapped = mapper(item, arrayIndex, array);
40
+ const items = Array.isArray(mapped) ? mapped : [mapped];
41
+ const itemsLength = items.length;
42
+ for (let itemsIndex = 0; itemsIndex < itemsLength; itemsIndex += 1) {
43
+ const item = items[itemsIndex];
44
+ if (filter(item, arrayIndex, array)) selected.push(item);
45
+ }
46
+ }
47
+ return selected;
48
+ }
16
49
  function selectValues(array, filter, mapper, flat, reverse) {
17
- return findValues("all", array, [filter], { map: {
18
- flat,
19
- reverse,
20
- callback: mapper
21
- } }).matched;
50
+ if (!Array.isArray(array) || typeof filter !== "function" || typeof mapper !== "function") return [];
51
+ const { length } = array;
52
+ if (length === 0) return [];
53
+ return flat ? selectFlatValues(array, length, filter, mapper, reverse) : selectBareValues(array, length, filter, mapper, reverse);
22
54
  }
23
55
  filterAndMap.flat = filterAndFlatMap;
24
56
  filterAndMap.reverse = mapAndFilter;
25
57
  mapAndFilter.flat = flatMapAndFilter;
26
- //#endregion
27
58
  export { filterAndFlatMap, filterAndMap, filterAndMap as select, flatMapAndFilter, mapAndFilter, mapAndFilter as reverseSelect };
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/single.d.ts
3
2
  /**
4
3
  * Get the _only_ item matching the given value
5
4
  *
@@ -79,5 +78,4 @@ export declare function single<Item, Narrowed extends Item>(array: Item[], filte
79
78
  * ); // => {id: 2}
80
79
  * ```
81
80
  */
82
- export declare function single<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
83
- //#endregion
81
+ export declare function single<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
@@ -1,11 +1,13 @@
1
- import "../models/array/array.find.model.mjs";
2
- import { findValues } from "../internal/array/find.mjs";
3
- //#region src/array/single.ts
1
+ import { findValue } from "../internal/array/find.mjs";
2
+ // src/array/single.ts
4
3
  function single(array, ...parameters) {
5
- const { matched } = findValues("all", array, parameters, { limit: 2 });
6
- if (matched.length > 1) throw new Error(SINGLE_MESSAGE);
7
- return matched[0];
4
+ const result = findValue(array, {
5
+ input: parameters,
6
+ limit: 2
7
+ });
8
+ if (result == null) return;
9
+ if (result.values.length > 1) throw new Error(SINGLE_MESSAGE);
10
+ return result.values[0];
8
11
  }
9
12
  const SINGLE_MESSAGE = "Multiple items were found";
10
- //#endregion
11
13
  export { single };
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models/index.mjs";
2
- //#region src/array/slice.d.ts
3
2
  /**
4
3
  * Drop items from the start of an array until they match a value
5
4
  *
@@ -170,5 +169,4 @@ export declare function take<Item extends PlainObject>(array: Item[], callback:
170
169
  * take([1, 2, 3, 4, 5], -2); // => [4, 5]
171
170
  * ```
172
171
  */
173
- export declare function take(array: unknown[], count: number): unknown[];
174
- //#endregion
172
+ export declare function take(array: unknown[], count: number): unknown[];
@@ -1,6 +1,6 @@
1
1
  import { getArrayCallbacks } from "../internal/array/callbacks.mjs";
2
2
  import { ARRAY_SLICE_DROP, ARRAY_SLICE_TAKE } from "../models/array/array.misc.model.mjs";
3
- //#region src/array/slice.ts
3
+ // src/array/slice.ts
4
4
  function drop(array, first, second) {
5
5
  return extract(ARRAY_SLICE_DROP, array, first, second);
6
6
  }
@@ -61,5 +61,4 @@ function slice(array, first, second) {
61
61
  function take(array, first, second) {
62
62
  return extract(ARRAY_SLICE_TAKE, array, first, second);
63
63
  }
64
- //#endregion
65
64
  export { drop, slice, take };
@@ -1,5 +1,4 @@
1
1
  import { ArrayComparisonSorter, ArrayKeySorter, ArrayKeySorters, ArraySorter, ArraySorters, ArrayValueSorter, CompareCallback, ComparisonSorter, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SortDirection, SortHandler, Sorter } from "../models/array/array.sort.model.mjs";
2
- //#region src/array/sort.d.ts
3
2
  declare function Sorter(this: any, sorters: SortHandler[]): void;
4
3
  /**
5
4
  * Get the index for an item _(to be inserted into an array of items)_ based on sorters _(and an optional default direction)_
@@ -205,5 +204,4 @@ export declare namespace sort {
205
204
  export var initialize: typeof initializeSorter;
206
205
  export var is: typeof isSorted;
207
206
  }
208
- //#endregion
209
207
  export { type ArrayComparisonSorter, type ArrayKeySorter, type ArrayKeySorters, type ArraySorter, type ArraySorters, type ArrayValueSorter, type CompareCallback, type ComparisonSorter, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, type SortDirection, type Sorter };