@tempots/std 0.10.7 → 0.12.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.
@@ -0,0 +1,230 @@
1
+ import { AsyncResult as l } from "./async-result.js";
2
+ const t = {
3
+ /**
4
+ * Creates a valid `Validation`.
5
+ * @returns A `Validation` that is `Valid`.
6
+ */
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ valid: { type: "valid" },
9
+ /**
10
+ * Creates an invalid `Validation`.
11
+ * @param error - The error associated with the invalid value.
12
+ * @returns A `Validation` that is `Invalid`.
13
+ */
14
+ invalid(e) {
15
+ return { type: "invalid", error: e };
16
+ },
17
+ /**
18
+ * Checks if a `Validation` is `Valid`.
19
+ * @param r - The `Validation` to check.
20
+ * @returns `true` if the `Validation` is `Valid`, otherwise `false`.
21
+ */
22
+ isValid(e) {
23
+ return e.type === "valid";
24
+ },
25
+ /**
26
+ * Checks if a `Validation` is `Invalid`.
27
+ * @param r - The `Validation` to check.
28
+ * @returns `true` if the `Validation` is `Invalid`, otherwise `false`.
29
+ */
30
+ isInvalid(e) {
31
+ return e.type === "invalid";
32
+ },
33
+ /**
34
+ * Maps the value of a `Validation` to a new value.
35
+ * @param r - The `Validation` to map.
36
+ * @param valid - The mapping function for a valid value.
37
+ * @param invalid - The mapping function for an invalid value.
38
+ * @returns The mapped value.
39
+ */
40
+ match: (e, s, r) => t.isValid(e) ? s() : r(e.error),
41
+ /**
42
+ * Maps the value of a `Validation` to a new `Validation`.
43
+ * @param validation - The `Validation` to map.
44
+ * @param value - The value to map.
45
+ * @returns A new `Validation` with the mapped value.
46
+ */
47
+ toResult: (e, s) => t.match(
48
+ e,
49
+ () => u.success(s),
50
+ (r) => u.failure(r)
51
+ ),
52
+ /**
53
+ * Execute a function when the `Validation` is valid.
54
+ *
55
+ * @param r - The `Validation` to check.
56
+ * @param apply - The function to execute when the `Validation` is valid.
57
+ * @returns The `Validation` object.
58
+ */
59
+ whenValid: (e, s) => (t.isValid(e) && s(), e),
60
+ /**
61
+ * Execute a function when the `Validation` is invalid.
62
+ *
63
+ * @param r - The `Validation` to check.
64
+ * @param apply - The function to execute when the `Validation` is invalid.
65
+ * @returns The `Validation` object.
66
+ */
67
+ whenInvalid: (e, s) => (t.isInvalid(e) && s(e.error), e)
68
+ }, u = {
69
+ /**
70
+ * Creates a successful `Result`.
71
+ * @param value - The value to wrap in a `Success` type.
72
+ * @returns A `Result` that is a `Success`.
73
+ * @public
74
+ */
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+ success(e) {
77
+ return { type: "Success", value: e };
78
+ },
79
+ /**
80
+ * Creates a failure `Result`.
81
+ * @param error - The error to wrap in a `Failure` type.
82
+ * @returns A `Result` that is a `Failure`.
83
+ * @public
84
+ */
85
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
+ failure(e) {
87
+ return { type: "Failure", error: e };
88
+ },
89
+ /**
90
+ * Maps the value of a `Result` to a new value.
91
+ * @param r - The `Result` to map.
92
+ * @param f - The mapping function.
93
+ * @returns A new `Result` with the mapped value.
94
+ * @public
95
+ */
96
+ map: (e, s) => e.type === "Success" ? u.success(s(e.value)) : e,
97
+ /**
98
+ * Maps the value of a `Result` to a new `Result`.
99
+ * @param r - The `Result` to map.
100
+ * @param f - The mapping function.
101
+ * @returns A new `Result` with the mapped value.
102
+ * @public
103
+ */
104
+ flatMap: (e, s) => e.type === "Success" ? s(e.value) : e,
105
+ /**
106
+ * Converts a `Result` to an `AsyncResult`.
107
+ * @param r - The `Result` to convert.
108
+ * @returns An `AsyncResult` that is equivalent to the input `Result`.
109
+ * @public
110
+ */
111
+ toAsync(e) {
112
+ return u.match(
113
+ e,
114
+ (s) => l.success(s),
115
+ (s) => l.failure(s)
116
+ );
117
+ },
118
+ /**
119
+ * Converts a `Result` to a `Validation`.
120
+ * @param r - The `Result` to convert.
121
+ * @returns A `Validation` that is equivalent to the input `Result`.
122
+ * @public
123
+ */
124
+ toValidation(e) {
125
+ return u.match(
126
+ e,
127
+ () => t.valid,
128
+ (s) => t.invalid(s)
129
+ );
130
+ },
131
+ /**
132
+ * Checks if a `Result` is a success.
133
+ * @param r - The `Result` to check.
134
+ * @returns `true` if the `Result` is a `Success`, `false` otherwise.
135
+ * @public
136
+ */
137
+ isSuccess(e) {
138
+ return e.type === "Success";
139
+ },
140
+ /**
141
+ * Checks if a `Result` is a failure.
142
+ * @param r - The `Result` to check.
143
+ * @returns `true` if the `Result` is a `Failure`, `false` otherwise.
144
+ * @public
145
+ */
146
+ isFailure(e) {
147
+ return e.type === "Failure";
148
+ },
149
+ /**
150
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns the provided default value.
151
+ * @param r - The `Result` to get the value from.
152
+ * @param alt - The default value to return if the `Result` is a `Failure`.
153
+ * @returns The value of the `Result` if it is a `Success`, otherwise the default value.
154
+ * @public
155
+ */
156
+ getOrElse(e, s) {
157
+ return u.isSuccess(e) ? e.value : s;
158
+ },
159
+ /**
160
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns the result of the provided function.
161
+ * @param r - The `Result` to get the value from.
162
+ * @param altf - The function to call if the `Result` is a `Failure`.
163
+ * @returns The value of the `Result` if it is a `Success`, otherwise the result of the function.
164
+ * @public
165
+ */
166
+ getOrElseLazy(e, s) {
167
+ return u.isSuccess(e) ? e.value : s();
168
+ },
169
+ /**
170
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns `null`.
171
+ * @param r - The `Result` to get the value from.
172
+ * @returns The value of the `Result` if it is a `Success`, otherwise `null`.
173
+ * @public
174
+ */
175
+ getOrNull(e) {
176
+ return u.isSuccess(e) ? e.value : null;
177
+ },
178
+ /**
179
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns `undefined`.
180
+ * @param r - The `Result` to get the value from.
181
+ * @returns The value of the `Result` if it is a `Success`, otherwise `undefined`.
182
+ * @public
183
+ */
184
+ getOrUndefined(e) {
185
+ return u.isSuccess(e) ? e.value : void 0;
186
+ },
187
+ /**
188
+ * Based on the state of the result, it picks the appropriate function to call and returns the result.
189
+ * @param success - The function to call if the result is a success.
190
+ * @param failure - The function to call if the result is a failure.
191
+ * @returns The result of calling the appropriate function based on the state of the result.
192
+ * @public
193
+ */
194
+ match: (e, s, r) => u.isSuccess(e) ? s(e.value) : r(e.error),
195
+ /**
196
+ * Calls the provided function if the result is a success.
197
+ * @param apply - The function to call if the result is a success.
198
+ * @returns A function that takes a `Result` and calls the provided function if the result is a success.
199
+ * @public
200
+ */
201
+ whenSuccess: (e, s) => (u.isSuccess(e) && s(e.value), e),
202
+ whenFailure: (e, s) => (u.isFailure(e) && s(e.error), e),
203
+ /**
204
+ * Combines two results into a single result.
205
+ * @param r1 - The first result.
206
+ * @param r2 - The second result.
207
+ * @param combineV - The function to combine two values.
208
+ * @param combineE - The function to combine two errors.
209
+ * @returns The combined result.
210
+ * @public
211
+ */
212
+ combine: (e, s, r, c) => u.match(
213
+ e,
214
+ (a) => u.match(
215
+ s,
216
+ (i) => u.success(r(a, i)),
217
+ (i) => u.failure(i)
218
+ ),
219
+ (a) => u.match(
220
+ s,
221
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
222
+ (i) => u.failure(a),
223
+ (i) => u.failure(c(a, i))
224
+ )
225
+ )
226
+ };
227
+ export {
228
+ u as R,
229
+ t as V
230
+ };
@@ -0,0 +1 @@
1
+ "use strict";const a=require("./async-result.cjs"),i={valid:{type:"valid"},invalid(e){return{type:"invalid",error:e}},isValid(e){return e.type==="valid"},isInvalid(e){return e.type==="invalid"},match:(e,s,t)=>i.isValid(e)?s():t(e.error),toResult:(e,s)=>i.match(e,()=>u.success(s),t=>u.failure(t)),whenValid:(e,s)=>(i.isValid(e)&&s(),e),whenInvalid:(e,s)=>(i.isInvalid(e)&&s(e.error),e)},u={success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},map:(e,s)=>e.type==="Success"?u.success(s(e.value)):e,flatMap:(e,s)=>e.type==="Success"?s(e.value):e,toAsync(e){return u.match(e,s=>a.AsyncResult.success(s),s=>a.AsyncResult.failure(s))},toValidation(e){return u.match(e,()=>i.valid,s=>i.invalid(s))},isSuccess(e){return e.type==="Success"},isFailure(e){return e.type==="Failure"},getOrElse(e,s){return u.isSuccess(e)?e.value:s},getOrElseLazy(e,s){return u.isSuccess(e)?e.value:s()},getOrNull(e){return u.isSuccess(e)?e.value:null},getOrUndefined(e){return u.isSuccess(e)?e.value:void 0},match:(e,s,t)=>u.isSuccess(e)?s(e.value):t(e.error),whenSuccess:(e,s)=>(u.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(u.isFailure(e)&&s(e.error),e),combine:(e,s,t,c)=>u.match(e,l=>u.match(s,r=>u.success(t(l,r)),r=>u.failure(r)),l=>u.match(s,r=>u.failure(l),r=>u.failure(c(l,r))))};exports.Result=u;exports.Validation=i;
package/result.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u={success(e){return{type:"success",value:e}},failure(e){return{type:"failure",error:e}},cmap:e=>s=>s.type==="success"?u.success(e(s.value)):s,map:(e,s)=>e.type==="success"?u.success(s(e.value)):e,cflatMap:e=>s=>s.type==="success"?e(s.value):s,flatMap:(e,s)=>e.type==="success"?s(e.value):e,toAsync(e){return e},isSuccess(e){return e.type==="success"},isFailure(e){return e.type==="failure"},getOrElse(e,s){return u.isSuccess(e)?e.value:s},getOrElseLazy(e,s){return u.isSuccess(e)?e.value:s()},getOrNull(e){return u.isSuccess(e)?e.value:null},getOrUndefined(e){return u.isSuccess(e)?e.value:void 0},cmatch:(e,s)=>t=>u.isSuccess(t)?e(t.value):s(t.error),match:(e,s,t)=>u.isSuccess(e)?s(e.value):t(e.error),whenSuccess:e=>s=>(u.isSuccess(s)&&e(s.value),s),whenFailure:e=>s=>(u.isFailure(s)&&e(s.error),s),combine:(e,s,t,l)=>u.match(e,r=>u.match(s,c=>u.success(t(r,c)),c=>u.failure(c)),r=>u.match(s,c=>u.failure(r),c=>u.failure(l(r,c))))};exports.Result=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./async-result.cjs");const e=require("./result-DzdZiQoR.cjs");exports.Result=e.Result;
package/result.d.ts CHANGED
@@ -1,32 +1,156 @@
1
1
  import { AsyncResult } from './async-result';
2
+ import { Maybe } from './domain';
3
+ import { Validation } from './validation';
2
4
 
5
+ /**
6
+ * Represents a successful result.
7
+ * @typeParam V - The type of the value.
8
+ * @public
9
+ */
3
10
  export interface Success<V> {
4
- type: 'success';
11
+ type: 'Success';
5
12
  value: V;
6
13
  }
14
+ /**
15
+ * Represents a failure result.
16
+ * @typeParam E - The type of the error.
17
+ * @public
18
+ */
7
19
  export interface Failure<E> {
8
- type: 'failure';
20
+ type: 'Failure';
9
21
  error: E;
10
22
  }
23
+ /**
24
+ * Represents a result that can either be a success or a failure.
25
+ * @typeParam V - The type of the value in case of success.
26
+ * @typeParam E - The type of the error in case of failure.
27
+ * @public
28
+ */
11
29
  export type Result<V, E> = Success<V> | Failure<E>;
30
+ /**
31
+ * Represents a promise that resolves to a `Result` type.
32
+ * @typeParam V - The type of the value contained in the `Result`.
33
+ * @typeParam E - The type of the error contained in the `Result`.
34
+ * @public
35
+ */
12
36
  export type PromiseResult<V, E> = PromiseLike<Result<V, E>>;
37
+ /**
38
+ * Utility functions for working with `Result` types.
39
+ * @public
40
+ */
13
41
  export declare const Result: {
42
+ /**
43
+ * Creates a successful `Result`.
44
+ * @param value - The value to wrap in a `Success` type.
45
+ * @returns A `Result` that is a `Success`.
46
+ * @public
47
+ */
14
48
  success<V>(value: V): Result<V, any>;
49
+ /**
50
+ * Creates a failure `Result`.
51
+ * @param error - The error to wrap in a `Failure` type.
52
+ * @returns A `Result` that is a `Failure`.
53
+ * @public
54
+ */
15
55
  failure<E>(error: E): Result<any, E>;
16
- cmap: <V1, V2, E>(f: (value: V1) => V2) => (r: Result<V1, E>) => Result<V2, E>;
56
+ /**
57
+ * Maps the value of a `Result` to a new value.
58
+ * @param r - The `Result` to map.
59
+ * @param f - The mapping function.
60
+ * @returns A new `Result` with the mapped value.
61
+ * @public
62
+ */
17
63
  map: <V1, V2, E>(r: Result<V1, E>, f: (value: V1) => V2) => Result<V2, E>;
18
- cflatMap: <V1, V2, E>(f: (value: V1) => Result<V2, E>) => (r: Result<V1, E>) => Result<V2, E>;
64
+ /**
65
+ * Maps the value of a `Result` to a new `Result`.
66
+ * @param r - The `Result` to map.
67
+ * @param f - The mapping function.
68
+ * @returns A new `Result` with the mapped value.
69
+ * @public
70
+ */
19
71
  flatMap: <V1, V2, E>(r: Result<V1, E>, f: (value: V1) => Result<V2, E>) => Result<V2, E>;
72
+ /**
73
+ * Converts a `Result` to an `AsyncResult`.
74
+ * @param r - The `Result` to convert.
75
+ * @returns An `AsyncResult` that is equivalent to the input `Result`.
76
+ * @public
77
+ */
20
78
  toAsync<V, E>(r: Result<V, E>): AsyncResult<V, E>;
79
+ /**
80
+ * Converts a `Result` to a `Validation`.
81
+ * @param r - The `Result` to convert.
82
+ * @returns A `Validation` that is equivalent to the input `Result`.
83
+ * @public
84
+ */
85
+ toValidation<V, E>(r: Result<V, E>): Validation<E>;
86
+ /**
87
+ * Checks if a `Result` is a success.
88
+ * @param r - The `Result` to check.
89
+ * @returns `true` if the `Result` is a `Success`, `false` otherwise.
90
+ * @public
91
+ */
21
92
  isSuccess<V, E>(r: Result<V, E>): r is Success<V>;
93
+ /**
94
+ * Checks if a `Result` is a failure.
95
+ * @param r - The `Result` to check.
96
+ * @returns `true` if the `Result` is a `Failure`, `false` otherwise.
97
+ * @public
98
+ */
22
99
  isFailure<V, E>(r: Result<V, E>): r is Failure<E>;
100
+ /**
101
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns the provided default value.
102
+ * @param r - The `Result` to get the value from.
103
+ * @param alt - The default value to return if the `Result` is a `Failure`.
104
+ * @returns The value of the `Result` if it is a `Success`, otherwise the default value.
105
+ * @public
106
+ */
23
107
  getOrElse<V, E>(r: Result<V, E>, alt: V): V;
108
+ /**
109
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns the result of the provided function.
110
+ * @param r - The `Result` to get the value from.
111
+ * @param altf - The function to call if the `Result` is a `Failure`.
112
+ * @returns The value of the `Result` if it is a `Success`, otherwise the result of the function.
113
+ * @public
114
+ */
24
115
  getOrElseLazy<V, E>(r: Result<V, E>, altf: () => V): V;
116
+ /**
117
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns `null`.
118
+ * @param r - The `Result` to get the value from.
119
+ * @returns The value of the `Result` if it is a `Success`, otherwise `null`.
120
+ * @public
121
+ */
25
122
  getOrNull<V, E>(r: Result<V, E>): V | null;
26
- getOrUndefined<V, E>(r: Result<V, E>): V | undefined;
27
- cmatch: <V1, V2, E>(success: (value: V1) => V2, failure: (error: E) => V2) => (r: Result<V1, E>) => V2;
123
+ /**
124
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns `undefined`.
125
+ * @param r - The `Result` to get the value from.
126
+ * @returns The value of the `Result` if it is a `Success`, otherwise `undefined`.
127
+ * @public
128
+ */
129
+ getOrUndefined<V, E>(r: Result<V, E>): Maybe<V>;
130
+ /**
131
+ * Based on the state of the result, it picks the appropriate function to call and returns the result.
132
+ * @param success - The function to call if the result is a success.
133
+ * @param failure - The function to call if the result is a failure.
134
+ * @returns The result of calling the appropriate function based on the state of the result.
135
+ * @public
136
+ */
28
137
  match: <V1, V2, E>(r: Result<V1, E>, success: (value: V1) => V2, failure: (error: E) => V2) => V2;
29
- whenSuccess: <V, E>(apply: (v: V) => void) => (r: Result<V, E>) => Result<V, E>;
30
- whenFailure: <V, E>(apply: (e: E) => void) => (r: Result<V, E>) => Result<V, E>;
138
+ /**
139
+ * Calls the provided function if the result is a success.
140
+ * @param apply - The function to call if the result is a success.
141
+ * @returns A function that takes a `Result` and calls the provided function if the result is a success.
142
+ * @public
143
+ */
144
+ whenSuccess: <V, E>(r: Result<V, E>, apply: (v: V) => void) => Result<V, E>;
145
+ whenFailure: <V, E>(r: Result<V, E>, apply: (e: E) => void) => Result<V, E>;
146
+ /**
147
+ * Combines two results into a single result.
148
+ * @param r1 - The first result.
149
+ * @param r2 - The second result.
150
+ * @param combineV - The function to combine two values.
151
+ * @param combineE - The function to combine two errors.
152
+ * @returns The combined result.
153
+ * @public
154
+ */
31
155
  combine: <V, E>(r1: Result<V, E>, r2: Result<V, E>, combineV: (v1: V, v2: V) => V, combineE: (e1: E, e2: E) => E) => Result<V, E>;
32
156
  };
package/result.js CHANGED
@@ -1,56 +1,5 @@
1
- const u = {
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
- success(e) {
4
- return { type: "success", value: e };
5
- },
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- failure(e) {
8
- return { type: "failure", error: e };
9
- },
10
- cmap: (e) => (s) => s.type === "success" ? u.success(e(s.value)) : s,
11
- map: (e, s) => e.type === "success" ? u.success(s(e.value)) : e,
12
- cflatMap: (e) => (s) => s.type === "success" ? e(s.value) : s,
13
- flatMap: (e, s) => e.type === "success" ? s(e.value) : e,
14
- toAsync(e) {
15
- return e;
16
- },
17
- isSuccess(e) {
18
- return e.type === "success";
19
- },
20
- isFailure(e) {
21
- return e.type === "failure";
22
- },
23
- getOrElse(e, s) {
24
- return u.isSuccess(e) ? e.value : s;
25
- },
26
- getOrElseLazy(e, s) {
27
- return u.isSuccess(e) ? e.value : s();
28
- },
29
- getOrNull(e) {
30
- return u.isSuccess(e) ? e.value : null;
31
- },
32
- getOrUndefined(e) {
33
- return u.isSuccess(e) ? e.value : void 0;
34
- },
35
- cmatch: (e, s) => (c) => u.isSuccess(c) ? e(c.value) : s(c.error),
36
- match: (e, s, c) => u.isSuccess(e) ? s(e.value) : c(e.error),
37
- whenSuccess: (e) => (s) => (u.isSuccess(s) && e(s.value), s),
38
- whenFailure: (e) => (s) => (u.isFailure(s) && e(s.error), s),
39
- combine: (e, s, c, l) => u.match(
40
- e,
41
- (t) => u.match(
42
- s,
43
- (r) => u.success(c(t, r)),
44
- (r) => u.failure(r)
45
- ),
46
- (t) => u.match(
47
- s,
48
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
- (r) => u.failure(t),
50
- (r) => u.failure(l(t, r))
51
- )
52
- )
53
- };
1
+ import "./async-result.js";
2
+ import { R as e } from "./result-Czm7RKNP.js";
54
3
  export {
55
- u as Result
4
+ e as Result
56
5
  };
package/string.cjs CHANGED
@@ -1,3 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./array.cjs"),A=require("./regexp.cjs");function l(n,t,e){return n.split(t).join(e)}function U(n,t){const e=n.indexOf(t);return e<0?"":n.substring(e+t.length)}function _(n,t){const e=n.lastIndexOf(t);return e<0?"":n.substring(e+t.length)}function k(n,t){const e=n.indexOf(t);return e<0?"":n.substring(0,e)}function q(n,t){const e=n.lastIndexOf(t);return e<0?"":n.substring(0,e)}function h(n){return n.substring(0,1).toUpperCase()+n.substring(1)}const m=n=>n.toUpperCase();function $(n,t=!1){return t?A.map(h(n),Fn,m):A.map(h(n),Rn,m)}function P(n){return n.replace(Jn,`
2
- `)}function x(n,t){return n==null&&t==null?0:n==null?-1:t==null?1:I(n.toLowerCase(),t.toLowerCase())}function d(n,t){return n.substring(0,n.length-t.length)===t}function R(n,t){return n.substring(0,n.length-t.length).toLowerCase()===t.toLowerCase()}function L(n,t){return n.substring(0,t.length)===t}function Z(n,t){return n.substring(0,t.length).toLowerCase()===t.toLowerCase()}function D(n,t){return y(n.toLowerCase(),t.map(e=>e.toLowerCase()))}function F(n,t){return O(n.toLowerCase(),t.map(e=>e.toLowerCase()))}function G(n){return n.trim().replace(M," ")}function I(n,t){return n<t?-1:n>t?1:0}function C(n,t){return n.toLowerCase().includes(t.toLowerCase())}function a(n,t){return n.includes(t)}function H(n,t){return n.split(t).length-1}function K(n,t){return u.any(t,e=>C(n,e))}function J(n,t){return u.any(t,e=>a(n,e))}function Q(n,t){return u.all(t,e=>C(n,e))}function V(n,t){return u.all(t,e=>a(n,e))}function X(n){return n.replace("_","-")}function Y(n,t){const e=Math.min(n.length,t.length);for(let r=0;r<e;r++)if(n.substring(r,r+1)!==t.substring(r,r+1))return r;return e}function w(n,t=20,e="…"){const r=n.length,i=e.length;return r>t?t<i?e.substr(i-t,t):n.substr(0,t-i)+e:n}function v(n,t=20,e="…"){const r=n.length,i=e.length;if(r>t){if(t<=i)return w(n,t,e);const c=Math.ceil((t-i)/2),f=Math.floor((t-i)/2);return n.substr(0,c)+e+n.substr(r-f,f)}else return n}function y(n,t){return u.any(t,e=>d(n,e))}function nn(n,t){return p(n).filter(t).join("")}function tn(n,t){return z(n).filter(t).map(r=>String.fromCharCode(r)).join("")}function en(n,t){const e=n.indexOf(t);return e<0?"":n.substring(e)}function rn(n,t=2166136261){let e=t;for(let r=0,i=n.length;r<i;r++)e^=n.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function sn(n){return n!=null&&n.length>0}function on(n){return l(T(n),"_"," ")}function un(n){return n.length>0&&!Dn.test(n)}function cn(n){return Gn.test(n)}function fn(n){return!Zn.test(n)}function an(n){return n.toLowerCase()===n}function ln(n){return n.toUpperCase()===n}function pn(n,t){return n!=null&&n!==""?n:t}function hn(n){return Hn.test(n)}function gn(n){return n==null||n===""}function dn(n){return n.substring(0,1).toLowerCase()+n.substring(1)}function W(n,t=1){return n.substring(Math.floor((n.length-t+1)*Math.random()),t)}function S(n,t){return u.range(t,()=>W(n)).join("")}function Cn(n){return S(xn,n)}function bn(n,t){return p(t).map(n)}function An(n,t){return l(n,t,"")}function mn(n,t){return d(n,t)?n.substring(0,n.length-t.length):n}function Ln(n,t,e){return n.substring(0,t)+n.substring(t+e)}function In(n,t){return L(n,t)?n.substring(t.length):n}function wn(n,t){const e=n.indexOf(t);return e<0?n:n.substring(0,e)+n.substring(e+t.length)}function b(n,t){return u.fill(t,n).join("")}function yn(n){const t=p(n);return t.reverse(),t.join("")}function Wn(n){return n.includes('"')?n.includes("'")?'"'+l(n,'"','\\"')+'"':"'"+n+"'":'"'+n+'"'}function Sn(n,t){const e=n.indexOf(t);return e<0?[n]:[n.substring(0,e),n.substring(e+t.length)]}function O(n,t){return u.any(t,e=>n.startsWith(e))}function On(n){return n.replace(Kn,"")}function zn(n,t,e=t){return`${t}${n}${e}`}function p(n){return n.split("")}function z(n){return u.range(n.length,t=>n.charCodeAt(t))}function Bn(n,t){const e=[];for(;n.length>0;)e.push(n.substring(0,t)),n=n.substr(t,n.length-t);return e}function En(n){return n.split(N)}function Tn(n,t){return E(B(n,t),t)}function B(n,t){let e=0;for(let r=0;r<n.length&&a(t,n.charAt(r));r++)e++;return n.substring(e)}function E(n,t){const e=n.length;let r=e,i;for(let c=0;c<e&&(i=e-c-1,a(t,n.charAt(i)));c++)r=i;return n.substring(0,r)}function T(n){return n=n.replace(/::/g,"/"),n=n.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2"),n=n.replace(/([a-z\d])([A-Z])/g,"$1_$2"),n=n.replace(/-/g,"_"),n.toLowerCase()}function jn(n){return n.substring(0,1).toUpperCase()+n.substring(1)}function Mn(n,t){const e=n.indexOf(t);return e<0?n:n.substring(0,e)}function Nn(n,t=78,e="",r=`
3
- `){return n.split(N).map(i=>j(i.replace(M," ").trim(),t,e,r)).join(r)}function g(n,t){if(t<0||t>=n.length)return!1;const e=n.charCodeAt(t);return e===9||e===10||e===11||e===12||e===13||e===32}function Un(n){if(typeof Buffer<"u")return Buffer.from(n).toString("base64");if(typeof btoa<"u")return btoa(n);throw new Error("no implementation provided for base64 encoding")}function _n(n){if(typeof Buffer<"u")return Buffer.from(n,"base64").toString("utf8");if(typeof atob<"u")return atob(n);throw new Error("no implementation provided for base64 decoding")}function j(n,t,e,r){const i=[],c=n.length,f=e.length;let o=0;for(t-=f;;){if(o+t>=c-f){i.push(n.substring(o));break}let s=0;for(;!g(n,o+t-s)&&s<t;)s++;if(s===t){for(s=0;!g(n,o+t+s)&&o+t+s<c;)s++;i.push(n.substring(o,o+t+s)),o+=t+s+1}else i.push(n.substring(o,o+t-s)),o+=t-s+1}return e+i.join(r+e)}function kn(n,t,e){const r=e-n.length;return r>0?b(t,r)+n:n}function qn(n,t,e){const r=e-n.length;return r>0?n+b(t,r):n}function $n(n,t){const e=n.lastIndexOf(t);return e>=0?[n.substring(0,e),n.substring(e+t.length)]:[n]}function Pn(n,t){const e=n.indexOf(t);return e>=0?[n.substring(0,e),n.substring(e+t.length)]:[n]}const xn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rn=/[^a-zA-Z]([a-z])/g,Zn=/[^\t\n\r ]/,Dn=/[^a-zA-Z]/,Fn=/[ \t\r\n][a-z]/g,Gn=/^[a-z0-9]+$/i,Hn=/^[0-9]+$/,Kn=/<\/?[a-z]+[^>]*>/gi,M=/[ \t\r\n]+/g,N=/\r\n|\n\r|\n|\r/g,Jn=/\r\n|\n\r|\r/g;exports.after=U;exports.afterLast=_;exports.before=k;exports.beforeLast=q;exports.canonicalizeNewlines=P;exports.capitalize=h;exports.capitalizeWords=$;exports.collapse=G;exports.compare=I;exports.compareCaseInsensitive=x;exports.contains=a;exports.containsAll=V;exports.containsAllCaseInsensitive=Q;exports.containsAny=J;exports.containsAnyCaseInsensitive=K;exports.containsCaseInsensitive=C;exports.count=H;exports.dasherize=X;exports.decodeBase64=_n;exports.diffIndex=Y;exports.ellipsis=w;exports.ellipsisMiddle=v;exports.encodeBase64=Un;exports.endsWith=d;exports.endsWithAny=y;exports.endsWithAnyCaseInsensitive=D;exports.endsWithCaseInsensitive=R;exports.filter=nn;exports.filterCharcode=tn;exports.from=en;exports.hasContent=sn;exports.hashCode=rn;exports.humanize=on;exports.ifEmpty=pn;exports.isAlpha=un;exports.isAlphaNum=cn;exports.isBreakingWhitespace=fn;exports.isDigitsOnly=hn;exports.isEmpty=gn;exports.isLowerCase=an;exports.isSpaceAt=g;exports.isUpperCase=ln;exports.lowerCaseFirst=dn;exports.lpad=kn;exports.map=bn;exports.quote=Wn;exports.random=W;exports.randomSequence=S;exports.randomSequence64=Cn;exports.remove=An;exports.removeAfter=mn;exports.removeAt=Ln;exports.removeBefore=In;exports.removeOne=wn;exports.repeat=b;exports.replace=l;exports.reverse=yn;exports.rpad=qn;exports.splitOnFirst=Pn;exports.splitOnLast=$n;exports.splitOnce=Sn;exports.startsWith=L;exports.startsWithAny=O;exports.startsWithAnyCaseInsensitive=F;exports.startsWithCaseInsensitive=Z;exports.stripTags=On;exports.surround=zn;exports.toArray=p;exports.toCharcodes=z;exports.toChunks=Bn;exports.toLines=En;exports.trimChars=Tn;exports.trimCharsLeft=B;exports.trimCharsRight=E;exports.underscore=T;exports.upTo=Mn;exports.upperCaseFirst=jn;exports.wrapColumns=Nn;exports.wrapLine=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./array.cjs"),A=require("./regexp.cjs");function c(n,t,e){return n.split(t).join(e)}function k(n,t){const e=n.indexOf(t);return e<0?"":n.substring(e+t.length)}function $(n,t){const e=n.lastIndexOf(t);return e<0?"":n.substring(e+t.length)}function R(n,t){const e=n.indexOf(t);return e<0?"":n.substring(0,e)}function T(n,t){const e=n.lastIndexOf(t);return e<0?"":n.substring(0,e)}function h(n){return n.substring(0,1).toUpperCase()+n.substring(1)}const m=n=>n.toUpperCase();function P(n,t=!1){return t?A.mapRegExp(h(n),Hn,m):A.mapRegExp(h(n),qn,m)}function Z(n){return n.replace(Kn,`
2
+ `)}function q(n,t){return n==null&&t==null?0:n==null?-1:t==null?1:w(n.toLowerCase(),t.toLowerCase())}function d(n,t){return n.substring(0,n.length-t.length)===t}function D(n,t){return n.substring(0,n.length-t.length).toLowerCase()===t.toLowerCase()}function L(n,t){return n.substring(0,t.length)===t}function F(n,t){return n.substring(0,t.length).toLowerCase()===t.toLowerCase()}function H(n,t){return I(n.toLowerCase(),t.map(e=>e.toLowerCase()))}function Q(n,t){return z(n.toLowerCase(),t.map(e=>e.toLowerCase()))}function G(n){return n.trim().replace(U," ")}function w(n,t){return n<t?-1:n>t?1:0}function C(n,t){return n.toLowerCase().includes(t.toLowerCase())}function l(n,t){return n.includes(t)}function K(n,t){return n.split(t).length-1}function J(n,t){return u.anyElement(t,e=>C(n,e))}function V(n,t){return u.anyElement(t,e=>l(n,e))}function X(n,t){return u.allElements(t,e=>C(n,e))}function Y(n,t){return u.allElements(t,e=>l(n,e))}function v(n){return n.replace("_","-")}function nn(n,t){if(n===t)return-1;const e=Math.min(n.length,t.length);for(let r=0;r<e;r++)if(n.substring(r,r+1)!==t.substring(r,r+1))return r;return e}function y(n,t=20,e="…"){const r=n.length,i=e.length;return r>t?t<i?e.substr(i-t,t):n.substr(0,t-i)+e:n}function tn(n,t=20,e="…"){const r=n.length,i=e.length;if(r>t){if(t<=i)return y(n,t,e);const f=Math.ceil((t-i)/2),a=Math.floor((t-i)/2);return n.substr(0,f)+e+n.substr(r-a,a)}else return n}function I(n,t){return u.anyElement(t,e=>d(n,e))}function en(n,t){return p(n).filter(t).join("")}function rn(n,t){return B(n).filter(t).map(r=>String.fromCharCode(r)).join("")}function sn(n,t){const e=n.indexOf(t);return e<0?"":n.substring(e)}function on(n,t=2166136261){let e=t;for(let r=0,i=n.length;r<i;r++)e^=n.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function un(n){return n!=null&&n.length>0}function fn(n){return c(N(n),"_"," ")}function cn(n){return n.length>0&&!Fn.test(n)}function an(n){return Qn.test(n)}function ln(n){return!Dn.test(n)}function pn(n){return n.toLowerCase()===n}function hn(n){return n.toUpperCase()===n}function gn(n,t){return n!=null&&n!==""?n:t}function dn(n){return Gn.test(n)}function Cn(n){return n==null||n===""}function bn(n){return n.substring(0,1).toLowerCase()+n.substring(1)}function W(n,t=1){return n.substring(Math.floor((n.length-t+1)*Math.random()),t)}function O(n,t){return u.generateArray(t,()=>W(n)).join("")}function An(n){return O(Zn,n)}function mn(n,t){return p(t).map(n)}function Ln(n,t){return c(n,t,"")}function wn(n,t){return d(n,t)?n.substring(0,n.length-t.length):n}function yn(n,t,e){return n.substring(0,t)+n.substring(t+e)}function In(n,t){return L(n,t)?n.substring(t.length):n}function Wn(n,t){const e=n.indexOf(t);return e<0?n:n.substring(0,e)+n.substring(e+t.length)}function b(n,t){return u.createFilledArray(t,n).join("")}function On(n){const t=p(n);return t.reverse(),t.join("")}function S(n,t="'"){return t==="'"?n.includes("'")?n.includes('"')?"'"+c(n,"'","\\'")+"'":'"'+n+'"':"'"+n+"'":n.includes('"')?n.includes("'")?'"'+c(n,'"','\\"')+'"':"'"+n+"'":'"'+n+'"'}function E(n,t="'"){return t+c(n,t,"\\"+t)+t}function Sn(n,t="'"){return n.indexOf(`
3
+ `)>=0?E(n,"`"):S(n,t)}function En(n,t){const e=n.indexOf(t);return e<0?[n]:[n.substring(0,e),n.substring(e+t.length)]}function z(n,t){return u.anyElement(t,e=>n.startsWith(e))}function zn(n,t,e=t){return`${t}${n}${e}`}function p(n){return n.split("")}function B(n){return u.generateArray(n.length,t=>n.charCodeAt(t))}function Bn(n,t){const e=[];for(;n.length>0;)e.push(n.substring(0,t)),n=n.substr(t,n.length-t);return e}function jn(n){return n.split(_)}function Mn(n,t){return M(j(n,t),t)}function j(n,t){let e=0;for(let r=0;r<n.length&&l(t,n.charAt(r));r++)e++;return n.substring(e)}function M(n,t){const e=n.length;let r=e,i;for(let f=0;f<e&&(i=e-f-1,l(t,n.charAt(i)));f++)r=i;return n.substring(0,r)}function N(n){return n=n.replace(/::/g,"/"),n=n.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2"),n=n.replace(/([a-z\d])([A-Z])/g,"$1_$2"),n=n.replace(/-/g,"_"),n.toLowerCase()}function Nn(n){return n.substring(0,1).toUpperCase()+n.substring(1)}function xn(n,t){const e=n.indexOf(t);return e<0?n:n.substring(0,e)}function Un(n,t=78,e="",r=`
4
+ `){return n.split(_).map(i=>x(i.replace(U," ").trim(),t,e,r)).join(r)}function g(n,t){if(t<0||t>=n.length)return!1;const e=n.charCodeAt(t);return e===9||e===10||e===11||e===12||e===13||e===32}function _n(n){if(typeof Buffer<"u")return Buffer.from(n).toString("base64");if(typeof btoa<"u")return btoa(n);throw new Error("no implementation found for base64 encoding")}function kn(n){if(typeof Buffer<"u")return Buffer.from(n,"base64").toString("utf8");if(typeof atob<"u")return atob(n);throw new Error("no implementation found for base64 decoding")}function x(n,t,e,r){const i=[],f=n.length,a=e.length;let o=0;for(t-=a;;){if(o+t>=f-a){i.push(n.substring(o));break}let s=0;for(;!g(n,o+t-s)&&s<t;)s++;if(s===t){for(s=0;!g(n,o+t+s)&&o+t+s<f;)s++;i.push(n.substring(o,o+t+s)),o+=t+s+1}else i.push(n.substring(o,o+t-s)),o+=t-s+1}return e+i.join(r+e)}function $n(n,t,e){const r=e-n.length;return r>0?b(t,r)+n:n}function Rn(n,t,e){const r=e-n.length;return r>0?n+b(t,r):n}function Tn(n,t){const e=n.lastIndexOf(t);return e>=0?[n.substring(0,e),n.substring(e+t.length)]:[n]}function Pn(n,t){const e=n.indexOf(t);return e>=0?[n.substring(0,e),n.substring(e+t.length)]:[n]}const Zn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qn=/[^a-zA-Z]([a-z])/g,Dn=/[^\t\n\r ]/,Fn=/[^a-zA-Z]/,Hn=/[ \t\r\n][a-z]/g,Qn=/^[a-z0-9]+$/i,Gn=/^[0-9]+$/,U=/[ \t\r\n]+/g,_=/\r\n|\n\r|\n|\r/g,Kn=/\r\n|\n\r|\r/g;exports.after=k;exports.afterLast=$;exports.before=R;exports.beforeLast=T;exports.canonicalizeNewlines=Z;exports.capitalize=h;exports.capitalizeWords=P;exports.collapse=G;exports.compareCaseInsensitive=q;exports.compareStrings=w;exports.contains=l;exports.containsAll=Y;exports.containsAllCaseInsensitive=X;exports.containsAny=V;exports.containsAnyCaseInsensitive=J;exports.containsCaseInsensitive=C;exports.count=K;exports.dasherize=v;exports.decodeBase64=kn;exports.diffIndex=nn;exports.ellipsis=y;exports.ellipsisMiddle=tn;exports.encodeBase64=_n;exports.endsWith=d;exports.endsWithAny=I;exports.endsWithAnyCaseInsensitive=H;exports.endsWithCaseInsensitive=D;exports.filter=en;exports.filterCharcode=rn;exports.from=sn;exports.hasContent=un;exports.hashCode=on;exports.humanize=fn;exports.ifEmpty=gn;exports.isAlpha=cn;exports.isAlphaNum=an;exports.isBreakingWhitespace=ln;exports.isDigitsOnly=dn;exports.isEmpty=Cn;exports.isLowerCase=pn;exports.isSpaceAt=g;exports.isUpperCase=hn;exports.jsQuote=Sn;exports.lowerCaseFirst=bn;exports.lpad=$n;exports.map=mn;exports.quote=E;exports.random=W;exports.randomSequence=O;exports.randomSequence64=An;exports.remove=Ln;exports.removeAfter=wn;exports.removeAt=yn;exports.removeBefore=In;exports.removeOne=Wn;exports.repeat=b;exports.replace=c;exports.reverse=On;exports.rpad=Rn;exports.smartQuote=S;exports.splitOnFirst=Pn;exports.splitOnLast=Tn;exports.splitOnce=En;exports.startsWith=L;exports.startsWithAny=z;exports.startsWithAnyCaseInsensitive=Q;exports.startsWithCaseInsensitive=F;exports.surround=zn;exports.toArray=p;exports.toCharcodes=B;exports.toChunks=Bn;exports.toLines=jn;exports.trimChars=Mn;exports.trimCharsLeft=j;exports.trimCharsRight=M;exports.underscore=N;exports.upTo=xn;exports.upperCaseFirst=Nn;exports.wrapColumns=Un;exports.wrapLine=x;