@tempots/std 0.9.7 → 0.10.3
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 +1 -3
- package/array.cjs +1 -0
- package/{arrays.d.ts → array.d.ts} +7 -7
- package/array.js +223 -0
- package/bigint.cjs +1 -0
- package/bigint.js +96 -110
- package/boolean.cjs +1 -0
- package/boolean.js +44 -0
- package/domain.cjs +1 -0
- package/domain.d.ts +22 -0
- package/domain.js +1 -0
- package/equal.cjs +1 -0
- package/equal.js +68 -0
- package/function.cjs +1 -0
- package/function.js +29 -0
- package/index.cjs +1 -0
- package/index.d.ts +0 -0
- package/index.js +1 -0
- package/maybe.cjs +1 -0
- package/maybe.d.ts +3 -3
- package/maybe.js +8 -24
- package/number.cjs +1 -0
- package/{numbers.d.ts → number.d.ts} +2 -5
- package/number.js +103 -0
- package/object.cjs +1 -0
- package/object.d.ts +8 -0
- package/object.js +30 -0
- package/package.json +55 -25
- package/regexp.cjs +1 -0
- package/regexp.js +14 -0
- package/string.cjs +3 -0
- package/{strings.d.ts → string.d.ts} +0 -2
- package/string.js +396 -0
- package/arrays.js +0 -249
- package/async-result.d.ts +0 -37
- package/async-result.js +0 -75
- package/booleans.js +0 -68
- package/colors/cmyk.d.ts +0 -21
- package/colors/cmyk.js +0 -54
- package/colors/convert.d.ts +0 -283
- package/colors/convert.js +0 -742
- package/colors/hsl.d.ts +0 -24
- package/colors/hsl.js +0 -56
- package/colors/hsla.d.ts +0 -18
- package/colors/hsla.js +0 -35
- package/colors/hsluv.d.ts +0 -24
- package/colors/hsluv.js +0 -56
- package/colors/hsv.d.ts +0 -24
- package/colors/hsv.js +0 -54
- package/colors/lab.d.ts +0 -24
- package/colors/lab.js +0 -54
- package/colors/lch.d.ts +0 -19
- package/colors/lch.js +0 -44
- package/colors/luv.d.ts +0 -19
- package/colors/luv.js +0 -45
- package/colors/rgb.d.ts +0 -13
- package/colors/rgb.js +0 -47
- package/colors/rgba.d.ts +0 -12
- package/colors/rgba.js +0 -44
- package/colors/srgb.d.ts +0 -24
- package/colors/srgb.js +0 -51
- package/colors/xyz.d.ts +0 -19
- package/colors/xyz.js +0 -41
- package/edit.d.ts +0 -20
- package/edit.js +0 -29
- package/equals.js +0 -122
- package/functions.js +0 -38
- package/json.d.ts +0 -14
- package/json.js +0 -33
- package/match.d.ts +0 -16
- package/match.js +0 -45
- package/memoize.d.ts +0 -1
- package/memoize.js +0 -9
- package/newtype.d.ts +0 -28
- package/newtype.js +0 -29
- package/numbers.js +0 -183
- package/objects.d.ts +0 -9
- package/objects.js +0 -33
- package/ord.d.ts +0 -19
- package/ord.js +0 -73
- package/reg-exps.js +0 -43
- package/result.d.ts +0 -31
- package/result.js +0 -95
- package/strings.js +0 -685
- package/types/assert.d.ts +0 -12
- package/types/assert.js +0 -13
- package/types/differentiate.d.ts +0 -13
- package/types/differentiate.js +0 -14
- package/types/functions.d.ts +0 -22
- package/types/functions.js +0 -13
- package/types/generic.d.ts +0 -9
- package/types/generic.js +0 -13
- package/types/objects.d.ts +0 -50
- package/types/objects.js +0 -13
- package/types/tuples.d.ts +0 -44
- package/types/tuples.js +0 -24
- package/types/utility.d.ts +0 -2
- package/types/utility.js +0 -1
- package/uuid.d.ts +0 -13
- package/uuid.js +0 -56
- package/validation.d.ts +0 -23
- package/validation.js +0 -44
- /package/{booleans.d.ts → boolean.d.ts} +0 -0
- /package/{equals.d.ts → equal.d.ts} +0 -0
- /package/{functions.d.ts → function.d.ts} +0 -0
- /package/{reg-exps.d.ts → regexp.d.ts} +0 -0
package/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/index.d.ts
ADDED
|
File without changes
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/maybe.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={nothing:void 0,just:t=>t,isNothing:t=>t==null,isJust:t=>t!=null};exports.Maybe=e;
|
package/maybe.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export type Maybe<T> = Just<T> | Nothing;
|
|
2
2
|
export type Nothing = undefined | null;
|
|
3
|
-
export type Just<T> = T
|
|
3
|
+
export type Just<T> = NonNullable<T>;
|
|
4
4
|
export declare const Maybe: {
|
|
5
5
|
nothing: Maybe<never>;
|
|
6
6
|
just: <T>(value: T) => Maybe<T>;
|
|
7
|
-
isNothing: <
|
|
8
|
-
isJust: <
|
|
7
|
+
isNothing: <T>(maybe: Maybe<T>) => maybe is Nothing;
|
|
8
|
+
isJust: <T>(maybe: Maybe<T>) => maybe is Just<T>;
|
|
9
9
|
};
|
package/maybe.js
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
-
See the License for the specific language governing permissions and
|
|
11
|
-
limitations under the License.
|
|
12
|
-
*/
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
14
|
-
export const Maybe = {
|
|
15
|
-
nothing: undefined,
|
|
16
|
-
just: (value) => {
|
|
17
|
-
return value;
|
|
18
|
-
},
|
|
19
|
-
isNothing: (maybe) => {
|
|
20
|
-
return maybe == null;
|
|
21
|
-
},
|
|
22
|
-
isJust: (maybe) => {
|
|
23
|
-
return maybe != null;
|
|
24
|
-
}
|
|
1
|
+
const t = {
|
|
2
|
+
nothing: void 0,
|
|
3
|
+
just: (n) => n,
|
|
4
|
+
isNothing: (n) => n == null,
|
|
5
|
+
isJust: (n) => n != null
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
t as Maybe
|
|
25
9
|
};
|
package/number.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./string.cjs"),s=1e-4,l=1e-9;function f(e,n,t=360){let r=(n-e)%t;return r<0&&(r+=t),r>t/2&&(r-=t),r}function p(e,n){const t=Math.pow(10,n);return Math.ceil(e*t)/t}function c(e,n,t){return Math.min(Math.max(e,n),t)}function g(e,n,t){return Math.trunc(c(e,n,t))}function A(e,n){return c(e,-n,n)}function M(e,n){return e<n?-1:e>n?1:0}function h(e,n){const t=Math.pow(10,n);return Math.floor(e*t)/t}function d(e,n=0){return a.lpad(e.toString(16),"0",n)}function o(e,n,t){return(n-e)*t+e}function w(e,n,t,r=360){return i(o(e,e+f(e,n,r),t),r)}function u(e,n,t=360){let r=(n-e)%t;return r<0&&(r+=t),r>t/2&&(r-=t),r}function C(e,n,t,r=360){return i(o(e,e+u(e,n,r),t),r)}function E(e,n,t,r=360){return e=i(e,r),n=i(n,r),n<e&&(n+=r),i(o(e,n,t),r)}function N(e,n,t,r=360){return e=i(e,r),n=i(n,r),n>e&&(n-=r),i(o(e,n,t),r)}function T(e,n,t=l){return isFinite(e)?isFinite(n)?Math.abs(e-n)<=t:!1:isNaN(e)?isNaN(n):isNaN(n)||isFinite(n)?!1:e>0==n>0}function m(e,n,t=360,r=l){return Math.abs(f(e,n,t))<=r}function S(e,n=l){return Math.abs(e)<=n}function W(e,n){return Math.pow(e,1/n)}function q(e,n){const t=Math.pow(10,n);return Math.round(e*t)/t}function O(e){return e<0?-1:1}function y(e,n,t){const r=t-n+1;return e<n&&(e+=r*((n-e)/r+1)),n+(e-n)%r}function i(e,n){return e=e%n,e<0&&(e+=n),e}exports.EPSILON=l;exports.TOLERANCE=s;exports.angleDifference=f;exports.ceilTo=p;exports.clamp=c;exports.clampInt=g;exports.clampSym=A;exports.compare=M;exports.floorTo=h;exports.interpolate=o;exports.interpolateAngle=w;exports.interpolateAngleCCW=N;exports.interpolateAngleCW=E;exports.interpolateWidestAngle=C;exports.nearEqualAngles=m;exports.nearEquals=T;exports.nearZero=S;exports.root=W;exports.roundTo=q;exports.sign=O;exports.toHex=d;exports.widestAngleDifference=u;exports.wrap=y;exports.wrapCircular=i;
|
|
@@ -34,10 +34,6 @@ export declare function compare(a: number, b: number): number;
|
|
|
34
34
|
Rounds a number down to the specified number of decimals.
|
|
35
35
|
**/
|
|
36
36
|
export declare function floorTo(v: number, decimals: number): number;
|
|
37
|
-
/**
|
|
38
|
-
`normalize` clamps the passwed value between 0 and 1.
|
|
39
|
-
**/
|
|
40
|
-
export declare function normalize(value: number): number;
|
|
41
37
|
export declare function toHex(num: number, length?: number): string;
|
|
42
38
|
/**
|
|
43
39
|
`interpolate` returns a value between `a` and `b` for any value of `t` (normally between 0 and 1).
|
|
@@ -48,11 +44,12 @@ Interpolates values in a polar coordinate system looking for the narrowest delta
|
|
|
48
44
|
It can be either clock-wise or counter-clock-wise.
|
|
49
45
|
**/
|
|
50
46
|
export declare function interpolateAngle(a: number, b: number, t: number, turn?: number): number;
|
|
47
|
+
export declare function widestAngleDifference(a: number, b: number, turn?: number): number;
|
|
51
48
|
/**
|
|
52
49
|
Interpolates values in a polar coordinate system looking for the wideset delta angle.
|
|
53
50
|
It can be either clock-wise or counter-clock-wise.
|
|
54
51
|
**/
|
|
55
|
-
export declare function
|
|
52
|
+
export declare function interpolateWidestAngle(a: number, b: number, t: number, turn?: number): number;
|
|
56
53
|
/**
|
|
57
54
|
Interpolates values in a polar coordinate system always in clock-wise direction.
|
|
58
55
|
**/
|
package/number.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
f as EPSILON,
|
|
80
|
+
p as TOLERANCE,
|
|
81
|
+
u as angleDifference,
|
|
82
|
+
h as ceilTo,
|
|
83
|
+
c as clamp,
|
|
84
|
+
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,
|
|
93
|
+
F as nearEqualAngles,
|
|
94
|
+
m as nearEquals,
|
|
95
|
+
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
|
|
103
|
+
};
|
package/object.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(e){return Object.keys(e)}function c(e,t){const u=s(e),r=s(t);if(u.length!==r.length)return!1;for(const n of u)if(!(n in t))return!1;return!0}function i(e){return e!=null&&Object.getPrototypeOf(e)===Object.prototype}function o(e,...t){return s(e).reduce((r,n)=>(t.includes(n)||(r[n]=e[n]),r),{})}function f(e,t){return Object.assign({},e,t)}function l(e){return e==null||i(e)&&Object.keys(e).length===0}exports.isEmpty=l;exports.isObject=i;exports.keys=s;exports.merge=f;exports.removeFields=o;exports.sameKeys=c;
|
package/object.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IndexKey, Merge, TupleToUnion } from './domain';
|
|
2
|
+
|
|
3
|
+
export declare function keys<T extends object>(obj: T): Array<keyof T>;
|
|
4
|
+
export declare function sameKeys<T extends object>(a: T, b: T): boolean;
|
|
5
|
+
export declare function isObject(obj: unknown): obj is Record<IndexKey, unknown>;
|
|
6
|
+
export declare function removeFields<T extends object, F extends Array<keyof T>>(ob: T, ...fields: F): Omit<T, TupleToUnion<F>>;
|
|
7
|
+
export declare function merge<A extends Record<IndexKey, unknown>, B extends Record<IndexKey, unknown>>(a: A, b: B): Merge<A, B>;
|
|
8
|
+
export declare function isEmpty(obj: object): boolean;
|
package/object.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function s(e) {
|
|
2
|
+
return Object.keys(e);
|
|
3
|
+
}
|
|
4
|
+
function i(e, t) {
|
|
5
|
+
const u = s(e), r = s(t);
|
|
6
|
+
if (u.length !== r.length) return !1;
|
|
7
|
+
for (const n of u)
|
|
8
|
+
if (!(n in t)) return !1;
|
|
9
|
+
return !0;
|
|
10
|
+
}
|
|
11
|
+
function c(e) {
|
|
12
|
+
return e != null && Object.getPrototypeOf(e) === Object.prototype;
|
|
13
|
+
}
|
|
14
|
+
function f(e, ...t) {
|
|
15
|
+
return s(e).reduce((r, n) => (t.includes(n) || (r[n] = e[n]), r), {});
|
|
16
|
+
}
|
|
17
|
+
function o(e, t) {
|
|
18
|
+
return Object.assign({}, e, t);
|
|
19
|
+
}
|
|
20
|
+
function l(e) {
|
|
21
|
+
return e == null || c(e) && Object.keys(e).length === 0;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
l as isEmpty,
|
|
25
|
+
c as isObject,
|
|
26
|
+
s as keys,
|
|
27
|
+
o as merge,
|
|
28
|
+
f as removeFields,
|
|
29
|
+
i as sameKeys
|
|
30
|
+
};
|
package/package.json
CHANGED
|
@@ -1,34 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempots/std",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
"exports": {
|
|
6
|
+
"array": {
|
|
7
|
+
"import": "./array.js",
|
|
8
|
+
"require": "./array.cjs"
|
|
9
|
+
},
|
|
10
|
+
"bigint": {
|
|
11
|
+
"import": "./bigint.js",
|
|
12
|
+
"require": "./bigint.cjs"
|
|
13
|
+
},
|
|
14
|
+
"boolean": {
|
|
15
|
+
"import": "./boolean.js",
|
|
16
|
+
"require": "./boolean.cjs"
|
|
17
|
+
},
|
|
18
|
+
"domain": {
|
|
19
|
+
"import": "./domain.js",
|
|
20
|
+
"require": "./domain.cjs"
|
|
21
|
+
},
|
|
22
|
+
"equal": {
|
|
23
|
+
"import": "./equal.js",
|
|
24
|
+
"require": "./equal.cjs"
|
|
25
|
+
},
|
|
26
|
+
"function": {
|
|
27
|
+
"import": "./function.js",
|
|
28
|
+
"require": "./function.cjs"
|
|
29
|
+
},
|
|
30
|
+
"index": {
|
|
31
|
+
"import": "./index.js",
|
|
32
|
+
"require": "./index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"maybe": {
|
|
35
|
+
"import": "./maybe.js",
|
|
36
|
+
"require": "./maybe.cjs"
|
|
37
|
+
},
|
|
38
|
+
"number": {
|
|
39
|
+
"import": "./number.js",
|
|
40
|
+
"require": "./number.cjs"
|
|
41
|
+
},
|
|
42
|
+
"object": {
|
|
43
|
+
"import": "./object.js",
|
|
44
|
+
"require": "./object.cjs"
|
|
45
|
+
},
|
|
46
|
+
"regexp": {
|
|
47
|
+
"import": "./regexp.js",
|
|
48
|
+
"require": "./regexp.cjs"
|
|
49
|
+
},
|
|
50
|
+
"string": {
|
|
51
|
+
"import": "./string.js",
|
|
52
|
+
"require": "./string.cjs"
|
|
53
|
+
}
|
|
10
54
|
},
|
|
11
|
-
"
|
|
12
|
-
"@types/node": "^18.15.11",
|
|
13
|
-
"@typescript-eslint/eslint-plugin": "^5.43.0",
|
|
14
|
-
"eslint": "^8.0.1",
|
|
15
|
-
"eslint-config-standard-with-typescript": "^34.0.1",
|
|
16
|
-
"eslint-plugin-import": "^2.25.2",
|
|
17
|
-
"eslint-plugin-n": "^15.0.0",
|
|
18
|
-
"eslint-plugin-promise": "^6.0.0",
|
|
19
|
-
"typescript": "^5.0.3",
|
|
20
|
-
"vitest": "^0.29.8"
|
|
21
|
-
},
|
|
22
|
-
"main": "index.js",
|
|
55
|
+
"license": "Apache-2.0",
|
|
23
56
|
"repository": {
|
|
24
57
|
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/fponticelli/tempots
|
|
58
|
+
"url": "git+https://github.com/fponticelli/tempots.git"
|
|
26
59
|
},
|
|
27
|
-
"author": "Franco Ponticelli",
|
|
28
|
-
"license": "Apache-2.0",
|
|
29
60
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/fponticelli/tempots
|
|
61
|
+
"url": "https://github.com/fponticelli/tempots/issues"
|
|
31
62
|
},
|
|
32
|
-
"homepage": "https://github.com/fponticelli/tempots
|
|
33
|
-
|
|
34
|
-
}
|
|
63
|
+
"homepage": "https://github.com/fponticelli/tempots#readme"
|
|
64
|
+
}
|
package/regexp.cjs
ADDED
|
@@ -0,0 +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.map=g;
|
package/regexp.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function h(e, i, u) {
|
|
2
|
+
const s = [];
|
|
3
|
+
let n = 0, l;
|
|
4
|
+
if (i.global)
|
|
5
|
+
for (i.lastIndex = 0; (l = i.exec(e)) !== null; )
|
|
6
|
+
s.push(e.substring(n, l.index)), s.push(u(...l)), n = l.index + l[0].length;
|
|
7
|
+
else
|
|
8
|
+
for (; (l = i.exec(e.substring(n))) !== null; )
|
|
9
|
+
s.push(e.substring(n, n + l.index)), s.push(u(...l)), n += l.index + l[0].length;
|
|
10
|
+
return s.push(e.substring(n)), s.join("");
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
h as map
|
|
14
|
+
};
|
package/string.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
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,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility functions to manipulate string values.
|
|
3
3
|
*/
|
|
4
|
-
import { Ord } from './ord';
|
|
5
4
|
/**
|
|
6
5
|
* Replaces all occurrances of `placeholder` in `subject` with the value `replacement`.
|
|
7
6
|
* @param subject
|
|
@@ -70,7 +69,6 @@ export declare function collapse(value: string): string;
|
|
|
70
69
|
* or otherwise a positive non-sero number.
|
|
71
70
|
*/
|
|
72
71
|
export declare function compare(a: string, b: string): number;
|
|
73
|
-
export declare const order: Ord<string>;
|
|
74
72
|
/**
|
|
75
73
|
* `contains` returns `true` if `s` contains one or more occurrences of `test` regardless of the text case.
|
|
76
74
|
*/
|