@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 CHANGED
@@ -1 +1,3 @@
1
1
  # Tempo Standard Library
2
+
3
+ A standard library for TypeScript.
package/async-result.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u={idle:{type:"idle"},loading:{type:"loading"},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"},isIdle(e){return e.type==="idle"},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.isIdle(r)?i():t(),match:(e,s,t,i,r=i)=>u.isSuccess(e)?s(e.value):u.isFailure(e)?t(e.error):u.isIdle(e)?r():i(),whenSuccess:e=>s=>(u.isSuccess(s)&&e(s.value),s),whenFailure:e=>s=>(u.isFailure(s)&&e(s.error),s)};exports.AsyncResult=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 Idle {
2
- type: 'idle';
1
+ export interface NotAsked {
2
+ type: 'NotAsked';
3
3
  }
4
- export interface Loading {
5
- type: 'loading';
4
+ export interface Loading<V> {
5
+ type: 'Loading';
6
+ previousValue?: V;
6
7
  }
7
8
  export interface Success<V> {
8
- type: 'success';
9
+ type: 'Success';
9
10
  value: V;
10
11
  }
11
12
  export interface Failure<E> {
12
- type: 'failure';
13
+ type: 'Failure';
13
14
  error: E;
14
15
  }
15
- export type AsyncResult<V, E> = Idle | Loading | Success<V> | Failure<E>;
16
+ export type AsyncResult<V, E> = NotAsked | Loading<V> | Success<V> | Failure<E>;
16
17
  export declare const AsyncResult: {
17
- idle: {
18
- type: "idle";
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
- isIdle<V, E>(r: AsyncResult<V, E>): r is Idle;
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
- idle: { type: "idle" },
3
- loading: { type: "loading" },
2
+ notAsked: { type: "NotAsked" },
3
+ loading(e = void 0) {
4
+ return { type: "Loading", previousValue: e };
5
+ },
4
6
  success(e) {
5
- return { type: "success", value: e };
7
+ return { type: "Success", value: e };
6
8
  },
7
9
  failure(e) {
8
- return { type: "failure", error: e };
10
+ return { type: "Failure", error: e };
9
11
  },
10
12
  isSuccess(e) {
11
- return e.type === "success";
13
+ return e.type === "Success";
12
14
  },
13
15
  isFailure(e) {
14
- return e.type === "failure";
16
+ return e.type === "Failure";
15
17
  },
16
- isIdle(e) {
17
- return e.type === "idle";
18
+ isNotAsked(e) {
19
+ return e.type === "NotAsked";
18
20
  },
19
21
  isLoading(e) {
20
- return e.type === "loading";
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, i, t = i) => (r) => u.isSuccess(r) ? e(r.value) : u.isFailure(r) ? s(r.error) : u.isIdle(r) ? t() : i(),
35
- match: (e, s, i, t, r = t) => u.isSuccess(e) ? s(e.value) : u.isFailure(e) ? i(e.error) : u.isIdle(e) ? r() : t(),
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
@@ -1,5 +1,5 @@
1
1
  export type Maybe<T> = Just<T> | Nothing;
2
- export type Nothing = undefined | null;
2
+ export type Nothing = undefined;
3
3
  export type Just<T> = NonNullable<T>;
4
4
  export declare const Maybe: {
5
5
  nothing: Maybe<never>;
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "@tempots/std",
3
- "version": "0.10.7",
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 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"});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: 'success';
4
+ type: 'Success';
5
5
  value: V;
6
6
  }
7
7
  export interface Failure<E> {
8
- type: 'failure';
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 u = {
1
+ const s = {
2
2
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
3
  success(e) {
4
- return { type: "success", value: e };
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: "failure", error: e };
8
+ return { type: "Failure", error: e };
9
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,
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 === "success";
18
+ return e.type === "Success";
19
19
  },
20
20
  isFailure(e) {
21
- return e.type === "failure";
21
+ return e.type === "Failure";
22
22
  },
23
- getOrElse(e, s) {
24
- return u.isSuccess(e) ? e.value : s;
23
+ getOrElse(e, u) {
24
+ return s.isSuccess(e) ? e.value : u;
25
25
  },
26
- getOrElseLazy(e, s) {
27
- return u.isSuccess(e) ? e.value : s();
26
+ getOrElseLazy(e, u) {
27
+ return s.isSuccess(e) ? e.value : u();
28
28
  },
29
29
  getOrNull(e) {
30
- return u.isSuccess(e) ? e.value : null;
30
+ return s.isSuccess(e) ? e.value : null;
31
31
  },
32
32
  getOrUndefined(e) {
33
- return u.isSuccess(e) ? e.value : void 0;
33
+ return s.isSuccess(e) ? e.value : void 0;
34
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(
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) => u.match(
42
- s,
43
- (r) => u.success(c(t, r)),
44
- (r) => u.failure(r)
41
+ (t) => s.match(
42
+ u,
43
+ (r) => s.success(c(t, r)),
44
+ (r) => s.failure(r)
45
45
  ),
46
- (t) => u.match(
47
- s,
46
+ (t) => s.match(
47
+ u,
48
48
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
- (r) => u.failure(t),
50
- (r) => u.failure(l(t, r))
49
+ (r) => s.failure(t),
50
+ (r) => s.failure(l(t, r))
51
51
  )
52
52
  )
53
53
  };
54
54
  export {
55
- u as Result
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 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 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 quote(s: string): string;
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 c, all as b, range as A, fill as O } from "./array.js";
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 a(n, t, r) {
3
+ function c(n, t, r) {
4
4
  return n.split(t).join(r);
5
5
  }
6
- function J(n, t) {
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 Q(n, t) {
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 V(n, t) {
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 X(n, t) {
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 Y(n, t = !1) {
27
- return t ? p(h(n), R, d) : p(h(n), P, d);
26
+ function nn(n, t = !1) {
27
+ return t ? p(h(n), G, d) : p(h(n), Z, d);
28
28
  }
29
- function v(n) {
30
- return n.replace(q, `
29
+ function tn(n) {
30
+ return n.replace(K, `
31
31
  `);
32
32
  }
33
- function nn(n, t) {
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 tn(n, t) {
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 rn(n, t) {
45
+ function on(n, t) {
46
46
  return n.substring(0, t.length).toLowerCase() === t.toLowerCase();
47
47
  }
48
- function en(n, t) {
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 on(n, t) {
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 sn(n) {
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 l(n, t) {
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 c(t, (r) => l(n, r));
73
+ return n.split(t).length - 1;
80
74
  }
81
75
  function ln(n, t) {
82
- return b(t, (r) => w(n, r));
76
+ return l(t, (r) => w(n, r));
83
77
  }
84
78
  function an(n, t) {
85
- return b(t, (r) => l(n, r));
79
+ return l(t, (r) => a(n, r));
86
80
  }
87
- function gn(n) {
88
- return n.replace("_", "-");
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 hn(n, t = 20, r = "…") {
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 c(t, (r) => L(n, r));
110
+ return l(t, (r) => L(n, r));
111
111
  }
112
- function dn(n, t) {
112
+ function Cn(n, t) {
113
113
  return g(n).filter(t).join("");
114
114
  }
115
- function Cn(n, t) {
116
- return $(n).filter(t).map((e) => String.fromCharCode(e)).join("");
115
+ function An(n, t) {
116
+ return N(n).filter(t).map((e) => String.fromCharCode(e)).join("");
117
117
  }
118
- function bn(n, t) {
118
+ function Ln(n, t) {
119
119
  const r = n.indexOf(t);
120
120
  return r < 0 ? "" : n.substring(r);
121
121
  }
122
- function An(n, t = 2166136261) {
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 && !x.test(n);
129
+ return n != null && n.length > 0;
136
130
  }
137
131
  function mn(n) {
138
- return D.test(n);
132
+ return c(k(n), "_", " ");
139
133
  }
140
134
  function Sn(n) {
141
- return !Z.test(n);
135
+ return n.length > 0 && !D.test(n);
142
136
  }
143
137
  function On(n) {
144
- return n.toLowerCase() === n;
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 yn(n, t) {
149
+ function En(n, t) {
150
150
  return n != null && n !== "" ? n : t;
151
151
  }
152
- function zn(n) {
153
- return G.test(n);
152
+ function Bn(n) {
153
+ return Q.test(n);
154
154
  }
155
- function En(n) {
155
+ function jn(n) {
156
156
  return n == null || n === "";
157
157
  }
158
- function Bn(n) {
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 jn(n) {
171
- return j(k, n);
170
+ function $n(n) {
171
+ return j(P, n);
172
172
  }
173
- function _n(n, t) {
173
+ function Mn(n, t) {
174
174
  return g(t).map(n);
175
175
  }
176
- function $n(n, t) {
177
- return a(n, t, "");
176
+ function Nn(n, t) {
177
+ return c(n, t, "");
178
178
  }
179
- function Mn(n, t) {
179
+ function Tn(n, t) {
180
180
  return L(n, t) ? n.substring(0, n.length - t.length) : n;
181
181
  }
182
- function Nn(n, t, r) {
182
+ function Un(n, t, r) {
183
183
  return n.substring(0, t) + n.substring(t + r);
184
184
  }
185
- function Tn(n, t) {
185
+ function kn(n, t) {
186
186
  return W(n, t) ? n.substring(t.length) : n;
187
187
  }
188
- function Un(n, t) {
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 kn(n) {
195
+ function Pn(n) {
196
196
  const t = g(n);
197
197
  return t.reverse(), t.join("");
198
198
  }
199
- function Pn(n) {
200
- return n.includes('"') ? n.includes("'") ? '"' + a(n, '"', '\\"') + '"' : "'" + n + "'" : '"' + n + '"';
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 _(n, t) {
207
- return c(t, (r) => n.startsWith(r));
213
+ function M(n, t) {
214
+ return l(t, (r) => n.startsWith(r));
208
215
  }
209
- function xn(n) {
210
- return n.replace(H, "");
216
+ function Dn(n) {
217
+ return n.replace(F, "");
211
218
  }
212
- function Rn(n, t, r = t) {
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 $(n) {
225
+ function N(n) {
219
226
  return A(n.length, (t) => n.charCodeAt(t));
220
227
  }
221
- function Dn(n, t) {
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 Gn(n) {
234
+ function Qn(n) {
228
235
  return n.split(S);
229
236
  }
230
- function Hn(n, t) {
231
- return N(M(n, t), t);
237
+ function Fn(n, t) {
238
+ return U(T(n, t), t);
232
239
  }
233
- function M(n, t) {
240
+ function T(n, t) {
234
241
  let r = 0;
235
- for (let e = 0; e < n.length && l(t, n.charAt(e)); e++)
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 N(n, t) {
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, l(t, n.charAt(i))); u++)
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 T(n) {
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 qn(n) {
256
+ function Kn(n) {
250
257
  return n.substring(0, 1).toUpperCase() + n.substring(1);
251
258
  }
252
- function Fn(n, t) {
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 Kn(n, t = 78, r = "", e = `
263
+ function Jn(n, t = 78, r = "", e = `
257
264
  `) {
258
265
  return n.split(S).map(
259
- (i) => U(i.replace(m, " ").trim(), t, r, e)
266
+ (i) => x(i.replace(m, " ").trim(), t, r, e)
260
267
  ).join(e);
261
268
  }
262
- function C(n, t) {
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 Jn(n) {
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 Qn(n) {
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 U(n, t, r, e) {
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 (; !C(n, s + t - o) && o < t; ) o++;
297
+ for (; !b(n, s + t - o) && o < t; ) o++;
291
298
  if (o === t) {
292
- for (o = 0; !C(n, s + t + o) && s + t + o < u; ) o++;
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 Vn(n, t, r) {
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 Xn(n, t, r) {
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 Yn(n, t) {
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 vn(n, t) {
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 k = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", P = /[^a-zA-Z]([a-z])/g, Z = /[^\t\n\r ]/, x = /[^a-zA-Z]/, R = /[ \t\r\n][a-z]/g, D = /^[a-z0-9]+$/i, G = /^[0-9]+$/, H = /<\/?[a-z]+[^>]*>/gi, m = /[ \t\r\n]+/g, S = /\r\n|\n\r|\n|\r/g, q = /\r\n|\n\r|\r/g;
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
- J as after,
318
- Q as afterLast,
319
- V as before,
320
- X as beforeLast,
321
- v as canonicalizeNewlines,
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
- Y as capitalizeWords,
324
- sn as collapse,
330
+ nn as capitalizeWords,
331
+ fn as collapse,
325
332
  y as compare,
326
- nn as compareCaseInsensitive,
327
- l as contains,
328
- an as containsAll,
329
- ln as containsAllCaseInsensitive,
330
- cn as containsAny,
331
- fn as containsAnyCaseInsensitive,
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
- un as count,
334
- gn as dasherize,
335
- Qn as decodeBase64,
336
- pn as diffIndex,
340
+ cn as count,
341
+ hn as dasherize,
342
+ Xn as decodeBase64,
343
+ dn as diffIndex,
337
344
  z as ellipsis,
338
- hn as ellipsisMiddle,
339
- Jn as encodeBase64,
345
+ bn as ellipsisMiddle,
346
+ Vn as encodeBase64,
340
347
  L as endsWith,
341
348
  E as endsWithAny,
342
- en as endsWithAnyCaseInsensitive,
343
- tn as endsWithCaseInsensitive,
344
- dn as filter,
345
- Cn as filterCharcode,
346
- bn as from,
347
- Ln as hasContent,
348
- An as hashCode,
349
- wn as humanize,
350
- yn as ifEmpty,
351
- In as isAlpha,
352
- mn as isAlphaNum,
353
- Sn as isBreakingWhitespace,
354
- zn as isDigitsOnly,
355
- En as isEmpty,
356
- On as isLowerCase,
357
- C as isSpaceAt,
358
- Wn as isUpperCase,
359
- Bn as lowerCaseFirst,
360
- Vn as lpad,
361
- _n as map,
362
- Pn as quote,
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
- jn as randomSequence64,
366
- $n as remove,
367
- Mn as removeAfter,
368
- Nn as removeAt,
369
- Tn as removeBefore,
370
- Un as removeOne,
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
- a as replace,
373
- kn as reverse,
374
- Xn as rpad,
375
- vn as splitOnFirst,
376
- Yn as splitOnLast,
377
- Zn as splitOnce,
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
- _ as startsWithAny,
380
- on as startsWithAnyCaseInsensitive,
381
- rn as startsWithCaseInsensitive,
382
- xn as stripTags,
383
- Rn as surround,
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
- $ as toCharcodes,
386
- Dn as toChunks,
387
- Gn as toLines,
388
- Hn as trimChars,
389
- M as trimCharsLeft,
390
- N as trimCharsRight,
391
- T as underscore,
392
- Fn as upTo,
393
- qn as upperCaseFirst,
394
- Kn as wrapColumns,
395
- U as wrapLine
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
-