@tempots/std 0.12.0 → 0.14.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.
package/number.js CHANGED
@@ -1,103 +1,45 @@
1
- import { lpad as l } from "./string.js";
2
- const p = 1e-4, f = 1e-9;
3
- function u(n, t, e = 360) {
4
- let r = (t - n) % e;
5
- return r < 0 && (r += e), r > e / 2 && (r -= e), r;
6
- }
7
- function h(n, t) {
8
- const e = Math.pow(10, t);
9
- return Math.ceil(n * e) / e;
10
- }
11
- function c(n, t, e) {
12
- return Math.min(Math.max(n, t), e);
13
- }
14
- function M(n, t, e) {
15
- return Math.trunc(c(n, t, e));
16
- }
17
- function g(n, t) {
18
- return c(n, -t, t);
19
- }
20
- function N(n, t) {
21
- return n < t ? -1 : n > t ? 1 : 0;
22
- }
23
- function w(n, t) {
24
- const e = Math.pow(10, t);
25
- return Math.floor(n * e) / e;
26
- }
27
- function A(n, t = 0) {
28
- return l(n.toString(16), "0", t);
29
- }
30
- function o(n, t, e) {
31
- return (t - n) * e + n;
32
- }
33
- function d(n, t, e, r = 360) {
34
- return i(o(n, n + u(n, t, r), e), r);
35
- }
36
- function a(n, t, e = 360) {
37
- let r = (t - n) % e;
38
- return r < 0 && (r += e), r > e / 2 && (r -= e), r;
39
- }
40
- function C(n, t, e, r = 360) {
41
- return i(
42
- o(n, n + a(n, t, r), e),
43
- r
44
- );
45
- }
46
- function E(n, t, e, r = 360) {
47
- return n = i(n, r), t = i(t, r), t < n && (t += r), i(o(n, t, e), r);
48
- }
49
- function T(n, t, e, r = 360) {
50
- return n = i(n, r), t = i(t, r), t > n && (t -= r), i(o(n, t, e), r);
51
- }
52
- function m(n, t, e = f) {
53
- return isFinite(n) ? isFinite(t) ? Math.abs(n - t) <= e : !1 : isNaN(n) ? isNaN(t) : isNaN(t) || isFinite(t) ? !1 : n > 0 == t > 0;
54
- }
55
- function F(n, t, e = 360, r = f) {
56
- return Math.abs(u(n, t, e)) <= r;
57
- }
58
- function S(n, t = f) {
59
- return Math.abs(n) <= t;
60
- }
61
- function W(n, t) {
62
- return Math.pow(n, 1 / t);
63
- }
64
- function q(n, t) {
65
- const e = Math.pow(10, t);
66
- return Math.round(n * e) / e;
67
- }
68
- function D(n) {
69
- return n < 0 ? -1 : 1;
70
- }
71
- function I(n, t, e) {
72
- const r = e - t + 1;
73
- return n < t && (n += r * ((t - n) / r + 1)), t + (n - t) % r;
74
- }
75
- function i(n, t) {
76
- return n = n % t, n < 0 && (n += t), n;
77
- }
1
+ import { lpad as a } from "./string.js";
2
+ const c = 1e-9, i = (t, e, n = 360) => {
3
+ let o = (e - t) % n;
4
+ return o < 0 && (o += n), o > n / 2 && (o -= n), o;
5
+ }, h = (t, e) => {
6
+ const n = Math.pow(10, e);
7
+ return Math.ceil(t * n) / n;
8
+ }, l = (t, e, n) => Math.min(Math.max(t, e), n), M = (t, e, n) => Math.trunc(l(t, e, n)), u = (t, e) => l(t, -e, e), g = (t, e) => t < e ? -1 : t > e ? 1 : 0, N = (t, e) => {
9
+ const n = Math.pow(10, e);
10
+ return Math.floor(t * n) / n;
11
+ }, w = (t, e = 0) => a(t.toString(16), "0", e), s = (t, e, n) => (e - t) * n + t, A = (t, e, n, o = 360) => r(s(t, t + i(t, e, o), n), o), f = (t, e, n = 360) => {
12
+ let o = (e - t) % n;
13
+ return o < 0 && (o += n), o > n / 2 && (o -= n), o;
14
+ }, d = (t, e, n, o = 360) => r(s(t, t + f(t, e, o), n), o), m = (t, e, n, o = 360) => (t = r(t, o), e = r(e, o), e < t && (e += o), r(s(t, e, n), o)), C = (t, e, n, o = 360) => (t = r(t, o), e = r(e, o), e > t && (e -= o), r(s(t, e, n), o)), E = (t, e, n = c) => isFinite(t) ? isFinite(e) ? Math.abs(t - e) <= n : !1 : isNaN(t) ? isNaN(e) : isNaN(e) || isFinite(e) ? !1 : t > 0 == e > 0, F = (t, e, n = 360, o = c) => Math.abs(i(t, e, n)) <= o, S = (t, e = c) => Math.abs(t) <= e, T = (t, e) => Math.pow(t, 1 / e), W = (t, e) => {
15
+ const n = Math.pow(10, e);
16
+ return Math.round(t * n) / n;
17
+ }, q = (t) => t < 0 ? -1 : 1, D = (t, e, n) => {
18
+ const o = n - e + 1;
19
+ return t < e && (t += o * ((e - t) / o + 1)), e + (t - e) % o;
20
+ }, r = (t, e) => (t = t % e, t < 0 && (t += e), t);
78
21
  export {
79
- f as EPSILON,
80
- p as TOLERANCE,
81
- u as angleDifference,
22
+ c as EPSILON,
23
+ i as angleDifference,
82
24
  h as ceilTo,
83
- c as clamp,
25
+ l as clamp,
84
26
  M as clampInt,
85
- g as clampSym,
86
- N as compare,
87
- w as floorTo,
88
- o as interpolate,
89
- d as interpolateAngle,
90
- T as interpolateAngleCCW,
91
- E as interpolateAngleCW,
92
- C as interpolateWidestAngle,
27
+ u as clampSym,
28
+ g as compareNumbers,
29
+ N as floorTo,
30
+ s as interpolate,
31
+ A as interpolateAngle,
32
+ C as interpolateAngleCCW,
33
+ m as interpolateAngleCW,
34
+ d as interpolateWidestAngle,
93
35
  F as nearEqualAngles,
94
- m as nearEquals,
36
+ E as nearEquals,
95
37
  S as nearZero,
96
- W as root,
97
- q as roundTo,
98
- D as sign,
99
- A as toHex,
100
- a as widestAngleDifference,
101
- I as wrap,
102
- i as wrapCircular
38
+ T as root,
39
+ W as roundTo,
40
+ q as sign,
41
+ w as toHex,
42
+ f as widestAngleDifference,
43
+ D as wrap,
44
+ r as wrapCircular
103
45
  };
package/object.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(e){return Object.keys(e)}function o(e,t){const s=c(e),r=c(t);if(s.length!==r.length)return!1;for(const n of s)if(!(n in t))return!1;return!0}function u(e){return e!=null&&Object.getPrototypeOf(e)===Object.prototype}function i(e,...t){return c(e).reduce((r,n)=>(t.includes(n)||(r[n]=e[n]),r),{})}function b(e,t){return Object.assign({},e,t)}function j(e){return Object.keys(e).length===0}exports.isEmptyObject=j;exports.isObject=u;exports.mergeObjects=b;exports.objectKeys=c;exports.removeObjectFields=i;exports.sameObjectKeys=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=e=>Object.keys(e),o=(e,t)=>{const r=n(e),c=n(t);if(r.length!==c.length)return!1;for(const s of r)if(!(s in t))return!1;return!0},b=e=>e!=null&&Object.getPrototypeOf(e)===Object.prototype,j=(e,...t)=>n(e).reduce((c,s)=>(t.includes(s)||(c[s]=e[s]),c),{}),O=(e,t)=>Object.assign({},e,t),i=e=>Object.keys(e).length===0;exports.isEmptyObject=i;exports.isObject=b;exports.mergeObjects=O;exports.objectKeys=n;exports.removeObjectFields=j;exports.sameObjectKeys=o;
package/object.d.ts CHANGED
@@ -7,7 +7,7 @@ import { IndexKey, Merge, TupleToUnion } from './domain';
7
7
  * @returns An array of keys from the object.
8
8
  * @public
9
9
  */
10
- export declare function objectKeys<T extends object>(obj: T): Array<keyof T>;
10
+ export declare const objectKeys: <T extends object>(obj: T) => Array<keyof T>;
11
11
  /**
12
12
  * Checks if two objects have the same keys.
13
13
  *
@@ -16,7 +16,7 @@ export declare function objectKeys<T extends object>(obj: T): Array<keyof T>;
16
16
  * @returns `true` if both objects have the same keys, `false` otherwise.
17
17
  * @public
18
18
  */
19
- export declare function sameObjectKeys<T extends object>(a: T, b: T): boolean;
19
+ export declare const sameObjectKeys: <T extends object>(a: T, b: T) => boolean;
20
20
  /**
21
21
  * Checks if the given value is an object.
22
22
  *
@@ -24,7 +24,7 @@ export declare function sameObjectKeys<T extends object>(a: T, b: T): boolean;
24
24
  * @returns `true` if the value is an object, `false` otherwise.
25
25
  * @public
26
26
  */
27
- export declare function isObject(obj: unknown): obj is Record<IndexKey, unknown>;
27
+ export declare const isObject: (obj: unknown) => obj is Record<IndexKey, unknown>;
28
28
  /**
29
29
  * Removes specified fields from an object and returns a new object without those fields.
30
30
  *
@@ -33,7 +33,7 @@ export declare function isObject(obj: unknown): obj is Record<IndexKey, unknown>
33
33
  * @returns A new object without the specified fields.
34
34
  * @public
35
35
  */
36
- export declare function removeObjectFields<T extends object, F extends Array<keyof T>>(ob: T, ...fields: F): Omit<T, TupleToUnion<F>>;
36
+ export declare const removeObjectFields: <T extends object, F extends Array<keyof T>>(ob: T, ...fields: F) => Omit<T, TupleToUnion<F>>;
37
37
  /**
38
38
  * Merges two objects together.
39
39
  *
@@ -44,7 +44,7 @@ export declare function removeObjectFields<T extends object, F extends Array<key
44
44
  * @returns The merged object.
45
45
  * @public
46
46
  */
47
- export declare function mergeObjects<A extends Record<IndexKey, unknown>, B extends Record<IndexKey, unknown>>(a: A, b: B): Merge<A, B>;
47
+ export declare const mergeObjects: <A extends Record<IndexKey, unknown>, B extends Record<IndexKey, unknown>>(a: A, b: B) => Merge<A, B>;
48
48
  /**
49
49
  * Checks if an object is empty.
50
50
  * An object is considered empty if it has no own enumerable properties.
@@ -53,4 +53,4 @@ export declare function mergeObjects<A extends Record<IndexKey, unknown>, B exte
53
53
  * @returns `true` if the object is empty, `false` otherwise.
54
54
  * @public
55
55
  */
56
- export declare function isEmptyObject(obj: object): boolean;
56
+ export declare const isEmptyObject: (obj: object) => boolean;
package/object.js CHANGED
@@ -1,30 +1,15 @@
1
- function s(e) {
2
- return Object.keys(e);
3
- }
4
- function u(e, t) {
5
- const c = s(e), r = s(t);
6
- if (c.length !== r.length) return !1;
7
- for (const n of c)
8
- if (!(n in t)) return !1;
1
+ const r = (e) => Object.keys(e), o = (e, t) => {
2
+ const c = r(e), n = r(t);
3
+ if (c.length !== n.length) return !1;
4
+ for (const s of c)
5
+ if (!(s in t)) return !1;
9
6
  return !0;
10
- }
11
- function o(e) {
12
- return e != null && Object.getPrototypeOf(e) === Object.prototype;
13
- }
14
- function i(e, ...t) {
15
- return s(e).reduce((r, n) => (t.includes(n) || (r[n] = e[n]), r), {});
16
- }
17
- function f(e, t) {
18
- return Object.assign({}, e, t);
19
- }
20
- function O(e) {
21
- return Object.keys(e).length === 0;
22
- }
7
+ }, O = (e) => e != null && Object.getPrototypeOf(e) === Object.prototype, j = (e, ...t) => r(e).reduce((n, s) => (t.includes(s) || (n[s] = e[s]), n), {}), b = (e, t) => Object.assign({}, e, t), i = (e) => Object.keys(e).length === 0;
23
8
  export {
24
- O as isEmptyObject,
25
- o as isObject,
26
- f as mergeObjects,
27
- s as objectKeys,
28
- i as removeObjectFields,
29
- u as sameObjectKeys
9
+ i as isEmptyObject,
10
+ O as isObject,
11
+ b as mergeObjects,
12
+ r as objectKeys,
13
+ j as removeObjectFields,
14
+ o as sameObjectKeys
30
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/std",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "priority": 8,
5
5
  "description": "Std library for TypeScript. Natural complement to the Tempo libraries.",
6
6
  "keywords": [
@@ -49,6 +49,10 @@
49
49
  "import": "./equal.js",
50
50
  "require": "./equal.cjs"
51
51
  },
52
+ "./error": {
53
+ "import": "./error.js",
54
+ "require": "./error.cjs"
55
+ },
52
56
  "./function": {
53
57
  "import": "./function.js",
54
58
  "require": "./function.cjs"
@@ -65,6 +69,10 @@
65
69
  "import": "./object.js",
66
70
  "require": "./object.cjs"
67
71
  },
72
+ "./promise": {
73
+ "import": "./promise.js",
74
+ "require": "./promise.cjs"
75
+ },
68
76
  "./regexp": {
69
77
  "import": "./regexp.js",
70
78
  "require": "./regexp.cjs"
@@ -110,6 +118,9 @@
110
118
  "equal": [
111
119
  "./equal.d.ts"
112
120
  ],
121
+ "error": [
122
+ "./error.d.ts"
123
+ ],
113
124
  "function": [
114
125
  "./function.d.ts"
115
126
  ],
@@ -122,6 +133,9 @@
122
133
  "object": [
123
134
  "./object.d.ts"
124
135
  ],
136
+ "promise": [
137
+ "./promise.d.ts"
138
+ ],
125
139
  "regexp": [
126
140
  "./regexp.d.ts"
127
141
  ],
package/promise.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=(t,{abortSignal:e}={})=>new Promise((o,r)=>{const i=setTimeout(o,t);e&&e.addEventListener("abort",()=>{clearTimeout(i),r(new DOMException("Aborted","AbortError"))})});exports.sleep=s;
package/promise.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Sleep for a given number of milliseconds.
3
+ *
4
+ * @param ms - The number of milliseconds to sleep.
5
+ * @param options - The options for the sleep function.
6
+ * @returns A promise that resolves after the given number of milliseconds.
7
+ * @public
8
+ */
9
+ export declare const sleep: (ms: number, { abortSignal }?: {
10
+ abortSignal?: AbortSignal;
11
+ }) => Promise<void>;
package/promise.js ADDED
@@ -0,0 +1,9 @@
1
+ const n = (t, { abortSignal: e } = {}) => new Promise((o, r) => {
2
+ const i = setTimeout(o, t);
3
+ e && e.addEventListener("abort", () => {
4
+ clearTimeout(i), r(new DOMException("Aborted", "AbortError"));
5
+ });
6
+ });
7
+ export {
8
+ n as sleep
9
+ };
package/regexp.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(i,s,u){const n=[];let l=0,e;if(s.global)for(s.lastIndex=0;(e=s.exec(i))!==null;)n.push(i.substring(l,e.index)),n.push(u(...e)),l=e.index+e[0].length;else for(;(e=s.exec(i.substring(l)))!==null;)n.push(i.substring(l,l+e.index)),n.push(u(...e)),l+=e.index+e[0].length;return n.push(i.substring(l)),n.join("")}exports.mapRegExp=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=(n,i,u)=>{const s=[];let l=0,e;if(i.global)for(i.lastIndex=0;(e=i.exec(n))!==null;)s.push(n.substring(l,e.index)),s.push(u(...e)),l=e.index+e[0].length;else for(;(e=i.exec(n.substring(l)))!==null;)s.push(n.substring(l,l+e.index)),s.push(u(...e)),l+=e.index+e[0].length;return s.push(n.substring(l)),s.join("")};exports.mapRegExp=g;
package/regexp.d.ts CHANGED
@@ -8,4 +8,4 @@
8
8
  * @param subject - The string to search.
9
9
  * @public
10
10
  */
11
- export declare function mapRegExp(subject: string, pattern: RegExp, f: (...s: string[]) => string): string;
11
+ export declare const mapRegExp: (subject: string, pattern: RegExp, f: (...s: string[]) => string) => string;
package/regexp.js CHANGED
@@ -1,14 +1,14 @@
1
- function h(s, i, u) {
1
+ const h = (n, i, u) => {
2
2
  const e = [];
3
- let n = 0, l;
3
+ let s = 0, l;
4
4
  if (i.global)
5
- for (i.lastIndex = 0; (l = i.exec(s)) !== null; )
6
- e.push(s.substring(n, l.index)), e.push(u(...l)), n = l.index + l[0].length;
5
+ for (i.lastIndex = 0; (l = i.exec(n)) !== null; )
6
+ e.push(n.substring(s, l.index)), e.push(u(...l)), s = l.index + l[0].length;
7
7
  else
8
- for (; (l = i.exec(s.substring(n))) !== null; )
9
- e.push(s.substring(n, n + l.index)), e.push(u(...l)), n += l.index + l[0].length;
10
- return e.push(s.substring(n)), e.join("");
11
- }
8
+ for (; (l = i.exec(n.substring(s))) !== null; )
9
+ e.push(n.substring(s, s + l.index)), e.push(u(...l)), s += l.index + l[0].length;
10
+ return e.push(n.substring(s)), e.join("");
11
+ };
12
12
  export {
13
13
  h as mapRegExp
14
14
  };
package/result.d.ts CHANGED
@@ -7,19 +7,19 @@ import { Validation } from './validation';
7
7
  * @typeParam V - The type of the value.
8
8
  * @public
9
9
  */
10
- export interface Success<V> {
11
- type: 'Success';
12
- value: V;
13
- }
10
+ export type Success<V> = {
11
+ readonly type: 'Success';
12
+ readonly value: V;
13
+ };
14
14
  /**
15
15
  * Represents a failure result.
16
16
  * @typeParam E - The type of the error.
17
17
  * @public
18
18
  */
19
- export interface Failure<E> {
20
- type: 'Failure';
21
- error: E;
22
- }
19
+ export type Failure<E> = {
20
+ readonly type: 'Failure';
21
+ readonly error: E;
22
+ };
23
23
  /**
24
24
  * Represents a result that can either be a success or a failure.
25
25
  * @typeParam V - The type of the value in case of success.
package/string.cjs CHANGED
@@ -1,4 +1,4 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./array.cjs"),m=require("./error.cjs"),A=require("./regexp.cjs"),u=(t,e,n)=>t.split(e).join(n),_=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(n+e.length)},k=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(n+e.length)},H=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(0,n)},$=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(0,n)},h=t=>t.substring(0,1).toUpperCase()+t.substring(1),b=t=>t.toUpperCase(),D=(t,e=!1)=>e?A.mapRegExp(h(t),qt,b):A.mapRegExp(h(t),$t,b),R=t=>t.replace(Qt,`
2
+ `),q=(t,e)=>t==null&&e==null?0:t==null?-1:e==null?1:I(t.toLowerCase(),e.toLowerCase()),d=(t,e)=>t.substring(0,t.length-e.length)===e,P=(t,e)=>t.substring(0,t.length-e.length).toLowerCase()===e.toLowerCase(),L=(t,e)=>t.substring(0,e.length)===e,Z=(t,e)=>t.substring(0,e.length).toLowerCase()===e.toLowerCase(),Q=(t,e)=>y(t.toLowerCase(),e.map(n=>n.toLowerCase())),G=(t,e)=>B(t.toLowerCase(),e.map(n=>n.toLowerCase())),K=t=>t.trim().replace(F," "),I=(t,e)=>t<e?-1:t>e?1:0,C=(t,e)=>t.toLowerCase().includes(e.toLowerCase()),l=(t,e)=>t.includes(e),J=(t,e)=>t.split(e).length-1,V=(t,e)=>c.anyElement(e,n=>C(t,n)),X=(t,e)=>c.anyElement(e,n=>l(t,n)),Y=(t,e)=>c.allElements(e,n=>C(t,n)),v=(t,e)=>c.allElements(e,n=>l(t,n)),tt=t=>t.replace("_","-"),et=(t,e)=>{if(t===e)return-1;const n=Math.min(t.length,e.length);for(let r=0;r<n;r++)if(t.substring(r,r+1)!==e.substring(r,r+1))return r;return n},w=(t,e=20,n="…")=>{const r=t.length,s=n.length;return r>e?e<s?n.slice(s-e,e):t.slice(0,e-s)+n:t},nt=(t,e=20,n="…")=>{const r=t.length,s=n.length;if(r>e){if(e<=s)return w(t,e,n);const a=Math.ceil((e-s)/2),g=Math.floor((e-s)/2);return t.slice(0,a)+n+t.slice(r-g)}else return t},y=(t,e)=>c.anyElement(e,n=>d(t,n)),rt=(t,e)=>p(t).filter(e).join(""),st=(t,e)=>T(t).filter(e).map(r=>String.fromCharCode(r)).join(""),it=(t,e=2166136261)=>{let n=e;for(let r=0,s=t.length;r<s;r++)n^=t.charCodeAt(r),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return n>>>0},ot=t=>t!=null&&t.length>0,ct=t=>u(M(t),"_"," "),at=t=>t.length>0&&!Rt.test(t),ut=t=>Pt.test(t),lt=t=>!Dt.test(t),gt=t=>t.toLowerCase()===t,pt=t=>t.toUpperCase()===t,ht=(t,e)=>t!=null&&t!==""?t:e,ft=t=>Zt.test(t),dt=t=>t==null||t==="",Ct=t=>t.substring(0,1).toLowerCase()+t.substring(1),E=(t,e=1)=>t.substring(Math.floor((t.length-e+1)*Math.random()),e),x=(t,e)=>c.generateArray(e,()=>E(t)).join(""),St=t=>x(Ht,t),At=(t,e)=>p(e).map(t),bt=(t,e)=>u(t,e,""),mt=(t,e)=>d(t,e)?t.substring(0,t.length-e.length):t,Lt=(t,e,n)=>t.substring(0,e)+t.substring(e+n),It=(t,e)=>L(t,e)?t.substring(e.length):t,wt=(t,e)=>{const n=t.indexOf(e);return n<0?t:t.substring(0,n)+t.substring(n+e.length)},S=(t,e)=>c.createFilledArray(e,t).join(""),yt=t=>{const e=p(t);return e.reverse(),e.join("")},W=(t,e="'")=>e==="'"?t.includes("'")?t.includes('"')?"'"+u(t,"'","\\'")+"'":'"'+t+'"':"'"+t+"'":t.includes('"')?t.includes("'")?'"'+u(t,'"','\\"')+'"':"'"+t+"'":'"'+t+'"',O=(t,e="'")=>e+u(t,e,"\\"+e)+e,Et=(t,e="'")=>t.indexOf(`
3
+ `)>=0?O(t,"`"):W(t,e),xt=(t,e)=>{const n=t.indexOf(e);return n<0?[t]:[t.substring(0,n),t.substring(n+e.length)]},B=(t,e)=>c.anyElement(e,n=>t.startsWith(n)),Wt=(t,e,n=e)=>`${e}${t}${n}`,p=t=>t.split(""),T=t=>c.generateArray(t.length,e=>t.charCodeAt(e)),Ot=(t,e)=>{const n=[];for(;t.length>0;)n.push(t.substring(0,e)),t=t.substring(e,t.length-e);return n},Bt=t=>t.split(U),Tt=(t,e)=>j(z(t,e),e),z=(t,e)=>{let n=0;for(let r=0;r<t.length&&l(e,t.charAt(r));r++)n++;return t.substring(n)},j=(t,e)=>{const n=t.length;let r=n,s;for(let a=0;a<n&&(s=n-a-1,l(e,t.charAt(s)));a++)r=s;return t.substring(0,r)},M=t=>(t=t.replace(/::/g,"/"),t=t.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2"),t=t.replace(/([a-z\d])([A-Z])/g,"$1_$2"),t=t.replace(/-/g,"_"),t.toLowerCase()),zt=t=>t.substring(0,1).toUpperCase()+t.substring(1),jt=(t,e=78,n="",r=`
4
+ `)=>t.split(U).map(s=>N(s.replace(F," ").trim(),e,n,r)).join(r),f=(t,e)=>{if(e<0||e>=t.length)return!1;const n=t.charCodeAt(e);return n===9||n===10||n===11||n===12||n===13||n===32},Mt=t=>{if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof btoa<"u")return btoa(t);throw new m.MissingImplementationError("No implementation found for base64 encoding")},Nt=t=>{if(typeof Buffer<"u")return Buffer.from(t,"base64").toString("utf8");if(typeof atob<"u")return atob(t);throw new m.MissingImplementationError("No implementation found for base64 decoding")},N=(t,e,n,r)=>{const s=[],a=t.length,g=n.length;let o=0;for(e-=g;;){if(o+e>=a-g){s.push(t.substring(o));break}let i=0;for(;!f(t,o+e-i)&&i<e;)i++;if(i===e){for(i=0;!f(t,o+e+i)&&o+e+i<a;)i++;s.push(t.substring(o,o+e+i)),o+=e+i+1}else s.push(t.substring(o,o+e-i)),o+=e-i+1}return n+s.join(r+n)},Ft=(t,e,n)=>{const r=n-t.length;return r>0?S(e,r)+t:t},Ut=(t,e,n)=>{const r=n-t.length;return r>0?t+S(e,r):t},_t=(t,e)=>{const n=t.lastIndexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},kt=(t,e)=>{const n=t.indexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$t=/[^a-zA-Z]([a-z])/g,Dt=/[^\t\n\r ]/,Rt=/[^a-zA-Z]/,qt=/[ \t\r\n][a-z]/g,Pt=/^[a-z0-9]+$/i,Zt=/^[0-9]+$/,F=/[ \t\r\n]+/g,U=/\r\n|\n\r|\n|\r/g,Qt=/\r\n|\n\r|\r/g;exports.canonicalizeNewlines=R;exports.capitalize=h;exports.capitalizeWords=D;exports.chunkString=Ot;exports.collapseText=K;exports.compareCaseInsensitive=q;exports.compareStrings=I;exports.containsAllText=v;exports.containsAllTextCaseInsensitive=Y;exports.containsAnyText=X;exports.containsAnyTextCaseInsensitive=V;exports.countStringOccurrences=J;exports.dasherize=tt;exports.decodeBase64=Nt;exports.deleteFirstFromString=wt;exports.deleteStringAfter=mt;exports.deleteStringBefore=It;exports.deleteSubstring=bt;exports.ellipsis=w;exports.ellipsisMiddle=nt;exports.encodeBase64=Mt;exports.filterCharcodes=st;exports.filterChars=rt;exports.humanize=ct;exports.ifEmptyString=ht;exports.isAlpha=at;exports.isAlphaNum=ut;exports.isBreakingWhitespace=lt;exports.isDigitsOnly=ft;exports.isEmptyString=dt;exports.isLowerCase=gt;exports.isSpaceAt=f;exports.isUpperCase=pt;exports.jsQuote=Et;exports.lowerCaseFirst=Ct;exports.lpad=Ft;exports.mapChars=At;exports.quote=O;exports.randomString=E;exports.randomStringSequence=x;exports.randomStringSequenceBase64=St;exports.repeatString=S;exports.replaceAll=u;exports.reverseString=yt;exports.rpad=Ut;exports.smartQuote=W;exports.splitStringOnFirst=kt;exports.splitStringOnLast=_t;exports.splitStringOnce=xt;exports.stringContains=l;exports.stringEndsWith=d;exports.stringEndsWithAny=y;exports.stringHasContent=ot;exports.stringHashCode=it;exports.stringStartsWith=L;exports.stringStartsWithAny=B;exports.stringToCharcodes=T;exports.stringToChars=p;exports.stringsDifferAtIndex=et;exports.substringAfter=_;exports.substringAfterLast=k;exports.substringBefore=H;exports.substringBeforeLast=$;exports.surroundString=Wt;exports.textContainsCaseInsensitive=C;exports.textEndsWithAnyCaseInsensitive=Q;exports.textEndsWithCaseInsensitive=P;exports.textStartsWithAnyCaseInsensitive=G;exports.textStartsWithCaseInsensitive=Z;exports.textToLines=Bt;exports.trimChars=Tt;exports.trimCharsLeft=z;exports.trimCharsRight=j;exports.trimStringSlice=Lt;exports.underscore=M;exports.upperCaseFirst=zt;exports.wrapColumns=jt;exports.wrapLine=N;