@oscarpalmer/atoms 0.217.0 → 0.219.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 (85) hide show
  1. package/dist/array/filter.d.mts +38 -4
  2. package/dist/array/find.d.mts +34 -0
  3. package/dist/array/first.d.mts +40 -4
  4. package/dist/array/insert.mjs +1 -1
  5. package/dist/array/last.d.mts +46 -10
  6. package/dist/array/partition.d.mts +24 -8
  7. package/dist/array/reverse.d.mts +6 -0
  8. package/dist/array/reverse.mjs +6 -0
  9. package/dist/array/select.d.mts +97 -116
  10. package/dist/array/select.mjs +19 -15
  11. package/dist/array/single.d.mts +22 -0
  12. package/dist/array/single.mjs +1 -1
  13. package/dist/array/slice.mjs +27 -14
  14. package/dist/array/sort.d.mts +54 -0
  15. package/dist/array/sort.mjs +2 -1
  16. package/dist/color/misc/get.mjs +3 -1
  17. package/dist/color/space/hex.d.mts +8 -0
  18. package/dist/color/space/hex.mjs +9 -1
  19. package/dist/function/retry.d.mts +1 -1
  20. package/dist/function/retry.mjs +5 -2
  21. package/dist/index.d.mts +879 -324
  22. package/dist/index.mjs +480 -173
  23. package/dist/internal/array/callbacks.mjs +1 -1
  24. package/dist/internal/array/find.d.mts +3 -3
  25. package/dist/internal/array/find.mjs +90 -48
  26. package/dist/internal/array/insert.mjs +1 -1
  27. package/dist/internal/array/match.mjs +21 -17
  28. package/dist/internal/array/sets.mjs +7 -1
  29. package/dist/internal/array/shuffle.d.mts +5 -0
  30. package/dist/internal/array/shuffle.mjs +5 -0
  31. package/dist/internal/math/aggregate.d.mts +69 -21
  32. package/dist/internal/math/aggregate.mjs +4 -1
  33. package/dist/internal/math/misc.d.mts +14 -0
  34. package/dist/internal/math/misc.mjs +14 -0
  35. package/dist/internal/number.d.mts +19 -1
  36. package/dist/internal/number.mjs +22 -2
  37. package/dist/internal/plan/plan.generate.mjs +3 -3
  38. package/dist/internal/random.d.mts +6 -0
  39. package/dist/internal/random.mjs +13 -2
  40. package/dist/internal/result/attempt.mjs +4 -4
  41. package/dist/internal/string/case.d.mts +63 -0
  42. package/dist/internal/string/case.mjs +63 -0
  43. package/dist/internal/string/misc.d.mts +20 -0
  44. package/dist/internal/string/misc.mjs +22 -1
  45. package/dist/internal/subscription.mjs +1 -1
  46. package/dist/internal/value/equal.mjs +2 -1
  47. package/dist/internal/value/partial.mjs +3 -1
  48. package/dist/logger.d.mts +12 -0
  49. package/dist/logger.mjs +12 -0
  50. package/dist/math.d.mts +90 -0
  51. package/dist/math.mjs +7 -0
  52. package/dist/models/array/array.find.model.d.mts +26 -0
  53. package/dist/models/array/array.misc.model.d.mts +2 -4
  54. package/dist/models/index.d.mts +1 -1
  55. package/dist/models/plan.model.d.mts +2 -0
  56. package/dist/models/plan.model.mjs +3 -1
  57. package/dist/models/string/string.fuzzy.model.d.mts +1 -1
  58. package/dist/models/string/string.misc.model.mjs +1 -1
  59. package/dist/models/value/value.merge.model.d.mts +4 -4
  60. package/dist/plan/index.d.mts +1 -4
  61. package/dist/plan/index.mjs +2 -3
  62. package/dist/plan/use.mjs +4 -4
  63. package/dist/promise/index.d.mts +6 -4
  64. package/dist/promise/index.mjs +4 -4
  65. package/dist/promise/misc.d.mts +6 -0
  66. package/dist/promise/misc.mjs +11 -2
  67. package/dist/promise/timed.d.mts +3 -0
  68. package/dist/promise/timed.mjs +5 -2
  69. package/dist/queue.d.mts +0 -1
  70. package/dist/queue.mjs +5 -6
  71. package/dist/random.d.mts +2 -2
  72. package/dist/random.mjs +3 -3
  73. package/dist/result/match.mjs +2 -2
  74. package/dist/result/misc.mjs +3 -10
  75. package/dist/result/work/pipe.d.mts +24 -22
  76. package/dist/result/work/pipe.mjs +7 -3
  77. package/dist/string/fuzzy.mjs +1 -1
  78. package/dist/string/index.d.mts +15 -1
  79. package/dist/string/index.mjs +16 -2
  80. package/dist/string/match.d.mts +24 -0
  81. package/dist/string/match.mjs +24 -0
  82. package/dist/string/template.d.mts +4 -0
  83. package/dist/value/clone.mjs +1 -1
  84. package/dist/value/merge.mjs +17 -4
  85. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  import { GenericCallback } from "../../models/index.mjs";
2
2
  import { Result, UnwrapValue } from "../../models/result.model.mjs";
3
3
  //#region src/result/work/pipe.d.ts
4
+ type InitialAsyncPipeValue<Initial> = GenericCallback | Initial | Promise<Initial> | Result<Initial>;
5
+ type InitialPipeValue<Initial> = GenericCallback | Initial | Result<Initial>;
4
6
  type WrapValue<Value> = Result<UnwrapValue<Value>>;
5
7
  /**
6
8
  * Attempt to pipe a value through a function
@@ -10,7 +12,7 @@ type WrapValue<Value> = Result<UnwrapValue<Value>>;
10
12
  * @param initial Initial value
11
13
  * @returns _Piped_ result
12
14
  */
13
- export declare function attemptAsyncPipe<Initial, Piped>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, pipe: (value: UnwrapValue<Initial>) => Piped): Promise<WrapValue<Piped>>;
15
+ export declare function attemptAsyncPipe<Initial, Piped>(initial: InitialAsyncPipeValue<Initial>, pipe: (value: UnwrapValue<Initial>) => Piped): Promise<WrapValue<Piped>>;
14
16
  /**
15
17
  * Attempt to pipe a value through a series of functions
16
18
  *
@@ -19,7 +21,7 @@ export declare function attemptAsyncPipe<Initial, Piped>(initial: GenericCallbac
19
21
  * @param initial Initial value
20
22
  * @returns _Piped_ result
21
23
  */
22
- export declare function attemptAsyncPipe<Initial, First, Second>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second): Promise<WrapValue<Second>>;
24
+ export declare function attemptAsyncPipe<Initial, First, Second>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second): Promise<WrapValue<Second>>;
23
25
  /**
24
26
  * Attempt to pipe a value through a series of functions
25
27
  *
@@ -28,7 +30,7 @@ export declare function attemptAsyncPipe<Initial, First, Second>(initial: Generi
28
30
  * @param initial Initial value
29
31
  * @returns _Piped_ result
30
32
  */
31
- export declare function attemptAsyncPipe<Initial, First, Second, Third>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third): Promise<WrapValue<Third>>;
33
+ export declare function attemptAsyncPipe<Initial, First, Second, Third>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third): Promise<WrapValue<Third>>;
32
34
  /**
33
35
  * Attempt to pipe a value through a series of functions
34
36
  *
@@ -37,7 +39,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third>(initial:
37
39
  * @param initial Initial value
38
40
  * @returns _Piped_ result
39
41
  */
40
- export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): Promise<WrapValue<Fourth>>;
42
+ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): Promise<WrapValue<Fourth>>;
41
43
  /**
42
44
  * Attempt to pipe a value through a series of functions
43
45
  *
@@ -46,7 +48,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(
46
48
  * @param initial Initial value
47
49
  * @returns _Piped_ result
48
50
  */
49
- export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): Promise<WrapValue<Fifth>>;
51
+ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): Promise<WrapValue<Fifth>>;
50
52
  /**
51
53
  * Attempt to pipe a value through a series of functions
52
54
  *
@@ -55,7 +57,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
55
57
  * @param initial Initial value
56
58
  * @returns _Piped_ result
57
59
  */
58
- export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): Promise<WrapValue<Sixth>>;
60
+ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): Promise<WrapValue<Sixth>>;
59
61
  /**
60
62
  * Attempt to pipe a value through a series of functions
61
63
  *
@@ -64,7 +66,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
64
66
  * @param initial Initial value
65
67
  * @returns _Piped_ result
66
68
  */
67
- export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): Promise<WrapValue<Seventh>>;
69
+ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): Promise<WrapValue<Seventh>>;
68
70
  /**
69
71
  * Attempt to pipe a value through a series of functions
70
72
  *
@@ -73,7 +75,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
73
75
  * @param initial Initial value
74
76
  * @returns _Piped_ result
75
77
  */
76
- export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): Promise<WrapValue<Eighth>>;
78
+ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): Promise<WrapValue<Eighth>>;
77
79
  /**
78
80
  * Attempt to pipe a value through a series of functions
79
81
  *
@@ -82,7 +84,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
82
84
  * @param initial Initial value
83
85
  * @returns _Piped_ result
84
86
  */
85
- export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): Promise<WrapValue<Ninth>>;
87
+ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): Promise<WrapValue<Ninth>>;
86
88
  /**
87
89
  * Attempt to pipe a value through a series of functions
88
90
  *
@@ -91,7 +93,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
91
93
  * @param initial Initial value
92
94
  * @returns _Piped_ result
93
95
  */
94
- export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): Promise<WrapValue<Tenth>>;
96
+ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): Promise<WrapValue<Tenth>>;
95
97
  /**
96
98
  * Attempt to pipe a result through a series of functions
97
99
  *
@@ -100,84 +102,84 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
100
102
  * @param initial Initial result
101
103
  * @returns _Piped_ result
102
104
  */
103
- export declare function attemptAsyncPipe<Initial>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): Promise<WrapValue<Initial>>;
105
+ export declare function attemptAsyncPipe<Initial>(initial: InitialAsyncPipeValue<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): Promise<WrapValue<Initial>>;
104
106
  /**
105
107
  * Attempt to pipe a value through a function
106
108
  *
107
109
  * @param initial Initial value
108
110
  * @returns _Piped_ result
109
111
  */
110
- export declare function attemptPipe<Initial, Pipe>(initial: GenericCallback | Initial | Result<Initial>, pipe: (value: UnwrapValue<Initial>) => Pipe): WrapValue<Pipe>;
112
+ export declare function attemptPipe<Initial, Pipe>(initial: InitialPipeValue<Initial>, pipe: (value: UnwrapValue<Initial>) => Pipe): WrapValue<Pipe>;
111
113
  /**
112
114
  * Attempt to pipe a value through a series of functions
113
115
  *
114
116
  * @param initial Initial value
115
117
  * @returns _Piped_ result
116
118
  */
117
- export declare function attemptPipe<Initial, First, Second>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second): WrapValue<Second>;
119
+ export declare function attemptPipe<Initial, First, Second>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second): WrapValue<Second>;
118
120
  /**
119
121
  * Attempt to pipe a value through a series of functions
120
122
  *
121
123
  * @param initial Initial value
122
124
  * @returns _Piped_ result
123
125
  */
124
- export declare function attemptPipe<Initial, First, Second, Third>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third): WrapValue<Third>;
126
+ export declare function attemptPipe<Initial, First, Second, Third>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third): WrapValue<Third>;
125
127
  /**
126
128
  * Attempt to pipe a value through a series of functions
127
129
  *
128
130
  * @param initial Initial value
129
131
  * @returns _Piped_ result
130
132
  */
131
- export declare function attemptPipe<Initial, First, Second, Third, Fourth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): WrapValue<Fourth>;
133
+ export declare function attemptPipe<Initial, First, Second, Third, Fourth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): WrapValue<Fourth>;
132
134
  /**
133
135
  * Attempt to pipe a value through a series of functions
134
136
  *
135
137
  * @param initial Initial value
136
138
  * @returns _Piped_ result
137
139
  */
138
- export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): WrapValue<Fifth>;
140
+ export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): WrapValue<Fifth>;
139
141
  /**
140
142
  * Attempt to pipe a value through a series of functions
141
143
  *
142
144
  * @param initial Initial value
143
145
  * @returns _Piped_ result
144
146
  */
145
- export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): WrapValue<Sixth>;
147
+ export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): WrapValue<Sixth>;
146
148
  /**
147
149
  * Attempt to pipe a value through a series of functions
148
150
  *
149
151
  * @param initial Initial value
150
152
  * @returns _Piped_ result
151
153
  */
152
- export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): WrapValue<Seventh>;
154
+ export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): WrapValue<Seventh>;
153
155
  /**
154
156
  * Attempt to pipe a value through a series of functions
155
157
  *
156
158
  * @param initial Initial value
157
159
  * @returns _Piped_ result
158
160
  */
159
- export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): WrapValue<Eighth>;
161
+ export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): WrapValue<Eighth>;
160
162
  /**
161
163
  * Attempt to pipe a value through a series of functions
162
164
  *
163
165
  * @param initial Initial value
164
166
  * @returns _Piped_ result
165
167
  */
166
- export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): WrapValue<Ninth>;
168
+ export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): WrapValue<Ninth>;
167
169
  /**
168
170
  * Attempt to pipe a value through a series of functions
169
171
  *
170
172
  * @param initial Initial value
171
173
  * @returns _Piped_ result
172
174
  */
173
- export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): WrapValue<Tenth>;
175
+ export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): WrapValue<Tenth>;
174
176
  /**
175
177
  * Attempt to pipe a result through a series of functions
176
178
  *
177
179
  * @param initial Initial result
178
180
  * @returns _Piped_ result
179
181
  */
180
- export declare function attemptPipe<Initial>(initial: GenericCallback | Initial | Result<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): WrapValue<Initial>;
182
+ export declare function attemptPipe<Initial>(initial: InitialPipeValue<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): WrapValue<Initial>;
181
183
  export declare namespace attemptPipe {
182
184
  export var async: typeof attemptAsyncPipe;
183
185
  }
@@ -3,9 +3,11 @@ import { asyncAttempt, attempt } from "../../internal/result/attempt.mjs";
3
3
  import { asyncPipe, pipe } from "../../internal/function/work.mjs";
4
4
  //#region src/result/work/pipe.ts
5
5
  async function attemptAsyncPipe(initial, first, ...seconds) {
6
- return asyncAttempt(() => {
6
+ return asyncAttempt(async () => {
7
7
  if (isError(initial)) throw initial.error;
8
- const value = typeof initial === "function" ? initial() : isOk(initial) ? initial.value : initial;
8
+ let value;
9
+ if (typeof initial === "function") value = initial();
10
+ else value = isOk(initial) ? initial.value : initial;
9
11
  if (first == null) return value;
10
12
  return asyncPipe(value, ...[first, ...seconds]);
11
13
  });
@@ -13,7 +15,9 @@ async function attemptAsyncPipe(initial, first, ...seconds) {
13
15
  function attemptPipe(initial, first, ...seconds) {
14
16
  return attempt(() => {
15
17
  if (isError(initial)) throw initial.error;
16
- const value = typeof initial === "function" ? initial() : isOk(initial) ? initial.value : initial;
18
+ let value;
19
+ if (typeof initial === "function") value = initial();
20
+ else value = isOk(initial) ? initial.value : initial;
17
21
  if (first == null) return value;
18
22
  return pipe(value, ...[first, ...seconds]);
19
23
  });
@@ -23,7 +23,7 @@ Object.defineProperties(Fuzzy.prototype, {
23
23
  }
24
24
  });
25
25
  function createFuzzyItems(items) {
26
- return items.sort((first, second) => first.haystack.localeCompare(second.haystack)).map(({ item }) => item);
26
+ return items.toSorted((first, second) => first.haystack.localeCompare(second.haystack)).map(({ item }) => item);
27
27
  }
28
28
  function createFuzzyOptions(input, state) {
29
29
  const options = isPlainObject(input) ? input : {};
@@ -31,7 +31,7 @@ export declare function getUuid(): string;
31
31
  *
32
32
  * @param value JSON string to parse
33
33
  * @param reviver Reviver function to transform the parsed values
34
- * @returns Parsed value or `undefined` if parsing fails
34
+ * @returns Parsed value, or `undefined` if parsing fails
35
35
  */
36
36
  export declare function parse(value: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): unknown;
37
37
  /**
@@ -39,6 +39,13 @@ export declare function parse(value: string, reviver?: (this: unknown, key: stri
39
39
  *
40
40
  * @param value String to trim
41
41
  * @returns Trimmed string
42
+ * @example
43
+ * ```typescript
44
+ * trim(' this is a test '); // => 'this is a test'
45
+ * trim('this is a test'); // => 'this is a test'
46
+ * trim(' '); // => ''
47
+ * trim(''); // => ''
48
+ * ```
42
49
  */
43
50
  export declare function trim(value: string): string;
44
51
  /**
@@ -48,6 +55,13 @@ export declare function trim(value: string): string;
48
55
  * @param length Maximum length of the string after truncation
49
56
  * @param suffix Suffix to append to the truncated string
50
57
  * @returns Truncated string
58
+ * @example
59
+ * ```typescript
60
+ * truncate('this is a test', 7); // => 'this is'
61
+ * truncate('this is a test', 7, '...'); // => 'this ...'
62
+ * truncate('this is a test', 20); // => 'this is a test'
63
+ * truncate('this is a test', 0); // => ''
64
+ * ```
51
65
  */
52
66
  export declare function truncate(value: string, length: number, suffix?: string): string;
53
67
  //#endregion
@@ -20,7 +20,7 @@ function dedent(value, ...values) {
20
20
  }
21
21
  if (lengths.length === 0) return actual.trim();
22
22
  const minimum = min(lengths);
23
- const pattern = new RegExp(`^\\s{0,${minimum}}`);
23
+ const pattern = new RegExp(String.raw`^\s{0,${minimum}}`);
24
24
  let result = "";
25
25
  for (let index = 0; index < length; index += 1) {
26
26
  const line = lines[index];
@@ -57,7 +57,7 @@ function getUuid(html) {
57
57
  *
58
58
  * @param value JSON string to parse
59
59
  * @param reviver Reviver function to transform the parsed values
60
- * @returns Parsed value or `undefined` if parsing fails
60
+ * @returns Parsed value, or `undefined` if parsing fails
61
61
  */
62
62
  function parse(value, reviver) {
63
63
  try {
@@ -71,6 +71,13 @@ function parse(value, reviver) {
71
71
  *
72
72
  * @param value String to trim
73
73
  * @returns Trimmed string
74
+ * @example
75
+ * ```typescript
76
+ * trim(' this is a test '); // => 'this is a test'
77
+ * trim('this is a test'); // => 'this is a test'
78
+ * trim(' '); // => ''
79
+ * trim(''); // => ''
80
+ * ```
74
81
  */
75
82
  function trim(value) {
76
83
  return typeof value === "string" ? value.trim() : "";
@@ -82,6 +89,13 @@ function trim(value) {
82
89
  * @param length Maximum length of the string after truncation
83
90
  * @param suffix Suffix to append to the truncated string
84
91
  * @returns Truncated string
92
+ * @example
93
+ * ```typescript
94
+ * truncate('this is a test', 7); // => 'this is'
95
+ * truncate('this is a test', 7, '...'); // => 'this ...'
96
+ * truncate('this is a test', 20); // => 'this is a test'
97
+ * truncate('this is a test', 0); // => ''
98
+ * ```
85
99
  */
86
100
  function truncate(value, length, suffix) {
87
101
  if (typeof value !== "string" || typeof length !== "number" || length === 0) return "";
@@ -6,6 +6,14 @@
6
6
  * @param needle String to look for
7
7
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
8
8
  * @returns `true` if the string ends with the given substring, otherwise `false`
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * endsWith('this is a test', 'test'); // => true
13
+ * endsWith('this is a test', 'Test'); // => false
14
+ * endsWith('this is a test', 'Test', true); // => true
15
+ * endsWith('this is a test', 'not'); // => false
16
+ * ```
9
17
  */
10
18
  export declare function endsWith(haystack: string, needle: string, ignoreCase?: boolean): boolean;
11
19
  /**
@@ -15,6 +23,14 @@ export declare function endsWith(haystack: string, needle: string, ignoreCase?:
15
23
  * @param needle String to look for
16
24
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
17
25
  * @returns `true` if the string includes the given substring, otherwise `false`
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * includes('this is a test', 'is'); // => true
30
+ * includes('this is a test', 'Is'); // => false
31
+ * includes('this is a test', 'Is', true); // => true
32
+ * includes('this is a test', 'not'); // => false
33
+ * ```
18
34
  */
19
35
  export declare function includes(haystack: string, needle: string, ignoreCase?: boolean): boolean;
20
36
  /**
@@ -24,6 +40,14 @@ export declare function includes(haystack: string, needle: string, ignoreCase?:
24
40
  * @param needle String to look for
25
41
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
26
42
  * @returns `true` if the string starts with the given substring, otherwise `false`
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * startsWith('this is a test', 'this'); // => true
47
+ * startsWith('this is a test', 'This'); // => false
48
+ * startsWith('this is a test', 'This', true); // => true
49
+ * startsWith('this is a test', 'not'); // => false
50
+ * ```
27
51
  */
28
52
  export declare function startsWith(haystack: string, needle: string, ignoreCase?: boolean): boolean;
29
53
  //#endregion
@@ -8,6 +8,14 @@ import { memoize } from "../internal/function/memoize.mjs";
8
8
  * @param needle String to look for
9
9
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
10
10
  * @returns `true` if the string ends with the given substring, otherwise `false`
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * endsWith('this is a test', 'test'); // => true
15
+ * endsWith('this is a test', 'Test'); // => false
16
+ * endsWith('this is a test', 'Test', true); // => true
17
+ * endsWith('this is a test', 'not'); // => false
18
+ * ```
11
19
  */
12
20
  function endsWith(haystack, needle, ignoreCase) {
13
21
  return match(STRING_MATCH_ENDS_WITH, haystack, needle, ignoreCase === true);
@@ -19,6 +27,14 @@ function endsWith(haystack, needle, ignoreCase) {
19
27
  * @param needle String to look for
20
28
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
21
29
  * @returns `true` if the string includes the given substring, otherwise `false`
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * includes('this is a test', 'is'); // => true
34
+ * includes('this is a test', 'Is'); // => false
35
+ * includes('this is a test', 'Is', true); // => true
36
+ * includes('this is a test', 'not'); // => false
37
+ * ```
22
38
  */
23
39
  function includes(haystack, needle, ignoreCase) {
24
40
  return match(STRING_MATCH_INCLUDES, haystack, needle, ignoreCase === true);
@@ -38,6 +54,14 @@ function matchCallback(haystack, needle, ignoreCase) {
38
54
  * @param needle String to look for
39
55
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
40
56
  * @returns `true` if the string starts with the given substring, otherwise `false`
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * startsWith('this is a test', 'this'); // => true
61
+ * startsWith('this is a test', 'This'); // => false
62
+ * startsWith('this is a test', 'This', true); // => true
63
+ * startsWith('this is a test', 'not'); // => false
64
+ * ```
41
65
  */
42
66
  function startsWith(haystack, needle, ignoreCase) {
43
67
  return match(STRING_MATCH_STARTS_WITH, haystack, needle, ignoreCase === true);
@@ -24,6 +24,10 @@ export declare function template(strings: TemplateStringsArray, ...values: unkno
24
24
  * @param variables Variables to use
25
25
  * @param options Templating options
26
26
  * @returns Templated string
27
+ * @example
28
+ * ```typescript
29
+ * template('Hello, {{name}}!', {name: 'World'}); // => 'Hello, World!'
30
+ * ```
27
31
  */
28
32
  export declare function template(value: string, variables?: PlainObject, options?: Partial<TemplateOptions>): string;
29
33
  export declare namespace template {
@@ -16,7 +16,7 @@ function clone(value, options) {
16
16
  function cloneAny(value, parameters, depth, options) {
17
17
  switch (true) {
18
18
  case value === null || CLONE_PRIMITIVES[typeof value]: return value;
19
- case value instanceof Date: return new Date(value.getTime());
19
+ case value instanceof Date: return new Date(value);
20
20
  case typeof value === "function":
21
21
  parameters.options ??= createCloneOptions(options);
22
22
  return parameters.options.copyFunctions ? value : void 0;
@@ -43,6 +43,12 @@ function createMergingOptions(input) {
43
43
  actual.skipNullableInArrays = options.skipNullableInArrays === true;
44
44
  return actual;
45
45
  }
46
+ function getFullKey(prefix, key, options) {
47
+ let full;
48
+ if (options.replaceableObjects == null) full = void 0;
49
+ else full = prefix == null ? key : `${prefix}.${key}`;
50
+ return full;
51
+ }
46
52
  function getReplaceableObjects(value) {
47
53
  const items = (Array.isArray(value) ? value : [value]).filter((item) => typeof item === "string" || item instanceof RegExp);
48
54
  if (items.length === 0) return;
@@ -70,6 +76,9 @@ function initializeAssigner(options) {
70
76
  function initializeMerger(options) {
71
77
  return new Merger(createMergingOptions(options));
72
78
  }
79
+ function isMergeable(next, previous, options, full) {
80
+ return isArrayOrPlainObject(next) && isArrayOrPlainObject(previous) && !(options.replaceableObjects?.(full) ?? false);
81
+ }
73
82
  /**
74
83
  * Merge multiple arrays or objects into a single one
75
84
  *
@@ -96,9 +105,9 @@ function mergeObjects(values, options, destination, prefix) {
96
105
  const key = keys[innerIndex];
97
106
  const next = item[key];
98
107
  const previous = merged[key];
99
- if (next == null && (options.skipNullableAny || isArray && options.skipNullableInArrays)) continue;
100
- const full = options.replaceableObjects == null ? void 0 : prefix == null ? key : `${prefix}.${key}`;
101
- if (isArrayOrPlainObject(next) && isArrayOrPlainObject(previous) && !(options.replaceableObjects?.(full) ?? false)) merged[key] = mergeObjects([previous, next], options, destination == null ? void 0 : merged[key], full);
108
+ if (skipMerge(next, options, isArray)) continue;
109
+ const fullKey = getFullKey(prefix, key, options);
110
+ if (isMergeable(next, previous, options, fullKey)) merged[key] = mergeObjects([previous, next], options, destination == null ? void 0 : merged[key], fullKey);
102
111
  else merged[key] = next;
103
112
  }
104
113
  }
@@ -110,7 +119,11 @@ function mergeValues(values, options, prefix) {
110
119
  if (actual.length === 0) return {};
111
120
  if (options.assignValues && actual.length === 2 && !Array.isArray(actual[0]) && Object.keys(actual[0]).length === 0) return Object.assign(actual[0], actual[1]);
112
121
  if (actual.length > 1) return mergeObjects(actual, options, options.assignValues ? actual[0] : void 0, prefix);
113
- return options.assignValues ? actual[0] : Array.isArray(actual[0]) ? actual[0].slice() : { ...actual[0] };
122
+ if (options.assignValues) return actual[0];
123
+ return Array.isArray(actual[0]) ? actual[0].slice() : { ...actual[0] };
124
+ }
125
+ function skipMerge(next, options, isArray) {
126
+ return next == null && (options.skipNullableAny || isArray && options.skipNullableInArrays);
114
127
  }
115
128
  assign.initialize = initializeAssigner;
116
129
  merge.initialize = initializeMerger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oscarpalmer/atoms",
3
- "version": "0.217.0",
3
+ "version": "0.219.0",
4
4
  "description": "Atomic utilities for making your JavaScript better.",
5
5
  "keywords": [
6
6
  "array",