@nlozgachev/pipelined 0.11.0 → 0.13.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 (193) hide show
  1. package/LICENCE +28 -0
  2. package/README.md +1 -1
  3. package/{types/src/Types/NonEmptyList.d.ts → dist/NonEmptyList-BlGFjor5.d.mts} +4 -3
  4. package/dist/NonEmptyList-BlGFjor5.d.ts +30 -0
  5. package/dist/Task-BB8Wmc1J.d.ts +677 -0
  6. package/dist/Task-ChKyH0pF.d.mts +677 -0
  7. package/dist/chunk-DBIC62UV.mjs +6 -0
  8. package/dist/chunk-QPTGO5AS.mjs +150 -0
  9. package/dist/composition.d.mts +495 -0
  10. package/dist/composition.d.ts +495 -0
  11. package/dist/composition.js +188 -0
  12. package/dist/composition.mjs +135 -0
  13. package/dist/core.d.mts +2170 -0
  14. package/dist/core.d.ts +2170 -0
  15. package/dist/core.js +698 -0
  16. package/dist/core.mjs +517 -0
  17. package/dist/types.d.mts +54 -0
  18. package/{types/src/Types/Brand.d.ts → dist/types.d.ts} +6 -4
  19. package/dist/types.js +41 -0
  20. package/dist/types.mjs +14 -0
  21. package/dist/utils.d.mts +1285 -0
  22. package/dist/utils.d.ts +1285 -0
  23. package/dist/utils.js +722 -0
  24. package/dist/utils.mjs +553 -0
  25. package/package.json +63 -69
  26. package/esm/mod.js +0 -3
  27. package/esm/package.json +0 -3
  28. package/esm/src/Composition/compose.js +0 -3
  29. package/esm/src/Composition/converge.js +0 -3
  30. package/esm/src/Composition/curry.js +0 -42
  31. package/esm/src/Composition/flip.js +0 -20
  32. package/esm/src/Composition/flow.js +0 -8
  33. package/esm/src/Composition/fn.js +0 -85
  34. package/esm/src/Composition/index.js +0 -13
  35. package/esm/src/Composition/juxt.js +0 -3
  36. package/esm/src/Composition/memoize.js +0 -66
  37. package/esm/src/Composition/not.js +0 -25
  38. package/esm/src/Composition/on.js +0 -12
  39. package/esm/src/Composition/pipe.js +0 -3
  40. package/esm/src/Composition/tap.js +0 -33
  41. package/esm/src/Composition/uncurry.js +0 -32
  42. package/esm/src/Core/Deferred.js +0 -30
  43. package/esm/src/Core/InternalTypes.js +0 -1
  44. package/esm/src/Core/Lens.js +0 -98
  45. package/esm/src/Core/Logged.js +0 -111
  46. package/esm/src/Core/Option.js +0 -191
  47. package/esm/src/Core/Optional.js +0 -160
  48. package/esm/src/Core/Predicate.js +0 -133
  49. package/esm/src/Core/Reader.js +0 -134
  50. package/esm/src/Core/Refinement.js +0 -115
  51. package/esm/src/Core/RemoteData.js +0 -211
  52. package/esm/src/Core/Result.js +0 -170
  53. package/esm/src/Core/State.js +0 -181
  54. package/esm/src/Core/Task.js +0 -223
  55. package/esm/src/Core/TaskOption.js +0 -106
  56. package/esm/src/Core/TaskResult.js +0 -127
  57. package/esm/src/Core/TaskValidation.js +0 -128
  58. package/esm/src/Core/These.js +0 -245
  59. package/esm/src/Core/Validation.js +0 -212
  60. package/esm/src/Core/index.js +0 -17
  61. package/esm/src/Types/Brand.js +0 -28
  62. package/esm/src/Types/NonEmptyList.js +0 -14
  63. package/esm/src/Types/index.js +0 -2
  64. package/esm/src/Utils/Arr.js +0 -570
  65. package/esm/src/Utils/Num.js +0 -124
  66. package/esm/src/Utils/Rec.js +0 -215
  67. package/esm/src/Utils/Str.js +0 -134
  68. package/esm/src/Utils/index.js +0 -4
  69. package/script/mod.js +0 -19
  70. package/script/package.json +0 -3
  71. package/script/src/Composition/compose.js +0 -6
  72. package/script/src/Composition/converge.js +0 -6
  73. package/script/src/Composition/curry.js +0 -48
  74. package/script/src/Composition/flip.js +0 -24
  75. package/script/src/Composition/flow.js +0 -11
  76. package/script/src/Composition/fn.js +0 -98
  77. package/script/src/Composition/index.js +0 -29
  78. package/script/src/Composition/juxt.js +0 -6
  79. package/script/src/Composition/memoize.js +0 -71
  80. package/script/src/Composition/not.js +0 -29
  81. package/script/src/Composition/on.js +0 -16
  82. package/script/src/Composition/pipe.js +0 -6
  83. package/script/src/Composition/tap.js +0 -37
  84. package/script/src/Composition/uncurry.js +0 -38
  85. package/script/src/Core/Deferred.js +0 -33
  86. package/script/src/Core/InternalTypes.js +0 -2
  87. package/script/src/Core/Lens.js +0 -101
  88. package/script/src/Core/Logged.js +0 -114
  89. package/script/src/Core/Option.js +0 -194
  90. package/script/src/Core/Optional.js +0 -163
  91. package/script/src/Core/Predicate.js +0 -136
  92. package/script/src/Core/Reader.js +0 -137
  93. package/script/src/Core/Refinement.js +0 -118
  94. package/script/src/Core/RemoteData.js +0 -214
  95. package/script/src/Core/Result.js +0 -173
  96. package/script/src/Core/State.js +0 -184
  97. package/script/src/Core/Task.js +0 -226
  98. package/script/src/Core/TaskOption.js +0 -109
  99. package/script/src/Core/TaskResult.js +0 -130
  100. package/script/src/Core/TaskValidation.js +0 -131
  101. package/script/src/Core/These.js +0 -248
  102. package/script/src/Core/Validation.js +0 -215
  103. package/script/src/Core/index.js +0 -33
  104. package/script/src/Types/Brand.js +0 -31
  105. package/script/src/Types/NonEmptyList.js +0 -18
  106. package/script/src/Types/index.js +0 -18
  107. package/script/src/Utils/Arr.js +0 -573
  108. package/script/src/Utils/Num.js +0 -127
  109. package/script/src/Utils/Rec.js +0 -218
  110. package/script/src/Utils/Str.js +0 -137
  111. package/script/src/Utils/index.js +0 -20
  112. package/types/mod.d.ts +0 -4
  113. package/types/mod.d.ts.map +0 -1
  114. package/types/src/Composition/compose.d.ts +0 -33
  115. package/types/src/Composition/compose.d.ts.map +0 -1
  116. package/types/src/Composition/converge.d.ts +0 -21
  117. package/types/src/Composition/converge.d.ts.map +0 -1
  118. package/types/src/Composition/curry.d.ts +0 -43
  119. package/types/src/Composition/curry.d.ts.map +0 -1
  120. package/types/src/Composition/flip.d.ts +0 -21
  121. package/types/src/Composition/flip.d.ts.map +0 -1
  122. package/types/src/Composition/flow.d.ts +0 -56
  123. package/types/src/Composition/flow.d.ts.map +0 -1
  124. package/types/src/Composition/fn.d.ts +0 -76
  125. package/types/src/Composition/fn.d.ts.map +0 -1
  126. package/types/src/Composition/index.d.ts +0 -14
  127. package/types/src/Composition/index.d.ts.map +0 -1
  128. package/types/src/Composition/juxt.d.ts +0 -18
  129. package/types/src/Composition/juxt.d.ts.map +0 -1
  130. package/types/src/Composition/memoize.d.ts +0 -46
  131. package/types/src/Composition/memoize.d.ts.map +0 -1
  132. package/types/src/Composition/not.d.ts +0 -26
  133. package/types/src/Composition/not.d.ts.map +0 -1
  134. package/types/src/Composition/on.d.ts +0 -13
  135. package/types/src/Composition/on.d.ts.map +0 -1
  136. package/types/src/Composition/pipe.d.ts +0 -56
  137. package/types/src/Composition/pipe.d.ts.map +0 -1
  138. package/types/src/Composition/tap.d.ts +0 -31
  139. package/types/src/Composition/tap.d.ts.map +0 -1
  140. package/types/src/Composition/uncurry.d.ts +0 -54
  141. package/types/src/Composition/uncurry.d.ts.map +0 -1
  142. package/types/src/Core/Deferred.d.ts +0 -49
  143. package/types/src/Core/Deferred.d.ts.map +0 -1
  144. package/types/src/Core/InternalTypes.d.ts +0 -23
  145. package/types/src/Core/InternalTypes.d.ts.map +0 -1
  146. package/types/src/Core/Lens.d.ts +0 -118
  147. package/types/src/Core/Lens.d.ts.map +0 -1
  148. package/types/src/Core/Logged.d.ts +0 -126
  149. package/types/src/Core/Logged.d.ts.map +0 -1
  150. package/types/src/Core/Option.d.ts +0 -209
  151. package/types/src/Core/Option.d.ts.map +0 -1
  152. package/types/src/Core/Optional.d.ts +0 -158
  153. package/types/src/Core/Optional.d.ts.map +0 -1
  154. package/types/src/Core/Predicate.d.ts +0 -161
  155. package/types/src/Core/Predicate.d.ts.map +0 -1
  156. package/types/src/Core/Reader.d.ts +0 -156
  157. package/types/src/Core/Reader.d.ts.map +0 -1
  158. package/types/src/Core/Refinement.d.ts +0 -138
  159. package/types/src/Core/Refinement.d.ts.map +0 -1
  160. package/types/src/Core/RemoteData.d.ts +0 -197
  161. package/types/src/Core/RemoteData.d.ts.map +0 -1
  162. package/types/src/Core/Result.d.ts +0 -182
  163. package/types/src/Core/Result.d.ts.map +0 -1
  164. package/types/src/Core/State.d.ts +0 -192
  165. package/types/src/Core/State.d.ts.map +0 -1
  166. package/types/src/Core/Task.d.ts +0 -219
  167. package/types/src/Core/Task.d.ts.map +0 -1
  168. package/types/src/Core/TaskOption.d.ts +0 -121
  169. package/types/src/Core/TaskOption.d.ts.map +0 -1
  170. package/types/src/Core/TaskResult.d.ts +0 -119
  171. package/types/src/Core/TaskResult.d.ts.map +0 -1
  172. package/types/src/Core/TaskValidation.d.ts +0 -144
  173. package/types/src/Core/TaskValidation.d.ts.map +0 -1
  174. package/types/src/Core/These.d.ts +0 -225
  175. package/types/src/Core/These.d.ts.map +0 -1
  176. package/types/src/Core/Validation.d.ts +0 -203
  177. package/types/src/Core/Validation.d.ts.map +0 -1
  178. package/types/src/Core/index.d.ts +0 -18
  179. package/types/src/Core/index.d.ts.map +0 -1
  180. package/types/src/Types/Brand.d.ts.map +0 -1
  181. package/types/src/Types/NonEmptyList.d.ts.map +0 -1
  182. package/types/src/Types/index.d.ts +0 -3
  183. package/types/src/Types/index.d.ts.map +0 -1
  184. package/types/src/Utils/Arr.d.ts +0 -403
  185. package/types/src/Utils/Arr.d.ts.map +0 -1
  186. package/types/src/Utils/Num.d.ts +0 -110
  187. package/types/src/Utils/Num.d.ts.map +0 -1
  188. package/types/src/Utils/Rec.d.ts +0 -143
  189. package/types/src/Utils/Rec.d.ts.map +0 -1
  190. package/types/src/Utils/Str.d.ts +0 -128
  191. package/types/src/Utils/Str.d.ts.map +0 -1
  192. package/types/src/Utils/index.d.ts +0 -5
  193. package/types/src/Utils/index.d.ts.map +0 -1
@@ -1,110 +0,0 @@
1
- import { Option } from "../Core/Option.js";
2
- /**
3
- * Number utilities for common operations. All transformation functions are data-last
4
- * and curried so they compose naturally with `pipe` and `Arr.map`.
5
- *
6
- * @example
7
- * ```ts
8
- * import { Num } from "@nlozgachev/pipelined/utils";
9
- * import { pipe } from "@nlozgachev/pipelined/composition";
10
- *
11
- * pipe(
12
- * Num.range(1, 6),
13
- * Arr.map(Num.multiply(2)),
14
- * Arr.filter(Num.between(4, 8))
15
- * ); // [4, 6, 8]
16
- * ```
17
- */
18
- export declare namespace Num {
19
- /**
20
- * Generates an array of numbers from `from` to `to` (both inclusive),
21
- * stepping by `step` (default `1`). If `step` is negative or zero, or `from > to`,
22
- * returns an empty array. When `step` does not land exactly on `to`, the last value
23
- * is the largest reachable value that does not exceed `to`.
24
- *
25
- * @example
26
- * ```ts
27
- * Num.range(0, 5); // [0, 1, 2, 3, 4, 5]
28
- * Num.range(0, 10, 2); // [0, 2, 4, 6, 8, 10]
29
- * Num.range(0, 9, 2); // [0, 2, 4, 6, 8]
30
- * Num.range(5, 0); // []
31
- * Num.range(3, 3); // [3]
32
- * ```
33
- */
34
- const range: (from: number, to: number, step?: number) => readonly number[];
35
- /**
36
- * Clamps a number between `min` and `max` (both inclusive).
37
- *
38
- * @example
39
- * ```ts
40
- * pipe(150, Num.clamp(0, 100)); // 100
41
- * pipe(-5, Num.clamp(0, 100)); // 0
42
- * pipe(42, Num.clamp(0, 100)); // 42
43
- * ```
44
- */
45
- const clamp: (min: number, max: number) => (n: number) => number;
46
- /**
47
- * Returns `true` when the number is between `min` and `max` (both inclusive).
48
- *
49
- * @example
50
- * ```ts
51
- * pipe(5, Num.between(1, 10)); // true
52
- * pipe(0, Num.between(1, 10)); // false
53
- * pipe(10, Num.between(1, 10)); // true
54
- * ```
55
- */
56
- const between: (min: number, max: number) => (n: number) => boolean;
57
- /**
58
- * Parses a string as a number. Returns `None` when the result is `NaN`.
59
- *
60
- * @example
61
- * ```ts
62
- * Num.parse("42"); // Some(42)
63
- * Num.parse("3.14"); // Some(3.14)
64
- * Num.parse("abc"); // None
65
- * Num.parse(""); // None
66
- * ```
67
- */
68
- const parse: (s: string) => Option<number>;
69
- /**
70
- * Adds `b` to a number. Data-last: use in `pipe` or `Arr.map`.
71
- *
72
- * @example
73
- * ```ts
74
- * pipe(5, Num.add(3)); // 8
75
- * pipe([1, 2, 3], Arr.map(Num.add(10))); // [11, 12, 13]
76
- * ```
77
- */
78
- const add: (b: number) => (a: number) => number;
79
- /**
80
- * Subtracts `b` from a number. Data-last: `subtract(b)(a)` = `a - b`.
81
- *
82
- * @example
83
- * ```ts
84
- * pipe(10, Num.subtract(3)); // 7
85
- * pipe([5, 10, 15], Arr.map(Num.subtract(2))); // [3, 8, 13]
86
- * ```
87
- */
88
- const subtract: (b: number) => (a: number) => number;
89
- /**
90
- * Multiplies a number by `b`. Data-last: use in `pipe` or `Arr.map`.
91
- *
92
- * @example
93
- * ```ts
94
- * pipe(6, Num.multiply(7)); // 42
95
- * pipe([1, 2, 3], Arr.map(Num.multiply(100))); // [100, 200, 300]
96
- * ```
97
- */
98
- const multiply: (b: number) => (a: number) => number;
99
- /**
100
- * Divides a number by `b`. Data-last: `divide(b)(a)` = `a / b`.
101
- *
102
- * @example
103
- * ```ts
104
- * pipe(20, Num.divide(4)); // 5
105
- * pipe([10, 20, 30], Arr.map(Num.divide(10))); // [1, 2, 3]
106
- * ```
107
- */
108
- const divide: (b: number) => (a: number) => number;
109
- }
110
- //# sourceMappingURL=Num.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Num.d.ts","sourceRoot":"","sources":["../../../src/src/Utils/Num.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,yBAAiB,GAAG,CAAC;IACpB;;;;;;;;;;;;;;OAcG;IACI,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,IAAI,MAAM,EAAE,aAAQ,KAAG,SAAS,MAAM,EAQzE,CAAC;IAEF;;;;;;;;;OASG;IACI,MAAM,KAAK,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,MAAM,GAAG,MAAM,KAAG,MAAyC,CAAC;IAE1G;;;;;;;;;OASG;IACI,MAAM,OAAO,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,MAAM,GAAG,MAAM,KAAG,OAA+B,CAAC;IAElG;;;;;;;;;;OAUG;IACI,MAAM,KAAK,GAAI,GAAG,MAAM,KAAG,MAAM,CAAC,MAAM,CAI9C,CAAC;IAEF;;;;;;;;OAQG;IACI,MAAM,GAAG,GAAI,GAAG,MAAM,MAAM,GAAG,MAAM,KAAG,MAAe,CAAC;IAE/D;;;;;;;;OAQG;IACI,MAAM,QAAQ,GAAI,GAAG,MAAM,MAAM,GAAG,MAAM,KAAG,MAAe,CAAC;IAEpE;;;;;;;;OAQG;IACI,MAAM,QAAQ,GAAI,GAAG,MAAM,MAAM,GAAG,MAAM,KAAG,MAAe,CAAC;IAEpE;;;;;;;;OAQG;IACI,MAAM,MAAM,GAAI,GAAG,MAAM,MAAM,GAAG,MAAM,KAAG,MAAe,CAAC;CAClE"}
@@ -1,143 +0,0 @@
1
- import { Option } from "../Core/Option.js";
2
- /**
3
- * Functional record/object utilities that compose well with pipe.
4
- * All functions are data-last and curried where applicable.
5
- *
6
- * @example
7
- * ```ts
8
- * pipe(
9
- * { a: 1, b: 2, c: 3 },
10
- * Rec.filter(n => n > 1),
11
- * Rec.map(n => n * 10)
12
- * ); // { b: 20, c: 30 }
13
- * ```
14
- */
15
- export declare namespace Rec {
16
- /**
17
- * Transforms each value in a record.
18
- *
19
- * @example
20
- * ```ts
21
- * pipe({ a: 1, b: 2 }, Rec.map(n => n * 2)); // { a: 2, b: 4 }
22
- * ```
23
- */
24
- const map: <A, B>(f: (a: A) => B) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, B>>;
25
- /**
26
- * Transforms each value in a record, also receiving the key.
27
- *
28
- * @example
29
- * ```ts
30
- * pipe({ a: 1, b: 2 }, Rec.mapWithKey((k, v) => `${k}:${v}`));
31
- * // { a: "a:1", b: "b:2" }
32
- * ```
33
- */
34
- const mapWithKey: <A, B>(f: (key: string, a: A) => B) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, B>>;
35
- /**
36
- * Filters values in a record by a predicate.
37
- *
38
- * @example
39
- * ```ts
40
- * pipe({ a: 1, b: 2, c: 3 }, Rec.filter(n => n > 1)); // { b: 2, c: 3 }
41
- * ```
42
- */
43
- const filter: <A>(predicate: (a: A) => boolean) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
44
- /**
45
- * Filters values in a record by a predicate that also receives the key.
46
- *
47
- * @example
48
- * ```ts
49
- * pipe({ a: 1, b: 2 }, Rec.filterWithKey((k, v) => k !== "a" && v > 0));
50
- * // { b: 2 }
51
- * ```
52
- */
53
- const filterWithKey: <A>(predicate: (key: string, a: A) => boolean) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
54
- /**
55
- * Looks up a value by key, returning Option.
56
- *
57
- * @example
58
- * ```ts
59
- * pipe({ a: 1, b: 2 }, Rec.lookup("a")); // Some(1)
60
- * pipe({ a: 1, b: 2 }, Rec.lookup("c")); // None
61
- * ```
62
- */
63
- const lookup: (key: string) => <A>(data: Readonly<Record<string, A>>) => Option<A>;
64
- /**
65
- * Returns all keys of a record.
66
- */
67
- const keys: <A>(data: Readonly<Record<string, A>>) => readonly string[];
68
- /**
69
- * Returns all values of a record.
70
- */
71
- const values: <A>(data: Readonly<Record<string, A>>) => readonly A[];
72
- /**
73
- * Returns all key-value pairs of a record.
74
- */
75
- const entries: <A>(data: Readonly<Record<string, A>>) => readonly (readonly [string, A])[];
76
- /**
77
- * Creates a record from key-value pairs.
78
- *
79
- * @example
80
- * ```ts
81
- * Rec.fromEntries([["a", 1], ["b", 2]]); // { a: 1, b: 2 }
82
- * ```
83
- */
84
- const fromEntries: <A>(data: readonly (readonly [string, A])[]) => Readonly<Record<string, A>>;
85
- /**
86
- * Picks specific keys from a record.
87
- *
88
- * @example
89
- * ```ts
90
- * pipe({ a: 1, b: 2, c: 3 }, Rec.pick("a", "c")); // { a: 1, c: 3 }
91
- * ```
92
- */
93
- const pick: <K extends string>(...pickedKeys: K[]) => <A extends Record<K, unknown>>(data: A) => Pick<A, K>;
94
- /**
95
- * Omits specific keys from a record.
96
- *
97
- * @example
98
- * ```ts
99
- * pipe({ a: 1, b: 2, c: 3 }, Rec.omit("b")); // { a: 1, c: 3 }
100
- * ```
101
- */
102
- const omit: <K extends string>(...omittedKeys: K[]) => <A extends Record<K, unknown>>(data: A) => Omit<A, K>;
103
- /**
104
- * Merges two records. Values from the second record take precedence.
105
- *
106
- * @example
107
- * ```ts
108
- * pipe({ a: 1, b: 2 }, Rec.merge({ b: 3, c: 4 })); // { a: 1, b: 3, c: 4 }
109
- * ```
110
- */
111
- const merge: <A>(other: Readonly<Record<string, A>>) => (data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
112
- /**
113
- * Returns true if the record has no keys.
114
- */
115
- const isEmpty: <A>(data: Readonly<Record<string, A>>) => boolean;
116
- /**
117
- * Returns the number of keys in a record.
118
- */
119
- const size: <A>(data: Readonly<Record<string, A>>) => number;
120
- /**
121
- * Transforms each key while preserving values.
122
- * If two keys map to the same new key, the last one wins.
123
- *
124
- * @example
125
- * ```ts
126
- * pipe({ firstName: "Alice", lastName: "Smith" }, Rec.mapKeys(k => k.toUpperCase()));
127
- * // { FIRSTNAME: "Alice", LASTNAME: "Smith" }
128
- * ```
129
- */
130
- const mapKeys: (f: (key: string) => string) => <A>(data: Readonly<Record<string, A>>) => Readonly<Record<string, A>>;
131
- /**
132
- * Removes all `None` values from a `Record<string, Option<A>>`, returning a plain `Record<string, A>`.
133
- * Useful when building records from fallible lookups.
134
- *
135
- * @example
136
- * ```ts
137
- * Rec.compact({ a: Option.some(1), b: Option.none(), c: Option.some(3) });
138
- * // { a: 1, c: 3 }
139
- * ```
140
- */
141
- const compact: <A>(data: Readonly<Record<string, Option<A>>>) => Readonly<Record<string, A>>;
142
- }
143
- //# sourceMappingURL=Rec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Rec.d.ts","sourceRoot":"","sources":["../../../src/src/Utils/Rec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,M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CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAGxG,CAAC;IAEJ;;OAEG;IACI,MAAM,OAAO,GAAI,CAAC,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAG,OAAyC,CAAC;IAEzG;;OAEG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAG,MAAkC,CAAC;IAE/F;;;;;;;;;OASG;IACI,MAAM,OAAO,GAClB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,MAAM,CAAC,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAQjG,CAAC;IAEH;;;;;;;;;OASG;IACI,MAAM,OAAO,GAAI,CAAC,EACxB,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KACvC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAS5B,CAAC;CACF"}
@@ -1,128 +0,0 @@
1
- import { Option } from "../Core/Option.js";
2
- /**
3
- * String utilities. All transformation functions are data-last and curried so they
4
- * compose naturally with `pipe`. Safe parsers return `Option` instead of `NaN`.
5
- *
6
- * @example
7
- * ```ts
8
- * import { Str } from "@nlozgachev/pipelined/utils";
9
- * import { pipe } from "@nlozgachev/pipelined/composition";
10
- *
11
- * pipe(" Hello, World! ", Str.trim, Str.toLowerCase); // "hello, world!"
12
- * ```
13
- */
14
- export declare namespace Str {
15
- /**
16
- * Splits a string by a separator. Data-last: use in `pipe`.
17
- *
18
- * @example
19
- * ```ts
20
- * pipe("a,b,c", Str.split(",")); // ["a", "b", "c"]
21
- * ```
22
- */
23
- const split: (separator: string | RegExp) => (s: string) => readonly string[];
24
- /**
25
- * Removes leading and trailing whitespace from a string.
26
- *
27
- * @example
28
- * ```ts
29
- * pipe(" hello ", Str.trim); // "hello"
30
- * ```
31
- */
32
- const trim: (s: string) => string;
33
- /**
34
- * Returns `true` when the string contains the given substring.
35
- *
36
- * @example
37
- * ```ts
38
- * pipe("hello world", Str.includes("world")); // true
39
- * pipe("hello world", Str.includes("xyz")); // false
40
- * ```
41
- */
42
- const includes: (substring: string) => (s: string) => boolean;
43
- /**
44
- * Returns `true` when the string starts with the given prefix.
45
- *
46
- * @example
47
- * ```ts
48
- * pipe("hello world", Str.startsWith("hello")); // true
49
- * pipe("hello world", Str.startsWith("world")); // false
50
- * ```
51
- */
52
- const startsWith: (prefix: string) => (s: string) => boolean;
53
- /**
54
- * Returns `true` when the string ends with the given suffix.
55
- *
56
- * @example
57
- * ```ts
58
- * pipe("hello world", Str.endsWith("world")); // true
59
- * pipe("hello world", Str.endsWith("hello")); // false
60
- * ```
61
- */
62
- const endsWith: (suffix: string) => (s: string) => boolean;
63
- /**
64
- * Converts a string to uppercase.
65
- *
66
- * @example
67
- * ```ts
68
- * pipe("hello", Str.toUpperCase); // "HELLO"
69
- * ```
70
- */
71
- const toUpperCase: (s: string) => string;
72
- /**
73
- * Converts a string to lowercase.
74
- *
75
- * @example
76
- * ```ts
77
- * pipe("HELLO", Str.toLowerCase); // "hello"
78
- * ```
79
- */
80
- const toLowerCase: (s: string) => string;
81
- /**
82
- * Splits a string into lines, normalising `\r\n` and `\r` line endings.
83
- *
84
- * @example
85
- * ```ts
86
- * Str.lines("one\ntwo\nthree"); // ["one", "two", "three"]
87
- * Str.lines("a\r\nb"); // ["a", "b"]
88
- * ```
89
- */
90
- const lines: (s: string) => readonly string[];
91
- /**
92
- * Splits a string into words on any whitespace boundary, filtering out empty strings.
93
- *
94
- * @example
95
- * ```ts
96
- * Str.words(" hello world "); // ["hello", "world"]
97
- * ```
98
- */
99
- const words: (s: string) => readonly string[];
100
- /**
101
- * Safe number parsers that return `Option` instead of `NaN`.
102
- */
103
- const parse: {
104
- /**
105
- * Parses a string as an integer (base 10). Returns `None` if the result is `NaN`.
106
- *
107
- * @example
108
- * ```ts
109
- * Str.parse.int("42"); // Some(42)
110
- * Str.parse.int("3.7"); // Some(3)
111
- * Str.parse.int("abc"); // None
112
- * ```
113
- */
114
- int: (s: string) => Option<number>;
115
- /**
116
- * Parses a string as a floating-point number. Returns `None` if the result is `NaN`.
117
- *
118
- * @example
119
- * ```ts
120
- * Str.parse.float("3.14"); // Some(3.14)
121
- * Str.parse.float("42"); // Some(42)
122
- * Str.parse.float("abc"); // None
123
- * ```
124
- */
125
- float: (s: string) => Option<number>;
126
- };
127
- }
128
- //# sourceMappingURL=Str.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Str.d.ts","sourceRoot":"","sources":["../../../src/src/Utils/Str.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,yBAAiB,GAAG,CAAC;IACpB;;;;;;;OAOG;IACI,MAAM,KAAK,GAAI,WAAW,MAAM,GAAG,MAAM,MAAM,GAAG,MAAM,KAAG,SAAS,MAAM,EAAwB,CAAC;IAE1G;;;;;;;OAOG;IACI,MAAM,IAAI,GAAI,GAAG,MAAM,KAAG,MAAkB,CAAC;IAEpD;;;;;;;;OAQG;IACI,MAAM,QAAQ,GAAI,WAAW,MAAM,MAAM,GAAG,MAAM,KAAG,OAAgC,CAAC;IAE7F;;;;;;;;OAQG;IACI,MAAM,UAAU,GAAI,QAAQ,MAAM,MAAM,GAAG,MAAM,KAAG,OAA+B,CAAC;IAE3F;;;;;;;;OAQG;IACI,MAAM,QAAQ,GAAI,QAAQ,MAAM,MAAM,GAAG,MAAM,KAAG,OAA6B,CAAC;IAEvF;;;;;;;OAOG;IACI,MAAM,WAAW,GAAI,GAAG,MAAM,KAAG,MAAyB,CAAC;IAElE;;;;;;;OAOG;IACI,MAAM,WAAW,GAAI,GAAG,MAAM,KAAG,MAAyB,CAAC;IAElE;;;;;;;;OAQG;IACI,MAAM,KAAK,GAAI,GAAG,MAAM,KAAG,SAAS,MAAM,EAAyB,CAAC;IAE3E;;;;;;;OAOG;IACI,MAAM,KAAK,GAAI,GAAG,MAAM,KAAG,SAAS,MAAM,EAA2C,CAAC;IAE7F;;OAEG;IACI,MAAM,KAAK;QACjB;;;;;;;;;WASG;iBACM,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC;QAKhC;;;;;;;;;WASG;mBACQ,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC;KAIlC,CAAC;CACF"}
@@ -1,5 +0,0 @@
1
- export * from "./Arr.js";
2
- export * from "./Rec.js";
3
- export * from "./Num.js";
4
- export * from "./Str.js";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}