@tempots/std 0.10.7 → 0.11.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/README.md +2 -0
- package/async-result.cjs +1 -1
- package/async-result.d.ts +15 -16
- package/async-result.js +13 -11
- package/domain.d.ts +3 -0
- package/maybe.d.ts +1 -1
- package/package.json +19 -12
- package/result.cjs +1 -1
- package/result.d.ts +2 -2
- package/result.js +29 -29
- package/string.cjs +4 -3
- package/string.d.ts +3 -1
- package/string.js +171 -162
- package/index.cjs +0 -1
- package/index.d.ts +0 -0
- package/index.js +0 -1
package/README.md
CHANGED
package/async-result.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u={
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u={notAsked:{type:"NotAsked"},loading(e=void 0){return{type:"Loading",previousValue:e}},success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},isSuccess(e){return e.type==="Success"},isFailure(e){return e.type==="Failure"},isNotAsked(e){return e.type==="NotAsked"},isLoading(e){return e.type==="Loading"},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,i=t)=>r=>u.isSuccess(r)?e(r.value):u.isFailure(r)?s(r.error):u.isNotAsked(r)?i():t(r.previousValue),match:(e,s,t,i,r=i)=>u.isSuccess(e)?s(e.value):u.isFailure(e)?t(e.error):u.isNotAsked(e)?r():i(e.previousValue),whenSuccess:e=>s=>(u.isSuccess(s)&&e(s.value),s),whenFailure:e=>s=>(u.isFailure(s)&&e(s.error),s)};exports.AsyncResult=u;
|
package/async-result.d.ts
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
type: '
|
|
1
|
+
export interface NotAsked {
|
|
2
|
+
type: 'NotAsked';
|
|
3
3
|
}
|
|
4
|
-
export interface Loading {
|
|
5
|
-
type: '
|
|
4
|
+
export interface Loading<V> {
|
|
5
|
+
type: 'Loading';
|
|
6
|
+
previousValue?: V;
|
|
6
7
|
}
|
|
7
8
|
export interface Success<V> {
|
|
8
|
-
type: '
|
|
9
|
+
type: 'Success';
|
|
9
10
|
value: V;
|
|
10
11
|
}
|
|
11
12
|
export interface Failure<E> {
|
|
12
|
-
type: '
|
|
13
|
+
type: 'Failure';
|
|
13
14
|
error: E;
|
|
14
15
|
}
|
|
15
|
-
export type AsyncResult<V, E> =
|
|
16
|
+
export type AsyncResult<V, E> = NotAsked | Loading<V> | Success<V> | Failure<E>;
|
|
16
17
|
export declare const AsyncResult: {
|
|
17
|
-
|
|
18
|
-
type: "
|
|
19
|
-
};
|
|
20
|
-
loading: {
|
|
21
|
-
type: "loading";
|
|
18
|
+
notAsked: {
|
|
19
|
+
type: "NotAsked";
|
|
22
20
|
};
|
|
21
|
+
loading<V>(previousValue?: V | undefined): AsyncResult<V, never>;
|
|
23
22
|
success<V>(value: V): AsyncResult<V, never>;
|
|
24
23
|
failure<E>(error: E): AsyncResult<never, E>;
|
|
25
24
|
isSuccess<V, E>(r: AsyncResult<V, E>): r is Success<V>;
|
|
26
25
|
isFailure<V, E>(r: AsyncResult<V, E>): r is Failure<E>;
|
|
27
|
-
|
|
28
|
-
isLoading<V, E>(r: AsyncResult<V, E>): r is Loading
|
|
26
|
+
isNotAsked<V, E>(r: AsyncResult<V, E>): r is NotAsked;
|
|
27
|
+
isLoading<V, E>(r: AsyncResult<V, E>): r is Loading<V>;
|
|
29
28
|
getOrElse<V, E>(r: AsyncResult<V, E>, alt: V): V;
|
|
30
29
|
getOrElseLazy<V, E>(r: AsyncResult<V, E>, altf: () => V): V;
|
|
31
30
|
getOrNull<V, E>(r: AsyncResult<V, E>): V | null;
|
|
32
31
|
getOrUndefined<V, E>(r: AsyncResult<V, E>): V | undefined;
|
|
33
|
-
cmatch: <V1, V2, E>(success: (value: V1) => V2, failure: (error: E) => V2, loading: () => V2, idle?: () => V2) => (r: AsyncResult<V1, E>) => V2;
|
|
34
|
-
match: <V1, V2, E>(r: AsyncResult<V1, E>, success: (value: V1) => V2, failure: (error: E) => V2, loading: () => V2, idle?: () => V2) => V2;
|
|
32
|
+
cmatch: <V1, V2, E>(success: (value: V1) => V2, failure: (error: E) => V2, loading: (previousValue?: V1) => V2, idle?: () => V2) => (r: AsyncResult<V1, E>) => V2;
|
|
33
|
+
match: <V1, V2, E>(r: AsyncResult<V1, E>, success: (value: V1) => V2, failure: (error: E) => V2, loading: (previousValue?: V1) => V2, idle?: () => V2) => V2;
|
|
35
34
|
whenSuccess: <V, E>(apply: (v: V) => void) => (r: AsyncResult<V, E>) => AsyncResult<V, E>;
|
|
36
35
|
whenFailure: <V, E>(apply: (e: E) => void) => (r: AsyncResult<V, E>) => AsyncResult<V, E>;
|
|
37
36
|
};
|
package/async-result.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
const u = {
|
|
2
|
-
|
|
3
|
-
loading
|
|
2
|
+
notAsked: { type: "NotAsked" },
|
|
3
|
+
loading(e = void 0) {
|
|
4
|
+
return { type: "Loading", previousValue: e };
|
|
5
|
+
},
|
|
4
6
|
success(e) {
|
|
5
|
-
return { type: "
|
|
7
|
+
return { type: "Success", value: e };
|
|
6
8
|
},
|
|
7
9
|
failure(e) {
|
|
8
|
-
return { type: "
|
|
10
|
+
return { type: "Failure", error: e };
|
|
9
11
|
},
|
|
10
12
|
isSuccess(e) {
|
|
11
|
-
return e.type === "
|
|
13
|
+
return e.type === "Success";
|
|
12
14
|
},
|
|
13
15
|
isFailure(e) {
|
|
14
|
-
return e.type === "
|
|
16
|
+
return e.type === "Failure";
|
|
15
17
|
},
|
|
16
|
-
|
|
17
|
-
return e.type === "
|
|
18
|
+
isNotAsked(e) {
|
|
19
|
+
return e.type === "NotAsked";
|
|
18
20
|
},
|
|
19
21
|
isLoading(e) {
|
|
20
|
-
return e.type === "
|
|
22
|
+
return e.type === "Loading";
|
|
21
23
|
},
|
|
22
24
|
getOrElse(e, s) {
|
|
23
25
|
return u.isSuccess(e) ? e.value : s;
|
|
@@ -31,8 +33,8 @@ const u = {
|
|
|
31
33
|
getOrUndefined(e) {
|
|
32
34
|
return u.isSuccess(e) ? e.value : void 0;
|
|
33
35
|
},
|
|
34
|
-
cmatch: (e, s,
|
|
35
|
-
match: (e, s,
|
|
36
|
+
cmatch: (e, s, t, i = t) => (r) => u.isSuccess(r) ? e(r.value) : u.isFailure(r) ? s(r.error) : u.isNotAsked(r) ? i() : t(r.previousValue),
|
|
37
|
+
match: (e, s, t, i, r = i) => u.isSuccess(e) ? s(e.value) : u.isFailure(e) ? t(e.error) : u.isNotAsked(e) ? r() : i(e.previousValue),
|
|
36
38
|
whenSuccess: (e) => (s) => (u.isSuccess(s) && e(s.value), s),
|
|
37
39
|
whenFailure: (e) => (s) => (u.isFailure(s) && e(s.error), s)
|
|
38
40
|
};
|
package/domain.d.ts
CHANGED
|
@@ -20,3 +20,6 @@ export type Fun4<A, B, C, D, R> = (a: A, b: B, c: C, d: D) => R;
|
|
|
20
20
|
export type Fun5<A, B, C, D, E, R> = (a: A, b: B, c: C, d: D, e: E) => R;
|
|
21
21
|
export type Fun6<A, B, C, D, E, F, R> = (a: A, b: B, c: C, d: D, e: E, f: F) => R;
|
|
22
22
|
export type FirstArgument<F> = F extends Fun1<infer A, unknown> ? A : never;
|
|
23
|
+
export type FilterTuple<T extends unknown[], N> = T extends [] ? [] : T extends [infer H, ...infer R] ? N extends H ? FilterTuple<R, N> : [H, ...FilterTuple<R, N>] : T;
|
|
24
|
+
export type SplitLiteral<T extends string, SplitBy extends string> = FilterTuple<T extends `${infer A}${SplitBy}${infer B}` ? [...SplitLiteral<A, SplitBy>, ...SplitLiteral<B, SplitBy>] : [T], ''>;
|
|
25
|
+
export type SplitLiteralToUnion<T extends string, SplitBy extends string> = TupleToUnion<SplitLiteral<T, SplitBy>>;
|
package/maybe.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempots/std",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"priority": 8,
|
|
5
|
+
"description": "Std library for TypeScript. Natural complement to the Tempo libraries.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"tempo",
|
|
8
|
+
"tempots",
|
|
9
|
+
"framework",
|
|
10
|
+
"std",
|
|
11
|
+
"library"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/fponticelli/tempots",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/fponticelli/tempots/issues"
|
|
16
|
+
},
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Franco Ponticelli",
|
|
19
|
+
"email": "franco.ponticelli@gmail.com",
|
|
20
|
+
"url": "https://github.com/fponticelli"
|
|
21
|
+
},
|
|
4
22
|
"type": "module",
|
|
5
23
|
"exports": {
|
|
6
24
|
"./array": {
|
|
@@ -31,10 +49,6 @@
|
|
|
31
49
|
"import": "./function.js",
|
|
32
50
|
"require": "./function.cjs"
|
|
33
51
|
},
|
|
34
|
-
"./index": {
|
|
35
|
-
"import": "./index.js",
|
|
36
|
-
"require": "./index.cjs"
|
|
37
|
-
},
|
|
38
52
|
"./json": {
|
|
39
53
|
"import": "./json.js",
|
|
40
54
|
"require": "./json.cjs"
|
|
@@ -73,10 +87,6 @@
|
|
|
73
87
|
"type": "git",
|
|
74
88
|
"url": "git+https://github.com/fponticelli/tempots.git"
|
|
75
89
|
},
|
|
76
|
-
"bugs": {
|
|
77
|
-
"url": "https://github.com/fponticelli/tempots/issues"
|
|
78
|
-
},
|
|
79
|
-
"homepage": "https://github.com/fponticelli/tempots#readme",
|
|
80
90
|
"typesVersions": {
|
|
81
91
|
"*": {
|
|
82
92
|
"array": [
|
|
@@ -100,9 +110,6 @@
|
|
|
100
110
|
"function": [
|
|
101
111
|
"./function.d.ts"
|
|
102
112
|
],
|
|
103
|
-
"index": [
|
|
104
|
-
"./index.d.ts"
|
|
105
|
-
],
|
|
106
113
|
"json": [
|
|
107
114
|
"./json.d.ts"
|
|
108
115
|
],
|
package/result.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s={success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},cmap:e=>u=>u.type==="Success"?s.success(e(u.value)):u,map:(e,u)=>e.type==="Success"?s.success(u(e.value)):e,cflatMap:e=>u=>u.type==="Success"?e(u.value):u,flatMap:(e,u)=>e.type==="Success"?u(e.value):e,toAsync(e){return e},isSuccess(e){return e.type==="Success"},isFailure(e){return e.type==="Failure"},getOrElse(e,u){return s.isSuccess(e)?e.value:u},getOrElseLazy(e,u){return s.isSuccess(e)?e.value:u()},getOrNull(e){return s.isSuccess(e)?e.value:null},getOrUndefined(e){return s.isSuccess(e)?e.value:void 0},cmatch:(e,u)=>t=>s.isSuccess(t)?e(t.value):u(t.error),match:(e,u,t)=>s.isSuccess(e)?u(e.value):t(e.error),whenSuccess:e=>u=>(s.isSuccess(u)&&e(u.value),u),whenFailure:e=>u=>(s.isFailure(u)&&e(u.error),u),combine:(e,u,t,l)=>s.match(e,r=>s.match(u,c=>s.success(t(r,c)),c=>s.failure(c)),r=>s.match(u,c=>s.failure(r),c=>s.failure(l(r,c))))};exports.Result=s;
|
package/result.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AsyncResult } from './async-result';
|
|
2
2
|
|
|
3
3
|
export interface Success<V> {
|
|
4
|
-
type: '
|
|
4
|
+
type: 'Success';
|
|
5
5
|
value: V;
|
|
6
6
|
}
|
|
7
7
|
export interface Failure<E> {
|
|
8
|
-
type: '
|
|
8
|
+
type: 'Failure';
|
|
9
9
|
error: E;
|
|
10
10
|
}
|
|
11
11
|
export type Result<V, E> = Success<V> | Failure<E>;
|
package/result.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
const
|
|
1
|
+
const s = {
|
|
2
2
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
3
|
success(e) {
|
|
4
|
-
return { type: "
|
|
4
|
+
return { type: "Success", value: e };
|
|
5
5
|
},
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
7
|
failure(e) {
|
|
8
|
-
return { type: "
|
|
8
|
+
return { type: "Failure", error: e };
|
|
9
9
|
},
|
|
10
|
-
cmap: (e) => (
|
|
11
|
-
map: (e,
|
|
12
|
-
cflatMap: (e) => (
|
|
13
|
-
flatMap: (e,
|
|
10
|
+
cmap: (e) => (u) => u.type === "Success" ? s.success(e(u.value)) : u,
|
|
11
|
+
map: (e, u) => e.type === "Success" ? s.success(u(e.value)) : e,
|
|
12
|
+
cflatMap: (e) => (u) => u.type === "Success" ? e(u.value) : u,
|
|
13
|
+
flatMap: (e, u) => e.type === "Success" ? u(e.value) : e,
|
|
14
14
|
toAsync(e) {
|
|
15
15
|
return e;
|
|
16
16
|
},
|
|
17
17
|
isSuccess(e) {
|
|
18
|
-
return e.type === "
|
|
18
|
+
return e.type === "Success";
|
|
19
19
|
},
|
|
20
20
|
isFailure(e) {
|
|
21
|
-
return e.type === "
|
|
21
|
+
return e.type === "Failure";
|
|
22
22
|
},
|
|
23
|
-
getOrElse(e,
|
|
24
|
-
return
|
|
23
|
+
getOrElse(e, u) {
|
|
24
|
+
return s.isSuccess(e) ? e.value : u;
|
|
25
25
|
},
|
|
26
|
-
getOrElseLazy(e,
|
|
27
|
-
return
|
|
26
|
+
getOrElseLazy(e, u) {
|
|
27
|
+
return s.isSuccess(e) ? e.value : u();
|
|
28
28
|
},
|
|
29
29
|
getOrNull(e) {
|
|
30
|
-
return
|
|
30
|
+
return s.isSuccess(e) ? e.value : null;
|
|
31
31
|
},
|
|
32
32
|
getOrUndefined(e) {
|
|
33
|
-
return
|
|
33
|
+
return s.isSuccess(e) ? e.value : void 0;
|
|
34
34
|
},
|
|
35
|
-
cmatch: (e,
|
|
36
|
-
match: (e,
|
|
37
|
-
whenSuccess: (e) => (
|
|
38
|
-
whenFailure: (e) => (
|
|
39
|
-
combine: (e,
|
|
35
|
+
cmatch: (e, u) => (c) => s.isSuccess(c) ? e(c.value) : u(c.error),
|
|
36
|
+
match: (e, u, c) => s.isSuccess(e) ? u(e.value) : c(e.error),
|
|
37
|
+
whenSuccess: (e) => (u) => (s.isSuccess(u) && e(u.value), u),
|
|
38
|
+
whenFailure: (e) => (u) => (s.isFailure(u) && e(u.error), u),
|
|
39
|
+
combine: (e, u, c, l) => s.match(
|
|
40
40
|
e,
|
|
41
|
-
(t) =>
|
|
42
|
-
|
|
43
|
-
(r) =>
|
|
44
|
-
(r) =>
|
|
41
|
+
(t) => s.match(
|
|
42
|
+
u,
|
|
43
|
+
(r) => s.success(c(t, r)),
|
|
44
|
+
(r) => s.failure(r)
|
|
45
45
|
),
|
|
46
|
-
(t) =>
|
|
47
|
-
|
|
46
|
+
(t) => s.match(
|
|
47
|
+
u,
|
|
48
48
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
49
|
-
(r) =>
|
|
50
|
-
(r) =>
|
|
49
|
+
(r) => s.failure(t),
|
|
50
|
+
(r) => s.failure(l(t, r))
|
|
51
51
|
)
|
|
52
52
|
)
|
|
53
53
|
};
|
|
54
54
|
export {
|
|
55
|
-
|
|
55
|
+
s as Result
|
|
56
56
|
};
|
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
|
|
2
|
-
`)}function
|
|
3
|
-
`)
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./array.cjs"),A=require("./regexp.cjs");function f(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 x(n,t){const e=n.indexOf(t);return e<0?"":n.substring(0,e)}function P(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 R(n,t=!1){return t?A.map(h(n),Hn,m):A.map(h(n),Dn,m)}function Z(n){return n.replace(Vn,`
|
|
2
|
+
`)}function q(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 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 G(n,t){return y(n.toLowerCase(),t.map(e=>e.toLowerCase()))}function H(n,t){return B(n.toLowerCase(),t.map(e=>e.toLowerCase()))}function Q(n){return n.trim().replace(U," ")}function I(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.any(t,e=>C(n,e))}function V(n,t){return u.any(t,e=>l(n,e))}function X(n,t){return u.all(t,e=>C(n,e))}function Y(n,t){return u.all(t,e=>l(n,e))}function v(n){return n.replace("_","-")}function nn(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 tn(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),a=Math.floor((t-i)/2);return n.substr(0,c)+e+n.substr(r-a,a)}else return n}function y(n,t){return u.any(t,e=>d(n,e))}function en(n,t){return p(n).filter(t).join("")}function rn(n,t){return E(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 cn(n){return f(M(n),"_"," ")}function fn(n){return n.length>0&&!Gn.test(n)}function an(n){return Qn.test(n)}function ln(n){return!Fn.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 Kn.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.range(t,()=>W(n)).join("")}function An(n){return O(qn,n)}function mn(n,t){return p(t).map(n)}function Ln(n,t){return f(n,t,"")}function In(n,t){return d(n,t)?n.substring(0,n.length-t.length):n}function wn(n,t,e){return n.substring(0,t)+n.substring(t+e)}function yn(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 On(n){const t=p(n);return t.reverse(),t.join("")}function S(n,t="'"){return t==="'"?n.includes("'")?n.includes('"')?"'"+f(n,"'","\\'")+"'":'"'+n+'"':"'"+n+"'":n.includes('"')?n.includes("'")?'"'+f(n,'"','\\"')+'"':"'"+n+"'":'"'+n+'"'}function z(n,t="'"){return t+f(n,t,"\\"+t)+t}function Sn(n,t="'"){return n.indexOf(`
|
|
3
|
+
`)>=0?z(n,"`"):S(n,t)}function zn(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.any(t,e=>n.startsWith(e))}function Bn(n){return n.replace(Jn,"")}function En(n,t,e=t){return`${t}${n}${e}`}function p(n){return n.split("")}function E(n){return u.range(n.length,t=>n.charCodeAt(t))}function jn(n,t){const e=[];for(;n.length>0;)e.push(n.substring(0,t)),n=n.substr(t,n.length-t);return e}function Tn(n){return n.split(_)}function Mn(n,t){return T(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 T(n,t){const e=n.length;let r=e,i;for(let c=0;c<e&&(i=e-c-1,l(t,n.charAt(i)));c++)r=i;return n.substring(0,r)}function M(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 Un(n,t){const e=n.indexOf(t);return e<0?n:n.substring(0,e)}function _n(n,t=78,e="",r=`
|
|
4
|
+
`){return n.split(_).map(i=>N(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 kn(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 N(n,t,e,r){const i=[],c=n.length,a=e.length;let o=0;for(t-=a;;){if(o+t>=c-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<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 xn(n,t,e){const r=e-n.length;return r>0?b(t,r)+n:n}function Pn(n,t,e){const r=e-n.length;return r>0?n+b(t,r):n}function Rn(n,t){const e=n.lastIndexOf(t);return e>=0?[n.substring(0,e),n.substring(e+t.length)]:[n]}function Zn(n,t){const e=n.indexOf(t);return e>=0?[n.substring(0,e),n.substring(e+t.length)]:[n]}const qn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Dn=/[^a-zA-Z]([a-z])/g,Fn=/[^\t\n\r ]/,Gn=/[^a-zA-Z]/,Hn=/[ \t\r\n][a-z]/g,Qn=/^[a-z0-9]+$/i,Kn=/^[0-9]+$/,Jn=/<\/?[a-z]+[^>]*>/gi,U=/[ \t\r\n]+/g,_=/\r\n|\n\r|\n|\r/g,Vn=/\r\n|\n\r|\r/g;exports.after=k;exports.afterLast=$;exports.before=x;exports.beforeLast=P;exports.canonicalizeNewlines=Z;exports.capitalize=h;exports.capitalizeWords=R;exports.collapse=Q;exports.compare=I;exports.compareCaseInsensitive=q;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=$n;exports.diffIndex=nn;exports.ellipsis=w;exports.ellipsisMiddle=tn;exports.encodeBase64=kn;exports.endsWith=d;exports.endsWithAny=y;exports.endsWithAnyCaseInsensitive=G;exports.endsWithCaseInsensitive=D;exports.filter=en;exports.filterCharcode=rn;exports.from=sn;exports.hasContent=un;exports.hashCode=on;exports.humanize=cn;exports.ifEmpty=gn;exports.isAlpha=fn;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=xn;exports.map=mn;exports.quote=z;exports.random=W;exports.randomSequence=O;exports.randomSequence64=An;exports.remove=Ln;exports.removeAfter=In;exports.removeAt=wn;exports.removeBefore=yn;exports.removeOne=Wn;exports.repeat=b;exports.replace=f;exports.reverse=On;exports.rpad=Pn;exports.smartQuote=S;exports.splitOnFirst=Zn;exports.splitOnLast=Rn;exports.splitOnce=zn;exports.startsWith=L;exports.startsWithAny=B;exports.startsWithAnyCaseInsensitive=H;exports.startsWithCaseInsensitive=F;exports.stripTags=Bn;exports.surround=En;exports.toArray=p;exports.toCharcodes=E;exports.toChunks=jn;exports.toLines=Tn;exports.trimChars=Mn;exports.trimCharsLeft=j;exports.trimCharsRight=T;exports.underscore=M;exports.upTo=Un;exports.upperCaseFirst=Nn;exports.wrapColumns=_n;exports.wrapLine=N;
|
package/string.d.ts
CHANGED
|
@@ -235,7 +235,9 @@ export declare function reverse(s: string): string;
|
|
|
235
235
|
/**
|
|
236
236
|
* Converts a string in a quoted string.
|
|
237
237
|
*/
|
|
238
|
-
export declare function
|
|
238
|
+
export declare function smartQuote(s: string, prefer?: string): string;
|
|
239
|
+
export declare function quote(s: string, quoteChar?: string): string;
|
|
240
|
+
export declare function jsQuote(s: string, prefer?: string): string;
|
|
239
241
|
/**
|
|
240
242
|
* It only splits on the first occurrance of separator.
|
|
241
243
|
*/
|
package/string.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { any as
|
|
1
|
+
import { any as l, all as C, range as A, fill as O } from "./array.js";
|
|
2
2
|
import { map as p } from "./regexp.js";
|
|
3
|
-
function
|
|
3
|
+
function c(n, t, r) {
|
|
4
4
|
return n.split(t).join(r);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function V(n, t) {
|
|
7
7
|
const r = n.indexOf(t);
|
|
8
8
|
return r < 0 ? "" : n.substring(r + t.length);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function X(n, t) {
|
|
11
11
|
const r = n.lastIndexOf(t);
|
|
12
12
|
return r < 0 ? "" : n.substring(r + t.length);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function Y(n, t) {
|
|
15
15
|
const r = n.indexOf(t);
|
|
16
16
|
return r < 0 ? "" : n.substring(0, r);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function v(n, t) {
|
|
19
19
|
const r = n.lastIndexOf(t);
|
|
20
20
|
return r < 0 ? "" : n.substring(0, r);
|
|
21
21
|
}
|
|
@@ -23,41 +23,41 @@ function h(n) {
|
|
|
23
23
|
return n.substring(0, 1).toUpperCase() + n.substring(1);
|
|
24
24
|
}
|
|
25
25
|
const d = (n) => n.toUpperCase();
|
|
26
|
-
function
|
|
27
|
-
return t ? p(h(n),
|
|
26
|
+
function nn(n, t = !1) {
|
|
27
|
+
return t ? p(h(n), G, d) : p(h(n), Z, d);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return n.replace(
|
|
29
|
+
function tn(n) {
|
|
30
|
+
return n.replace(K, `
|
|
31
31
|
`);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function rn(n, t) {
|
|
34
34
|
return n == null && t == null ? 0 : n == null ? -1 : t == null ? 1 : y(n.toLowerCase(), t.toLowerCase());
|
|
35
35
|
}
|
|
36
36
|
function L(n, t) {
|
|
37
37
|
return n.substring(0, n.length - t.length) === t;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function en(n, t) {
|
|
40
40
|
return n.substring(0, n.length - t.length).toLowerCase() === t.toLowerCase();
|
|
41
41
|
}
|
|
42
42
|
function W(n, t) {
|
|
43
43
|
return n.substring(0, t.length) === t;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function on(n, t) {
|
|
46
46
|
return n.substring(0, t.length).toLowerCase() === t.toLowerCase();
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function sn(n, t) {
|
|
49
49
|
return E(
|
|
50
50
|
n.toLowerCase(),
|
|
51
51
|
t.map((r) => r.toLowerCase())
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
return
|
|
54
|
+
function un(n, t) {
|
|
55
|
+
return M(
|
|
56
56
|
n.toLowerCase(),
|
|
57
57
|
t.map((r) => r.toLowerCase())
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function fn(n) {
|
|
61
61
|
return n.trim().replace(m, " ");
|
|
62
62
|
}
|
|
63
63
|
function y(n, t) {
|
|
@@ -66,28 +66,28 @@ function y(n, t) {
|
|
|
66
66
|
function w(n, t) {
|
|
67
67
|
return n.toLowerCase().includes(t.toLowerCase());
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function a(n, t) {
|
|
70
70
|
return n.includes(t);
|
|
71
71
|
}
|
|
72
|
-
function un(n, t) {
|
|
73
|
-
return n.split(t).length - 1;
|
|
74
|
-
}
|
|
75
|
-
function fn(n, t) {
|
|
76
|
-
return c(t, (r) => w(n, r));
|
|
77
|
-
}
|
|
78
72
|
function cn(n, t) {
|
|
79
|
-
return
|
|
73
|
+
return n.split(t).length - 1;
|
|
80
74
|
}
|
|
81
75
|
function ln(n, t) {
|
|
82
|
-
return
|
|
76
|
+
return l(t, (r) => w(n, r));
|
|
83
77
|
}
|
|
84
78
|
function an(n, t) {
|
|
85
|
-
return
|
|
79
|
+
return l(t, (r) => a(n, r));
|
|
86
80
|
}
|
|
87
|
-
function gn(n) {
|
|
88
|
-
return
|
|
81
|
+
function gn(n, t) {
|
|
82
|
+
return C(t, (r) => w(n, r));
|
|
89
83
|
}
|
|
90
84
|
function pn(n, t) {
|
|
85
|
+
return C(t, (r) => a(n, r));
|
|
86
|
+
}
|
|
87
|
+
function hn(n) {
|
|
88
|
+
return n.replace("_", "-");
|
|
89
|
+
}
|
|
90
|
+
function dn(n, t) {
|
|
91
91
|
const r = Math.min(n.length, t.length);
|
|
92
92
|
for (let e = 0; e < r; e++)
|
|
93
93
|
if (n.substring(e, e + 1) !== t.substring(e, e + 1)) return e;
|
|
@@ -97,7 +97,7 @@ function z(n, t = 20, r = "…") {
|
|
|
97
97
|
const e = n.length, i = r.length;
|
|
98
98
|
return e > t ? t < i ? r.substr(i - t, t) : n.substr(0, t - i) + r : n;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function bn(n, t = 20, r = "…") {
|
|
101
101
|
const e = n.length, i = r.length;
|
|
102
102
|
if (e > t) {
|
|
103
103
|
if (t <= i)
|
|
@@ -107,55 +107,55 @@ function hn(n, t = 20, r = "…") {
|
|
|
107
107
|
} else return n;
|
|
108
108
|
}
|
|
109
109
|
function E(n, t) {
|
|
110
|
-
return
|
|
110
|
+
return l(t, (r) => L(n, r));
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function Cn(n, t) {
|
|
113
113
|
return g(n).filter(t).join("");
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
return
|
|
115
|
+
function An(n, t) {
|
|
116
|
+
return N(n).filter(t).map((e) => String.fromCharCode(e)).join("");
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function Ln(n, t) {
|
|
119
119
|
const r = n.indexOf(t);
|
|
120
120
|
return r < 0 ? "" : n.substring(r);
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function wn(n, t = 2166136261) {
|
|
123
123
|
let r = t;
|
|
124
124
|
for (let e = 0, i = n.length; e < i; e++)
|
|
125
125
|
r ^= n.charCodeAt(e), r += (r << 1) + (r << 4) + (r << 7) + (r << 8) + (r << 24);
|
|
126
126
|
return r >>> 0;
|
|
127
127
|
}
|
|
128
|
-
function Ln(n) {
|
|
129
|
-
return n != null && n.length > 0;
|
|
130
|
-
}
|
|
131
|
-
function wn(n) {
|
|
132
|
-
return a(T(n), "_", " ");
|
|
133
|
-
}
|
|
134
128
|
function In(n) {
|
|
135
|
-
return n.length > 0
|
|
129
|
+
return n != null && n.length > 0;
|
|
136
130
|
}
|
|
137
131
|
function mn(n) {
|
|
138
|
-
return
|
|
132
|
+
return c(k(n), "_", " ");
|
|
139
133
|
}
|
|
140
134
|
function Sn(n) {
|
|
141
|
-
return !
|
|
135
|
+
return n.length > 0 && !D.test(n);
|
|
142
136
|
}
|
|
143
137
|
function On(n) {
|
|
144
|
-
return
|
|
138
|
+
return H.test(n);
|
|
145
139
|
}
|
|
146
140
|
function Wn(n) {
|
|
141
|
+
return !R.test(n);
|
|
142
|
+
}
|
|
143
|
+
function yn(n) {
|
|
144
|
+
return n.toLowerCase() === n;
|
|
145
|
+
}
|
|
146
|
+
function zn(n) {
|
|
147
147
|
return n.toUpperCase() === n;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function En(n, t) {
|
|
150
150
|
return n != null && n !== "" ? n : t;
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
return
|
|
152
|
+
function Bn(n) {
|
|
153
|
+
return Q.test(n);
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function jn(n) {
|
|
156
156
|
return n == null || n === "";
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function _n(n) {
|
|
159
159
|
return n.substring(0, 1).toLowerCase() + n.substring(1);
|
|
160
160
|
}
|
|
161
161
|
function B(n, t = 1) {
|
|
@@ -167,118 +167,125 @@ function B(n, t = 1) {
|
|
|
167
167
|
function j(n, t) {
|
|
168
168
|
return A(t, () => B(n)).join("");
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
return j(
|
|
170
|
+
function $n(n) {
|
|
171
|
+
return j(P, n);
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function Mn(n, t) {
|
|
174
174
|
return g(t).map(n);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
return
|
|
176
|
+
function Nn(n, t) {
|
|
177
|
+
return c(n, t, "");
|
|
178
178
|
}
|
|
179
|
-
function
|
|
179
|
+
function Tn(n, t) {
|
|
180
180
|
return L(n, t) ? n.substring(0, n.length - t.length) : n;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function Un(n, t, r) {
|
|
183
183
|
return n.substring(0, t) + n.substring(t + r);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function kn(n, t) {
|
|
186
186
|
return W(n, t) ? n.substring(t.length) : n;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function xn(n, t) {
|
|
189
189
|
const r = n.indexOf(t);
|
|
190
190
|
return r < 0 ? n : n.substring(0, r) + n.substring(r + t.length);
|
|
191
191
|
}
|
|
192
192
|
function I(n, t) {
|
|
193
193
|
return O(t, n).join("");
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function Pn(n) {
|
|
196
196
|
const t = g(n);
|
|
197
197
|
return t.reverse(), t.join("");
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
return n.includes('"') ? n.includes("'") ? '"' +
|
|
199
|
+
function _(n, t = "'") {
|
|
200
|
+
return t === "'" ? n.includes("'") ? n.includes('"') ? "'" + c(n, "'", "\\'") + "'" : '"' + n + '"' : "'" + n + "'" : n.includes('"') ? n.includes("'") ? '"' + c(n, '"', '\\"') + '"' : "'" + n + "'" : '"' + n + '"';
|
|
201
|
+
}
|
|
202
|
+
function $(n, t = "'") {
|
|
203
|
+
return t + c(n, t, "\\" + t) + t;
|
|
201
204
|
}
|
|
202
|
-
function Zn(n, t) {
|
|
205
|
+
function Zn(n, t = "'") {
|
|
206
|
+
return n.indexOf(`
|
|
207
|
+
`) >= 0 ? $(n, "`") : _(n, t);
|
|
208
|
+
}
|
|
209
|
+
function Rn(n, t) {
|
|
203
210
|
const r = n.indexOf(t);
|
|
204
211
|
return r < 0 ? [n] : [n.substring(0, r), n.substring(r + t.length)];
|
|
205
212
|
}
|
|
206
|
-
function
|
|
207
|
-
return
|
|
213
|
+
function M(n, t) {
|
|
214
|
+
return l(t, (r) => n.startsWith(r));
|
|
208
215
|
}
|
|
209
|
-
function
|
|
210
|
-
return n.replace(
|
|
216
|
+
function Dn(n) {
|
|
217
|
+
return n.replace(F, "");
|
|
211
218
|
}
|
|
212
|
-
function
|
|
219
|
+
function Gn(n, t, r = t) {
|
|
213
220
|
return `${t}${n}${r}`;
|
|
214
221
|
}
|
|
215
222
|
function g(n) {
|
|
216
223
|
return n.split("");
|
|
217
224
|
}
|
|
218
|
-
function
|
|
225
|
+
function N(n) {
|
|
219
226
|
return A(n.length, (t) => n.charCodeAt(t));
|
|
220
227
|
}
|
|
221
|
-
function
|
|
228
|
+
function Hn(n, t) {
|
|
222
229
|
const r = [];
|
|
223
230
|
for (; n.length > 0; )
|
|
224
231
|
r.push(n.substring(0, t)), n = n.substr(t, n.length - t);
|
|
225
232
|
return r;
|
|
226
233
|
}
|
|
227
|
-
function
|
|
234
|
+
function Qn(n) {
|
|
228
235
|
return n.split(S);
|
|
229
236
|
}
|
|
230
|
-
function
|
|
231
|
-
return
|
|
237
|
+
function Fn(n, t) {
|
|
238
|
+
return U(T(n, t), t);
|
|
232
239
|
}
|
|
233
|
-
function
|
|
240
|
+
function T(n, t) {
|
|
234
241
|
let r = 0;
|
|
235
|
-
for (let e = 0; e < n.length &&
|
|
242
|
+
for (let e = 0; e < n.length && a(t, n.charAt(e)); e++)
|
|
236
243
|
r++;
|
|
237
244
|
return n.substring(r);
|
|
238
245
|
}
|
|
239
|
-
function
|
|
246
|
+
function U(n, t) {
|
|
240
247
|
const r = n.length;
|
|
241
248
|
let e = r, i;
|
|
242
|
-
for (let u = 0; u < r && (i = r - u - 1,
|
|
249
|
+
for (let u = 0; u < r && (i = r - u - 1, a(t, n.charAt(i))); u++)
|
|
243
250
|
e = i;
|
|
244
251
|
return n.substring(0, e);
|
|
245
252
|
}
|
|
246
|
-
function
|
|
253
|
+
function k(n) {
|
|
247
254
|
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();
|
|
248
255
|
}
|
|
249
|
-
function
|
|
256
|
+
function Kn(n) {
|
|
250
257
|
return n.substring(0, 1).toUpperCase() + n.substring(1);
|
|
251
258
|
}
|
|
252
|
-
function
|
|
259
|
+
function qn(n, t) {
|
|
253
260
|
const r = n.indexOf(t);
|
|
254
261
|
return r < 0 ? n : n.substring(0, r);
|
|
255
262
|
}
|
|
256
|
-
function
|
|
263
|
+
function Jn(n, t = 78, r = "", e = `
|
|
257
264
|
`) {
|
|
258
265
|
return n.split(S).map(
|
|
259
|
-
(i) =>
|
|
266
|
+
(i) => x(i.replace(m, " ").trim(), t, r, e)
|
|
260
267
|
).join(e);
|
|
261
268
|
}
|
|
262
|
-
function
|
|
269
|
+
function b(n, t) {
|
|
263
270
|
if (t < 0 || t >= n.length) return !1;
|
|
264
271
|
const r = n.charCodeAt(t);
|
|
265
272
|
return r === 9 || r === 10 || r === 11 || r === 12 || r === 13 || r === 32;
|
|
266
273
|
}
|
|
267
|
-
function
|
|
274
|
+
function Vn(n) {
|
|
268
275
|
if (typeof Buffer < "u")
|
|
269
276
|
return Buffer.from(n).toString("base64");
|
|
270
277
|
if (typeof btoa < "u")
|
|
271
278
|
return btoa(n);
|
|
272
279
|
throw new Error("no implementation provided for base64 encoding");
|
|
273
280
|
}
|
|
274
|
-
function
|
|
281
|
+
function Xn(n) {
|
|
275
282
|
if (typeof Buffer < "u")
|
|
276
283
|
return Buffer.from(n, "base64").toString("utf8");
|
|
277
284
|
if (typeof atob < "u")
|
|
278
285
|
return atob(n);
|
|
279
286
|
throw new Error("no implementation provided for base64 decoding");
|
|
280
287
|
}
|
|
281
|
-
function
|
|
288
|
+
function x(n, t, r, e) {
|
|
282
289
|
const i = [], u = n.length, f = r.length;
|
|
283
290
|
let s = 0;
|
|
284
291
|
for (t -= f; ; ) {
|
|
@@ -287,110 +294,112 @@ function U(n, t, r, e) {
|
|
|
287
294
|
break;
|
|
288
295
|
}
|
|
289
296
|
let o = 0;
|
|
290
|
-
for (; !
|
|
297
|
+
for (; !b(n, s + t - o) && o < t; ) o++;
|
|
291
298
|
if (o === t) {
|
|
292
|
-
for (o = 0; !
|
|
299
|
+
for (o = 0; !b(n, s + t + o) && s + t + o < u; ) o++;
|
|
293
300
|
i.push(n.substring(s, s + t + o)), s += t + o + 1;
|
|
294
301
|
} else
|
|
295
302
|
i.push(n.substring(s, s + t - o)), s += t - o + 1;
|
|
296
303
|
}
|
|
297
304
|
return r + i.join(e + r);
|
|
298
305
|
}
|
|
299
|
-
function
|
|
306
|
+
function Yn(n, t, r) {
|
|
300
307
|
const e = r - n.length;
|
|
301
308
|
return e > 0 ? I(t, e) + n : n;
|
|
302
309
|
}
|
|
303
|
-
function
|
|
310
|
+
function vn(n, t, r) {
|
|
304
311
|
const e = r - n.length;
|
|
305
312
|
return e > 0 ? n + I(t, e) : n;
|
|
306
313
|
}
|
|
307
|
-
function
|
|
314
|
+
function nt(n, t) {
|
|
308
315
|
const r = n.lastIndexOf(t);
|
|
309
316
|
return r >= 0 ? [n.substring(0, r), n.substring(r + t.length)] : [n];
|
|
310
317
|
}
|
|
311
|
-
function
|
|
318
|
+
function tt(n, t) {
|
|
312
319
|
const r = n.indexOf(t);
|
|
313
320
|
return r >= 0 ? [n.substring(0, r), n.substring(r + t.length)] : [n];
|
|
314
321
|
}
|
|
315
|
-
const
|
|
322
|
+
const P = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Z = /[^a-zA-Z]([a-z])/g, R = /[^\t\n\r ]/, D = /[^a-zA-Z]/, G = /[ \t\r\n][a-z]/g, H = /^[a-z0-9]+$/i, Q = /^[0-9]+$/, F = /<\/?[a-z]+[^>]*>/gi, m = /[ \t\r\n]+/g, S = /\r\n|\n\r|\n|\r/g, K = /\r\n|\n\r|\r/g;
|
|
316
323
|
export {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
324
|
+
V as after,
|
|
325
|
+
X as afterLast,
|
|
326
|
+
Y as before,
|
|
327
|
+
v as beforeLast,
|
|
328
|
+
tn as canonicalizeNewlines,
|
|
322
329
|
h as capitalize,
|
|
323
|
-
|
|
324
|
-
|
|
330
|
+
nn as capitalizeWords,
|
|
331
|
+
fn as collapse,
|
|
325
332
|
y as compare,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
333
|
+
rn as compareCaseInsensitive,
|
|
334
|
+
a as contains,
|
|
335
|
+
pn as containsAll,
|
|
336
|
+
gn as containsAllCaseInsensitive,
|
|
337
|
+
an as containsAny,
|
|
338
|
+
ln as containsAnyCaseInsensitive,
|
|
332
339
|
w as containsCaseInsensitive,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
340
|
+
cn as count,
|
|
341
|
+
hn as dasherize,
|
|
342
|
+
Xn as decodeBase64,
|
|
343
|
+
dn as diffIndex,
|
|
337
344
|
z as ellipsis,
|
|
338
|
-
|
|
339
|
-
|
|
345
|
+
bn as ellipsisMiddle,
|
|
346
|
+
Vn as encodeBase64,
|
|
340
347
|
L as endsWith,
|
|
341
348
|
E as endsWithAny,
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
349
|
+
sn as endsWithAnyCaseInsensitive,
|
|
350
|
+
en as endsWithCaseInsensitive,
|
|
351
|
+
Cn as filter,
|
|
352
|
+
An as filterCharcode,
|
|
353
|
+
Ln as from,
|
|
354
|
+
In as hasContent,
|
|
355
|
+
wn as hashCode,
|
|
356
|
+
mn as humanize,
|
|
357
|
+
En as ifEmpty,
|
|
358
|
+
Sn as isAlpha,
|
|
359
|
+
On as isAlphaNum,
|
|
360
|
+
Wn as isBreakingWhitespace,
|
|
361
|
+
Bn as isDigitsOnly,
|
|
362
|
+
jn as isEmpty,
|
|
363
|
+
yn as isLowerCase,
|
|
364
|
+
b as isSpaceAt,
|
|
365
|
+
zn as isUpperCase,
|
|
366
|
+
Zn as jsQuote,
|
|
367
|
+
_n as lowerCaseFirst,
|
|
368
|
+
Yn as lpad,
|
|
369
|
+
Mn as map,
|
|
370
|
+
$ as quote,
|
|
363
371
|
B as random,
|
|
364
372
|
j as randomSequence,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
373
|
+
$n as randomSequence64,
|
|
374
|
+
Nn as remove,
|
|
375
|
+
Tn as removeAfter,
|
|
376
|
+
Un as removeAt,
|
|
377
|
+
kn as removeBefore,
|
|
378
|
+
xn as removeOne,
|
|
371
379
|
I as repeat,
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
380
|
+
c as replace,
|
|
381
|
+
Pn as reverse,
|
|
382
|
+
vn as rpad,
|
|
383
|
+
_ as smartQuote,
|
|
384
|
+
tt as splitOnFirst,
|
|
385
|
+
nt as splitOnLast,
|
|
386
|
+
Rn as splitOnce,
|
|
378
387
|
W as startsWith,
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
388
|
+
M as startsWithAny,
|
|
389
|
+
un as startsWithAnyCaseInsensitive,
|
|
390
|
+
on as startsWithCaseInsensitive,
|
|
391
|
+
Dn as stripTags,
|
|
392
|
+
Gn as surround,
|
|
384
393
|
g as toArray,
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
394
|
+
N as toCharcodes,
|
|
395
|
+
Hn as toChunks,
|
|
396
|
+
Qn as toLines,
|
|
397
|
+
Fn as trimChars,
|
|
398
|
+
T as trimCharsLeft,
|
|
399
|
+
U as trimCharsRight,
|
|
400
|
+
k as underscore,
|
|
401
|
+
qn as upTo,
|
|
402
|
+
Kn as upperCaseFirst,
|
|
403
|
+
Jn as wrapColumns,
|
|
404
|
+
x as wrapLine
|
|
396
405
|
};
|
package/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/index.d.ts
DELETED
|
File without changes
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|