@tempots/std 0.9.6 → 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/array.d.ts +49 -0
- package/array.js +223 -0
- package/bigint.cjs +1 -0
- package/bigint.d.ts +18 -0
- package/bigint.js +96 -0
- package/boolean.cjs +1 -0
- package/boolean.d.ts +23 -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.d.ts +3 -0
- package/equal.js +68 -0
- package/function.cjs +1 -0
- package/function.d.ts +20 -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 +9 -0
- package/maybe.js +9 -0
- package/number.cjs +1 -0
- package/number.d.ts +101 -0
- 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.d.ts +10 -0
- package/regexp.js +14 -0
- package/string.cjs +3 -0
- package/string.d.ts +312 -0
- package/string.js +396 -0
- package/src/arrays.ts +0 -296
- package/src/async-result.ts +0 -103
- package/src/bigint.ts +0 -111
- package/src/booleans.ts +0 -73
- package/src/colors/cmyk.ts +0 -84
- package/src/colors/convert.ts +0 -1093
- package/src/colors/hsl.ts +0 -73
- package/src/colors/hsla.ts +0 -45
- package/src/colors/hsluv.ts +0 -73
- package/src/colors/hsv.ts +0 -75
- package/src/colors/lab.ts +0 -69
- package/src/colors/lch.ts +0 -53
- package/src/colors/luv.ts +0 -56
- package/src/colors/rgb.ts +0 -55
- package/src/colors/rgba.ts +0 -53
- package/src/colors/srgb.ts +0 -72
- package/src/colors/xyz.ts +0 -52
- package/src/edit.ts +0 -29
- package/src/equals.ts +0 -116
- package/src/functions.ts +0 -108
- package/src/json.ts +0 -52
- package/src/match.ts +0 -88
- package/src/maybe.ts +0 -32
- package/src/memoize.ts +0 -9
- package/src/newtype.ts +0 -59
- package/src/numbers.ts +0 -222
- package/src/objects.ts +0 -47
- package/src/ord.ts +0 -79
- package/src/reg-exps.ts +0 -48
- package/src/result.ts +0 -140
- package/src/strings.ts +0 -768
- package/src/types/assert.ts +0 -96
- package/src/types/differentiate.ts +0 -89
- package/src/types/functions.ts +0 -114
- package/src/types/generic.ts +0 -42
- package/src/types/objects.ts +0 -212
- package/src/types/tuples.ts +0 -244
- package/src/types/utility.ts +0 -3
- package/src/uuid.ts +0 -61
- package/src/validation.ts +0 -69
- package/test/arrays.spec.ts +0 -410
- package/test/colors.spec.ts +0 -406
- package/test/commmon.ts +0 -9
- package/test/equals.spec.ts +0 -165
- package/test/functions.spec.ts +0 -9
- package/test/index.d.ts +0 -20
- package/test/objects.spec.ts +0 -22
- package/test/reg-exps.spec.ts +0 -33
- package/test/strings.spec.ts +0 -333
- package/test/uuid.spec.ts +0 -35
- package/tsconfig.json +0 -19
package/README.md
CHANGED
package/array.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./maybe.cjs"),M=require("./object.cjs");function q(t,e){return Array.from({length:t.length},(n,r)=>e(t[r],r))}function E(t,e){const n=[];for(let r=0;r<t.length;r++){const i=e(t[r],r);i!=null&&n.push(i)}return n}function j(t,e){const n=[];for(const r of t)n.push(...e(r));return n}function w(t){return t.length>0?y.Maybe.just(t[0]):y.Maybe.nothing}function A(t){return t.slice(1)}function b(t,e,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function N(t){return function(e,n){return b(e,n,t)}}function O(t){return t.length===0}function B(t){return t.length>0}function k(t,e){const n=[];for(const r of t)e(r)&&n.push(r);return n}function I(t,e){const n=[];for(let r=0;r<t.length;r++){const i=e(t[r],r);i!=null&&n.push(i)}return n}function P(t){return k(t,e=>e!=null)}function _(t){return[].concat(...t)}function S(t,e,n){for(const r of t)n=e(n,r);return n}function C(t,e){for(const n of t)if(!e(n))return!1;return!0}function R(t,e){for(const n of t)if(e(n))return!0;return!1}function T(t,e){for(const n of t)e(n)}function $(...t){return[].concat(...t)}function D(t,e=!0){return function(n,r){if(n.length<r.length)return-1*(e?1:-1);if(n.length>r.length)return 1*(e?1:-1);for(let i=0;i<n.length;i++){const u=t(n[i],r[i]);if(u!==0)return u}return 0}}function L(t,e){return e.slice().sort(t)}function d(t,e){return Array.from({length:t},(n,r)=>e(r))}function V(t,e=0){return d(t,n=>e+n)}function W(t,e){return d(t,()=>e)}function z(t){return Array.from(new Set(t))}function G(t,e){const n={};return t.forEach(r=>{n[e(r)]=r}),M.keys(n).map(r=>n[r])}function H(t,e){const n=t.indexOf(e);return n<0?!1:(t.splice(n,1),!0)}function J(t,e){const n=t.findIndex(e);return n<0?!1:(t.splice(n,1),!0)}function Q(t){const e=[];for(let n=t.next();!(n.done??!1);n=t.next())e.push(n.value);return e}function U(t,e,n){const r={removals:[],swaps:[],inserts:[]},{removals:i,inserts:u,swaps:a}=r,l=new Map;e.forEach((o,f)=>l.set(n(o),f));const s=t.map((o,f)=>[o,f]).filter(([o])=>!l.has(n(o))).map(([o,f])=>f);for(let o=s.length-1;o>=0;o--){const f=s[o],c=i.length>0?i[i.length-1]:void 0;c!=null&&c.at===f+1?(c.at--,c.qt++):i.push({at:f,qt:1})}const h=new Map;t.forEach((o,f)=>h.set(n(o),f));const g=e.map((o,f)=>[o,f]).filter(([o])=>!h.has(n(o))).map(([o,f])=>f);for(const o of g){const f=u.length>0?u[u.length-1]:void 0;f!=null&&f.at+f.values.length===o?f.values.push(e[o]):u.push({at:o,values:[e[o]]})}const p=t.filter((o,f)=>!s.includes(f)),m=new Map;for(let o=0;o<p.length;o++)m.set(n(p[o]),o);const v=e.filter((o,f)=>!g.includes(f));for(let o=0;o<v.length;o++){const f=n(v[o]),c=m.get(f);if(c==null||o===c)continue;const x=n(p[o]);m.delete(x),a.push({from:o,to:c})}return r}function X(t,e){const n=[...e];for(const{at:r,qt:i}of t.removals)n.splice(r,i);for(const{from:r,to:i}of t.swaps){const u=n[i];n[i]=n[r],n[r]=u}for(const r of t.inserts)n.splice(r.at,0,...r.values);return n}function Y(t,e=" and ",n=", "){return t.length===0?"":t.length===1?String(t[0]):`${t.slice(0,-1).join(n)}${e}${String(t[t.length-1])}`}function Z(t,e,n=!0){const r=t.map((l,s)=>[l,s]);r.sort((l,s)=>e(l[0],s[0]));const i=new Array(r.length);let u=0,a=r[0][0];for(let l=0;l<r.length;l++){const[s,h]=r[l];e(s,a)!==0&&(u=l,a=s),i[h]=u,n&&u++}return i}exports.all=C;exports.any=R;exports.applyOperations=X;exports.concat=$;exports.diffOperations=U;exports.distinctByPredicate=G;exports.distinctPrimitive=z;exports.each=T;exports.equals=b;exports.fill=W;exports.filter=k;exports.filterMap=I;exports.filterNulls=P;exports.flatMap=j;exports.flatten=_;exports.foldLeft=S;exports.hasValues=B;exports.head=w;exports.isEmpty=O;exports.joinWithConjunction=Y;exports.makeCompare=D;exports.makeEquals=N;exports.map=q;exports.mapNotNull=E;exports.numbersRange=V;exports.ofIterableIterator=Q;exports.range=d;exports.rank=Z;exports.remove=H;exports.removeByPredicate=J;exports.sort=L;exports.tail=A;
|
package/array.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Maybe } from './maybe';
|
|
2
|
+
import { Compare, Primitive } from './domain';
|
|
3
|
+
|
|
4
|
+
export declare function map<A, B>(arr: A[], f: (a: A, index: number) => B): B[];
|
|
5
|
+
export declare function mapNotNull<A, B>(arr: A[], f: (a: A, index: number) => B | null | undefined): B[];
|
|
6
|
+
export declare function flatMap<A, B>(arr: A[], f: (a: A) => B[]): B[];
|
|
7
|
+
export declare function head<A>(arr: A[]): Maybe<A>;
|
|
8
|
+
export declare function tail<A>(arr: A[]): A[];
|
|
9
|
+
export declare function equals<T>(a: T[], b: T[], equality: (a: T, b: T) => boolean): boolean;
|
|
10
|
+
export declare function makeEquals<T>(equality: (a: T, b: T) => boolean): (a: T[], b: T[]) => boolean;
|
|
11
|
+
export declare function isEmpty<T>(arr: T[]): arr is [];
|
|
12
|
+
export declare function hasValues<T>(arr: T[]): arr is [T, ...T[]];
|
|
13
|
+
export declare function filter<T>(arr: T[], predicate: (v: T) => boolean): T[];
|
|
14
|
+
export declare function filterMap<A, B>(arr: A[], f: (a: A, index: number) => Maybe<B>): B[];
|
|
15
|
+
export declare function filterNulls<T>(arr: Array<T | null | undefined>): T[];
|
|
16
|
+
export declare function flatten<T>(arr: T[][]): T[];
|
|
17
|
+
export declare function foldLeft<T, B>(arr: T[], f: (acc: B, curr: T) => B, b: B): B;
|
|
18
|
+
export declare function all<T>(arr: T[], predicate: (v: T) => boolean): boolean;
|
|
19
|
+
export declare function any<T>(arr: T[], predicate: (v: T) => boolean): boolean;
|
|
20
|
+
export declare function each<T>(arr: T[], f: (v: T) => void): void;
|
|
21
|
+
export declare function concat<A>(...arrs: A[][]): A[];
|
|
22
|
+
export declare function makeCompare<A>(comparef: Compare<A>, shorterFirst?: boolean): (a: A[], b: A[]) => number;
|
|
23
|
+
export declare function sort<A>(compare: Compare<A>, arr: A[]): A[];
|
|
24
|
+
export declare function range<A>(length: number, f: (index: number) => A): A[];
|
|
25
|
+
export declare function numbersRange(length: number, startAt?: number): number[];
|
|
26
|
+
export declare function fill<A>(length: number, value: A): A[];
|
|
27
|
+
export declare function distinctPrimitive<T extends Primitive>(values: T[]): T[];
|
|
28
|
+
export declare function distinctByPredicate<T>(values: T[], predicate: (a: T) => string): T[];
|
|
29
|
+
export declare function remove<A>(arr: A[], item: A): boolean;
|
|
30
|
+
export declare function removeByPredicate<A>(arr: A[], predicate: (a: A) => boolean): boolean;
|
|
31
|
+
export declare function ofIterableIterator<A>(it: IterableIterator<A>): A[];
|
|
32
|
+
export interface DiffOperations<T> {
|
|
33
|
+
removals: Array<{
|
|
34
|
+
at: number;
|
|
35
|
+
qt: number;
|
|
36
|
+
}>;
|
|
37
|
+
swaps: Array<{
|
|
38
|
+
from: number;
|
|
39
|
+
to: number;
|
|
40
|
+
}>;
|
|
41
|
+
inserts: Array<{
|
|
42
|
+
at: number;
|
|
43
|
+
values: T[];
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
export declare function diffOperations<T, K>(from: T[], to: T[], getKey: (v: T) => K): DiffOperations<T>;
|
|
47
|
+
export declare function applyOperations<T>(operations: DiffOperations<T>, start: T[]): T[];
|
|
48
|
+
export declare function joinWithConjunction<A>(arr: A[], conjunction?: string, separator?: string): string;
|
|
49
|
+
export declare function rank<T>(array: T[], compare: (a: T, b: T) => number, incrementDuplicates?: boolean): number[];
|
package/array.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { Maybe as v } from "./maybe.js";
|
|
2
|
+
import { keys as w } from "./object.js";
|
|
3
|
+
function _(n, e) {
|
|
4
|
+
return Array.from({ length: n.length }, (t, r) => e(n[r], r));
|
|
5
|
+
}
|
|
6
|
+
function q(n, e) {
|
|
7
|
+
const t = [];
|
|
8
|
+
for (let r = 0; r < n.length; r++) {
|
|
9
|
+
const u = e(n[r], r);
|
|
10
|
+
u != null && t.push(u);
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
function y(n, e) {
|
|
15
|
+
const t = [];
|
|
16
|
+
for (const r of n)
|
|
17
|
+
t.push(...e(r));
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
function B(n) {
|
|
21
|
+
return n.length > 0 ? v.just(n[0]) : v.nothing;
|
|
22
|
+
}
|
|
23
|
+
function I(n) {
|
|
24
|
+
return n.slice(1);
|
|
25
|
+
}
|
|
26
|
+
function A(n, e, t) {
|
|
27
|
+
if (n.length !== e.length) return !1;
|
|
28
|
+
for (let r = 0; r < n.length; r++)
|
|
29
|
+
if (!t(n[r], e[r])) return !1;
|
|
30
|
+
return !0;
|
|
31
|
+
}
|
|
32
|
+
function N(n) {
|
|
33
|
+
return function(e, t) {
|
|
34
|
+
return A(e, t, n);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function O(n) {
|
|
38
|
+
return n.length === 0;
|
|
39
|
+
}
|
|
40
|
+
function j(n) {
|
|
41
|
+
return n.length > 0;
|
|
42
|
+
}
|
|
43
|
+
function E(n, e) {
|
|
44
|
+
const t = [];
|
|
45
|
+
for (const r of n) e(r) && t.push(r);
|
|
46
|
+
return t;
|
|
47
|
+
}
|
|
48
|
+
function P(n, e) {
|
|
49
|
+
const t = [];
|
|
50
|
+
for (let r = 0; r < n.length; r++) {
|
|
51
|
+
const u = e(n[r], r);
|
|
52
|
+
u != null && t.push(u);
|
|
53
|
+
}
|
|
54
|
+
return t;
|
|
55
|
+
}
|
|
56
|
+
function S(n) {
|
|
57
|
+
return E(n, (e) => e != null);
|
|
58
|
+
}
|
|
59
|
+
function $(n) {
|
|
60
|
+
return [].concat(...n);
|
|
61
|
+
}
|
|
62
|
+
function C(n, e, t) {
|
|
63
|
+
for (const r of n)
|
|
64
|
+
t = e(t, r);
|
|
65
|
+
return t;
|
|
66
|
+
}
|
|
67
|
+
function D(n, e) {
|
|
68
|
+
for (const t of n)
|
|
69
|
+
if (!e(t))
|
|
70
|
+
return !1;
|
|
71
|
+
return !0;
|
|
72
|
+
}
|
|
73
|
+
function R(n, e) {
|
|
74
|
+
for (const t of n)
|
|
75
|
+
if (e(t))
|
|
76
|
+
return !0;
|
|
77
|
+
return !1;
|
|
78
|
+
}
|
|
79
|
+
function T(n, e) {
|
|
80
|
+
for (const t of n) e(t);
|
|
81
|
+
}
|
|
82
|
+
function L(...n) {
|
|
83
|
+
return [].concat(...n);
|
|
84
|
+
}
|
|
85
|
+
function V(n, e = !0) {
|
|
86
|
+
return function(t, r) {
|
|
87
|
+
if (t.length < r.length)
|
|
88
|
+
return -1 * (e ? 1 : -1);
|
|
89
|
+
if (t.length > r.length)
|
|
90
|
+
return 1 * (e ? 1 : -1);
|
|
91
|
+
for (let u = 0; u < t.length; u++) {
|
|
92
|
+
const s = n(t[u], r[u]);
|
|
93
|
+
if (s !== 0) return s;
|
|
94
|
+
}
|
|
95
|
+
return 0;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function W(n, e) {
|
|
99
|
+
return e.slice().sort(n);
|
|
100
|
+
}
|
|
101
|
+
function x(n, e) {
|
|
102
|
+
return Array.from({ length: n }, (t, r) => e(r));
|
|
103
|
+
}
|
|
104
|
+
function z(n, e = 0) {
|
|
105
|
+
return x(n, (t) => e + t);
|
|
106
|
+
}
|
|
107
|
+
function G(n, e) {
|
|
108
|
+
return x(n, () => e);
|
|
109
|
+
}
|
|
110
|
+
function H(n) {
|
|
111
|
+
return Array.from(new Set(n));
|
|
112
|
+
}
|
|
113
|
+
function J(n, e) {
|
|
114
|
+
const t = {};
|
|
115
|
+
return n.forEach((r) => {
|
|
116
|
+
t[e(r)] = r;
|
|
117
|
+
}), w(t).map((r) => t[r]);
|
|
118
|
+
}
|
|
119
|
+
function Q(n, e) {
|
|
120
|
+
const t = n.indexOf(e);
|
|
121
|
+
return t < 0 ? !1 : (n.splice(t, 1), !0);
|
|
122
|
+
}
|
|
123
|
+
function U(n, e) {
|
|
124
|
+
const t = n.findIndex(e);
|
|
125
|
+
return t < 0 ? !1 : (n.splice(t, 1), !0);
|
|
126
|
+
}
|
|
127
|
+
function X(n) {
|
|
128
|
+
const e = [];
|
|
129
|
+
for (let t = n.next(); !(t.done ?? !1); t = n.next())
|
|
130
|
+
e.push(t.value);
|
|
131
|
+
return e;
|
|
132
|
+
}
|
|
133
|
+
function Y(n, e, t) {
|
|
134
|
+
const r = {
|
|
135
|
+
removals: [],
|
|
136
|
+
swaps: [],
|
|
137
|
+
inserts: []
|
|
138
|
+
}, { removals: u, inserts: s, swaps: a } = r, i = /* @__PURE__ */ new Map();
|
|
139
|
+
e.forEach((o, f) => i.set(t(o), f));
|
|
140
|
+
const l = n.map((o, f) => [o, f]).filter(([o]) => !i.has(t(o))).map(([o, f]) => f);
|
|
141
|
+
for (let o = l.length - 1; o >= 0; o--) {
|
|
142
|
+
const f = l[o], c = u.length > 0 ? u[u.length - 1] : void 0;
|
|
143
|
+
c != null && c.at === f + 1 ? (c.at--, c.qt++) : u.push({ at: f, qt: 1 });
|
|
144
|
+
}
|
|
145
|
+
const h = /* @__PURE__ */ new Map();
|
|
146
|
+
n.forEach((o, f) => h.set(t(o), f));
|
|
147
|
+
const g = e.map((o, f) => [o, f]).filter(([o]) => !h.has(t(o))).map(([o, f]) => f);
|
|
148
|
+
for (const o of g) {
|
|
149
|
+
const f = s.length > 0 ? s[s.length - 1] : void 0;
|
|
150
|
+
f != null && f.at + f.values.length === o ? f.values.push(e[o]) : s.push({ at: o, values: [e[o]] });
|
|
151
|
+
}
|
|
152
|
+
const p = n.filter((o, f) => !l.includes(f)), m = /* @__PURE__ */ new Map();
|
|
153
|
+
for (let o = 0; o < p.length; o++)
|
|
154
|
+
m.set(t(p[o]), o);
|
|
155
|
+
const d = e.filter((o, f) => !g.includes(f));
|
|
156
|
+
for (let o = 0; o < d.length; o++) {
|
|
157
|
+
const f = t(d[o]), c = m.get(f);
|
|
158
|
+
if (c == null || o === c) continue;
|
|
159
|
+
const k = t(p[o]);
|
|
160
|
+
m.delete(k), a.push({ from: o, to: c });
|
|
161
|
+
}
|
|
162
|
+
return r;
|
|
163
|
+
}
|
|
164
|
+
function Z(n, e) {
|
|
165
|
+
const t = [...e];
|
|
166
|
+
for (const { at: r, qt: u } of n.removals)
|
|
167
|
+
t.splice(r, u);
|
|
168
|
+
for (const { from: r, to: u } of n.swaps) {
|
|
169
|
+
const s = t[u];
|
|
170
|
+
t[u] = t[r], t[r] = s;
|
|
171
|
+
}
|
|
172
|
+
for (const r of n.inserts)
|
|
173
|
+
t.splice(r.at, 0, ...r.values);
|
|
174
|
+
return t;
|
|
175
|
+
}
|
|
176
|
+
function F(n, e = " and ", t = ", ") {
|
|
177
|
+
return n.length === 0 ? "" : n.length === 1 ? String(n[0]) : `${n.slice(0, -1).join(t)}${e}${String(n[n.length - 1])}`;
|
|
178
|
+
}
|
|
179
|
+
function K(n, e, t = !0) {
|
|
180
|
+
const r = n.map((i, l) => [i, l]);
|
|
181
|
+
r.sort((i, l) => e(i[0], l[0]));
|
|
182
|
+
const u = new Array(r.length);
|
|
183
|
+
let s = 0, a = r[0][0];
|
|
184
|
+
for (let i = 0; i < r.length; i++) {
|
|
185
|
+
const [l, h] = r[i];
|
|
186
|
+
e(l, a) !== 0 && (s = i, a = l), u[h] = s, t && s++;
|
|
187
|
+
}
|
|
188
|
+
return u;
|
|
189
|
+
}
|
|
190
|
+
export {
|
|
191
|
+
D as all,
|
|
192
|
+
R as any,
|
|
193
|
+
Z as applyOperations,
|
|
194
|
+
L as concat,
|
|
195
|
+
Y as diffOperations,
|
|
196
|
+
J as distinctByPredicate,
|
|
197
|
+
H as distinctPrimitive,
|
|
198
|
+
T as each,
|
|
199
|
+
A as equals,
|
|
200
|
+
G as fill,
|
|
201
|
+
E as filter,
|
|
202
|
+
P as filterMap,
|
|
203
|
+
S as filterNulls,
|
|
204
|
+
y as flatMap,
|
|
205
|
+
$ as flatten,
|
|
206
|
+
C as foldLeft,
|
|
207
|
+
j as hasValues,
|
|
208
|
+
B as head,
|
|
209
|
+
O as isEmpty,
|
|
210
|
+
F as joinWithConjunction,
|
|
211
|
+
V as makeCompare,
|
|
212
|
+
N as makeEquals,
|
|
213
|
+
_ as map,
|
|
214
|
+
q as mapNotNull,
|
|
215
|
+
z as numbersRange,
|
|
216
|
+
X as ofIterableIterator,
|
|
217
|
+
x as range,
|
|
218
|
+
K as rank,
|
|
219
|
+
Q as remove,
|
|
220
|
+
U as removeByPredicate,
|
|
221
|
+
W as sort,
|
|
222
|
+
I as tail
|
|
223
|
+
};
|
package/bigint.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(n,e){return e<0n&&(n=-n,e=-e),n<=0n?n/e:(n-1n)/e+1n}function f(n,e){return e<0n&&(n=-n,e=-e),n>=0n?n/e:(n+1n)/e-1n}function c(n,e){return n<e?-1:n>e?1:0}function i(n){return n<0n?-n:n}function s(n,e){return n<e?n:e}function l(n,e){return n>e?n:e}function m(n,e){if(e<0n)throw new Error("negative exponent");let r=1n;for(;e>0n;)(e&1n)!==0n&&(r*=n),e>>=1n,n*=n;return r}function u(n,e){for(n=i(n),e=i(e);e>0n;){const r=e;e=n%e,n=r}return n}function v(n,e){return i(n*e)/u(n,e)}function t(n){if(n<2n)return!1;if(n===2n||n===3n)return!0;if(n%2n===0n||n%3n===0n)return!1;let e=5n;for(;e*e<=n;){if(n%e===0n||n%(e+2n)===0n)return!1;e+=6n}return!0}function a(n){if(n<2n)return 2n;if(n===2n)return 3n;for(n%2n===0n?n++:n+=2n;!t(n);)n+=2n;return n}function w(n){if(n<=2n)throw new Error("no previous prime");if(n===3n)return 2n;for(n%2n===0n?n--:n-=2n;!t(n);)n-=2n;return n}function p(n){return n%2n===0n}function P(n){return n%2n!==0n}function d(n){return n===0n}function g(n){return n===1n}function h(n){return n<0n}function O(n){return n>0n}exports.abs=i;exports.ceilDiv=o;exports.compare=c;exports.floorDiv=f;exports.gcd=u;exports.isEven=p;exports.isNegative=h;exports.isOdd=P;exports.isOne=g;exports.isPositive=O;exports.isPrime=t;exports.isZero=d;exports.lcm=v;exports.max=l;exports.min=s;exports.nextPrime=a;exports.pow=m;exports.prevPrime=w;
|
package/bigint.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function ceilDiv(x: bigint, y: bigint): bigint;
|
|
2
|
+
export declare function floorDiv(x: bigint, y: bigint): bigint;
|
|
3
|
+
export declare function compare(x: bigint, y: bigint): number;
|
|
4
|
+
export declare function abs(x: bigint): bigint;
|
|
5
|
+
export declare function min(x: bigint, y: bigint): bigint;
|
|
6
|
+
export declare function max(x: bigint, y: bigint): bigint;
|
|
7
|
+
export declare function pow(x: bigint, y: bigint): bigint;
|
|
8
|
+
export declare function gcd(x: bigint, y: bigint): bigint;
|
|
9
|
+
export declare function lcm(x: bigint, y: bigint): bigint;
|
|
10
|
+
export declare function isPrime(x: bigint): boolean;
|
|
11
|
+
export declare function nextPrime(x: bigint): bigint;
|
|
12
|
+
export declare function prevPrime(x: bigint): bigint;
|
|
13
|
+
export declare function isEven(x: bigint): boolean;
|
|
14
|
+
export declare function isOdd(x: bigint): boolean;
|
|
15
|
+
export declare function isZero(x: bigint): boolean;
|
|
16
|
+
export declare function isOne(x: bigint): boolean;
|
|
17
|
+
export declare function isNegative(x: bigint): boolean;
|
|
18
|
+
export declare function isPositive(x: bigint): boolean;
|
package/bigint.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
function f(n, r) {
|
|
2
|
+
return r < 0n && (n = -n, r = -r), n <= 0n ? n / r : (n - 1n) / r + 1n;
|
|
3
|
+
}
|
|
4
|
+
function o(n, r) {
|
|
5
|
+
return r < 0n && (n = -n, r = -r), n >= 0n ? n / r : (n + 1n) / r - 1n;
|
|
6
|
+
}
|
|
7
|
+
function c(n, r) {
|
|
8
|
+
return n < r ? -1 : n > r ? 1 : 0;
|
|
9
|
+
}
|
|
10
|
+
function i(n) {
|
|
11
|
+
return n < 0n ? -n : n;
|
|
12
|
+
}
|
|
13
|
+
function s(n, r) {
|
|
14
|
+
return n < r ? n : r;
|
|
15
|
+
}
|
|
16
|
+
function l(n, r) {
|
|
17
|
+
return n > r ? n : r;
|
|
18
|
+
}
|
|
19
|
+
function w(n, r) {
|
|
20
|
+
if (r < 0n) throw new Error("negative exponent");
|
|
21
|
+
let e = 1n;
|
|
22
|
+
for (; r > 0n; )
|
|
23
|
+
(r & 1n) !== 0n && (e *= n), r >>= 1n, n *= n;
|
|
24
|
+
return e;
|
|
25
|
+
}
|
|
26
|
+
function u(n, r) {
|
|
27
|
+
for (n = i(n), r = i(r); r > 0n; ) {
|
|
28
|
+
const e = r;
|
|
29
|
+
r = n % r, n = e;
|
|
30
|
+
}
|
|
31
|
+
return n;
|
|
32
|
+
}
|
|
33
|
+
function a(n, r) {
|
|
34
|
+
return i(n * r) / u(n, r);
|
|
35
|
+
}
|
|
36
|
+
function t(n) {
|
|
37
|
+
if (n < 2n) return !1;
|
|
38
|
+
if (n === 2n || n === 3n) return !0;
|
|
39
|
+
if (n % 2n === 0n || n % 3n === 0n) return !1;
|
|
40
|
+
let r = 5n;
|
|
41
|
+
for (; r * r <= n; ) {
|
|
42
|
+
if (n % r === 0n || n % (r + 2n) === 0n) return !1;
|
|
43
|
+
r += 6n;
|
|
44
|
+
}
|
|
45
|
+
return !0;
|
|
46
|
+
}
|
|
47
|
+
function m(n) {
|
|
48
|
+
if (n < 2n) return 2n;
|
|
49
|
+
if (n === 2n) return 3n;
|
|
50
|
+
for (n % 2n === 0n ? n++ : n += 2n; !t(n); ) n += 2n;
|
|
51
|
+
return n;
|
|
52
|
+
}
|
|
53
|
+
function v(n) {
|
|
54
|
+
if (n <= 2n) throw new Error("no previous prime");
|
|
55
|
+
if (n === 3n) return 2n;
|
|
56
|
+
for (n % 2n === 0n ? n-- : n -= 2n; !t(n); ) n -= 2n;
|
|
57
|
+
return n;
|
|
58
|
+
}
|
|
59
|
+
function h(n) {
|
|
60
|
+
return n % 2n === 0n;
|
|
61
|
+
}
|
|
62
|
+
function p(n) {
|
|
63
|
+
return n % 2n !== 0n;
|
|
64
|
+
}
|
|
65
|
+
function P(n) {
|
|
66
|
+
return n === 0n;
|
|
67
|
+
}
|
|
68
|
+
function d(n) {
|
|
69
|
+
return n === 1n;
|
|
70
|
+
}
|
|
71
|
+
function g(n) {
|
|
72
|
+
return n < 0n;
|
|
73
|
+
}
|
|
74
|
+
function E(n) {
|
|
75
|
+
return n > 0n;
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
i as abs,
|
|
79
|
+
f as ceilDiv,
|
|
80
|
+
c as compare,
|
|
81
|
+
o as floorDiv,
|
|
82
|
+
u as gcd,
|
|
83
|
+
h as isEven,
|
|
84
|
+
g as isNegative,
|
|
85
|
+
p as isOdd,
|
|
86
|
+
d as isOne,
|
|
87
|
+
E as isPositive,
|
|
88
|
+
t as isPrime,
|
|
89
|
+
P as isZero,
|
|
90
|
+
a as lcm,
|
|
91
|
+
l as max,
|
|
92
|
+
s as min,
|
|
93
|
+
m as nextPrime,
|
|
94
|
+
w as pow,
|
|
95
|
+
v as prevPrime
|
|
96
|
+
};
|
package/boolean.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(e,r){return e===r?0:e?-1:1}function a(e){return e?1:0}function n(e){if(e==null)return!1;switch(e.toLowerCase()){case"true":case"false":case"0":case"1":case"on":case"off":return!0;default:return!1}}function s(e){switch(e.toLowerCase()){case"true":case"1":case"on":return!0;case"false":case"0":case"off":return!1;default:throw new Error(`unable to parse '${e}'`)}}function o(e,r){return e!==r}exports.canParse=n;exports.compare=t;exports.parse=s;exports.toInt=a;exports.xor=o;
|
package/boolean.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions to manipulate `boolean` values.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Returns a comparison value (`Int`) from two boolean values.
|
|
6
|
+
*/
|
|
7
|
+
export declare function compare(a: boolean, b: boolean): number;
|
|
8
|
+
/**
|
|
9
|
+
* Converts a boolean to an integer value (`true` => `1`, `false` => `0`).
|
|
10
|
+
*/
|
|
11
|
+
export declare function toInt(v: boolean): number;
|
|
12
|
+
/**
|
|
13
|
+
* Returns `true` if the passed value is either `true` or `false` (case insensitive).
|
|
14
|
+
*/
|
|
15
|
+
export declare function canParse(v: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Returns `true`/`false` if the passed value is `true`/`false` (case insensitive) with any other value it will return null.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parse(v: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Returns `true` when arguments are different.
|
|
22
|
+
*/
|
|
23
|
+
export declare function xor(a: boolean, b: boolean): boolean;
|
package/boolean.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function t(e, r) {
|
|
2
|
+
return e === r ? 0 : e ? -1 : 1;
|
|
3
|
+
}
|
|
4
|
+
function a(e) {
|
|
5
|
+
return e ? 1 : 0;
|
|
6
|
+
}
|
|
7
|
+
function n(e) {
|
|
8
|
+
if (e == null) return !1;
|
|
9
|
+
switch (e.toLowerCase()) {
|
|
10
|
+
case "true":
|
|
11
|
+
case "false":
|
|
12
|
+
case "0":
|
|
13
|
+
case "1":
|
|
14
|
+
case "on":
|
|
15
|
+
case "off":
|
|
16
|
+
return !0;
|
|
17
|
+
default:
|
|
18
|
+
return !1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function s(e) {
|
|
22
|
+
switch (e.toLowerCase()) {
|
|
23
|
+
case "true":
|
|
24
|
+
case "1":
|
|
25
|
+
case "on":
|
|
26
|
+
return !0;
|
|
27
|
+
case "false":
|
|
28
|
+
case "0":
|
|
29
|
+
case "off":
|
|
30
|
+
return !1;
|
|
31
|
+
default:
|
|
32
|
+
throw new Error(`unable to parse '${e}'`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function c(e, r) {
|
|
36
|
+
return e !== r;
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
n as canParse,
|
|
40
|
+
t as compare,
|
|
41
|
+
s as parse,
|
|
42
|
+
a as toInt,
|
|
43
|
+
c as xor
|
|
44
|
+
};
|
package/domain.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/domain.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type IndexKey = keyof any;
|
|
2
|
+
export type Primitive = string | boolean | number | null | undefined;
|
|
3
|
+
export type Nothing = undefined | null;
|
|
4
|
+
export type Compare<T> = (a: T, b: T) => number;
|
|
5
|
+
export type Id<T> = {} & {
|
|
6
|
+
[P in keyof T]: T[P];
|
|
7
|
+
};
|
|
8
|
+
export type Merge<A, B> = Id<A & B>;
|
|
9
|
+
export type Sample = Merge<{
|
|
10
|
+
a: number;
|
|
11
|
+
}, {
|
|
12
|
+
b: string;
|
|
13
|
+
}>;
|
|
14
|
+
export type TupleToUnion<T extends unknown[]> = T[number];
|
|
15
|
+
export type Fun0<R> = () => R;
|
|
16
|
+
export type Fun1<A, R> = (a: A) => R;
|
|
17
|
+
export type Fun2<A, B, R> = (a: A, b: B) => R;
|
|
18
|
+
export type Fun3<A, B, C, R> = (a: A, b: B, c: C) => R;
|
|
19
|
+
export type Fun4<A, B, C, D, R> = (a: A, b: B, c: C, d: D) => R;
|
|
20
|
+
export type Fun5<A, B, C, D, E, R> = (a: A, b: B, c: C, d: D, e: E) => R;
|
|
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
|
+
export type FirstArgument<F> = F extends Fun1<infer A, unknown> ? A : never;
|
package/domain.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/equal.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(e,t){return e===t||e!==e&&t!==t}function f(e,t){if(g(e,t))return!0;if(e==null||t==null)return!1;const u=Array.isArray(e),h=Array.isArray(t);if(u!==h)return!1;if(u){const n=e,r=t,a=n.length;if(a!==r.length)return!1;for(let s=0;s<a;s++)if(!f(n[s],r[s]))return!1;return!0}const l=e instanceof Date,j=t instanceof Date;if(l!==j)return!1;if(l){const n=e,r=t;return+n==+r}const p=e instanceof Set,I=t instanceof Set;if(p!==I)return!1;if(p){const n=e,r=t;if(n.size!==r.size)return!1;const a=n.keys();for(;;){const s=a.next();if(s.done??!1)break;if(!r.has(s.value))return!1}return!0}const y=e instanceof Map,O=t instanceof Map;if(y!==O)return!1;if(y){const n=e,r=t;if(n.size!==r.size)return!1;const s=n.keys();for(;;){const o=s.next();if(o.done??!1)break;if(!f(n.get(o.value),r.get(o.value)))return!1}return!0}const b=typeof e=="object";if(b!==(typeof t=="object"))return!1;if(b){const n=e,r=t,a=Object.keys(n),s=Object.keys(r),o=a.length;if(o!==s.length)return!1;for(let i=0;i<o;i++){const c=a[i];if(!Object.prototype.hasOwnProperty.call(r,c)||!f(n[c],r[c]))return!1}return!0}return!1}function d(e,t){return e==t}exports.deepEqual=f;exports.looseEqual=d;exports.strictEqual=g;
|
package/equal.d.ts
ADDED
package/equal.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function O(e, t) {
|
|
2
|
+
return e === t || e !== e && t !== t;
|
|
3
|
+
}
|
|
4
|
+
function i(e, t) {
|
|
5
|
+
if (O(e, t)) return !0;
|
|
6
|
+
if (e == null || t == null) return !1;
|
|
7
|
+
const u = Array.isArray(e), b = Array.isArray(t);
|
|
8
|
+
if (u !== b) return !1;
|
|
9
|
+
if (u) {
|
|
10
|
+
const n = e, r = t, a = n.length;
|
|
11
|
+
if (a !== r.length) return !1;
|
|
12
|
+
for (let s = 0; s < a; s++)
|
|
13
|
+
if (!i(n[s], r[s])) return !1;
|
|
14
|
+
return !0;
|
|
15
|
+
}
|
|
16
|
+
const l = e instanceof Date, I = t instanceof Date;
|
|
17
|
+
if (l !== I) return !1;
|
|
18
|
+
if (l) {
|
|
19
|
+
const n = e, r = t;
|
|
20
|
+
return +n == +r;
|
|
21
|
+
}
|
|
22
|
+
const p = e instanceof Set, g = t instanceof Set;
|
|
23
|
+
if (p !== g) return !1;
|
|
24
|
+
if (p) {
|
|
25
|
+
const n = e, r = t;
|
|
26
|
+
if (n.size !== r.size) return !1;
|
|
27
|
+
const a = n.keys();
|
|
28
|
+
for (; ; ) {
|
|
29
|
+
const s = a.next();
|
|
30
|
+
if (s.done ?? !1) break;
|
|
31
|
+
if (!r.has(s.value)) return !1;
|
|
32
|
+
}
|
|
33
|
+
return !0;
|
|
34
|
+
}
|
|
35
|
+
const h = e instanceof Map, j = t instanceof Map;
|
|
36
|
+
if (h !== j) return !1;
|
|
37
|
+
if (h) {
|
|
38
|
+
const n = e, r = t;
|
|
39
|
+
if (n.size !== r.size) return !1;
|
|
40
|
+
const s = n.keys();
|
|
41
|
+
for (; ; ) {
|
|
42
|
+
const f = s.next();
|
|
43
|
+
if (f.done ?? !1) break;
|
|
44
|
+
if (!i(n.get(f.value), r.get(f.value))) return !1;
|
|
45
|
+
}
|
|
46
|
+
return !0;
|
|
47
|
+
}
|
|
48
|
+
const y = typeof e == "object";
|
|
49
|
+
if (y !== (typeof t == "object")) return !1;
|
|
50
|
+
if (y) {
|
|
51
|
+
const n = e, r = t, a = Object.keys(n), s = Object.keys(r), f = a.length;
|
|
52
|
+
if (f !== s.length) return !1;
|
|
53
|
+
for (let o = 0; o < f; o++) {
|
|
54
|
+
const c = a[o];
|
|
55
|
+
if (!Object.prototype.hasOwnProperty.call(r, c) || !i(n[c], r[c])) return !1;
|
|
56
|
+
}
|
|
57
|
+
return !0;
|
|
58
|
+
}
|
|
59
|
+
return !1;
|
|
60
|
+
}
|
|
61
|
+
function M(e, t) {
|
|
62
|
+
return e == t;
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
i as deepEqual,
|
|
66
|
+
M as looseEqual,
|
|
67
|
+
O as strictEqual
|
|
68
|
+
};
|
package/function.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(...r){return t=>r.reduce((e,n)=>n(e),t)}function i(r){return r}function c(r){return t=>(...e)=>r(t,...e)}function o(r){return(...t)=>e=>r(...t.concat([e]))}function f(r){return(...t)=>r(...t.reverse())}function y(r){return r}exports.compose=u;exports.curryLeft=c;exports.curryRight=o;exports.flip=f;exports.id=y;exports.identity=i;
|
package/function.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare function compose<A>(): (a: A) => A;
|
|
2
|
+
export declare function compose<A, B>(f1: (a: A) => B): (a: A) => B;
|
|
3
|
+
export declare function compose<A, B, C>(f1: (a: A) => B, f2: (b: B) => C): (a: A) => C;
|
|
4
|
+
export declare function compose<A, B, C, D>(f1: (a: A) => B, f2: (b: B) => C, f3: (c: C) => D): (a: A) => D;
|
|
5
|
+
export declare function compose<A, B, C, D, E>(f1: (a: A) => B, f2: (b: B) => C, f3: (c: C) => D, f4: (d: D) => E): (a: A) => E;
|
|
6
|
+
export declare function compose<A, B, C, D, E, F>(f1: (a: A) => B, f2: (b: B) => C, f3: (c: C) => D, f4: (d: D) => E, f5: (e: E) => F): (a: A) => F;
|
|
7
|
+
export declare function compose<A, B, C, D, E, F, G>(f1: (a: A) => B, f2: (b: B) => C, f3: (c: C) => D, f4: (d: D) => E, f5: (e: E) => F, f6: (f: F) => G): (a: A) => G;
|
|
8
|
+
export declare function identity<T>(v: T): T;
|
|
9
|
+
export declare function curryLeft<A, Rest extends any[], Ret>(f: (a: A, ...rest: Rest) => Ret): (a: A) => (...rest: Rest) => Ret;
|
|
10
|
+
export declare function curryRight<A, B, C, D>(f: (a: A, b: B, c: C) => D): (a: A, b: B) => (c: C) => D;
|
|
11
|
+
export declare function curryRight<A, B, C, D, E>(f: (a: A, b: B, c: C, d: D) => E): (a: A, b: B, c: C) => (d: D) => E;
|
|
12
|
+
export declare function curryRight<A, B, C, D, E, F>(f: (a: A, b: B, c: C, d: D, e: E) => F): (a: A, b: B, c: C, d: D) => (e: E) => F;
|
|
13
|
+
export declare function curryRight<A, B, C, D, E, F, G>(f: (a: A, b: B, c: C, d: D, e: E, f: F) => G): (a: A, b: B, c: C, d: D, e: E) => (f: F) => G;
|
|
14
|
+
export declare function flip<A, B, C>(f: (a: A, b: B) => C): (b: B, a: A) => C;
|
|
15
|
+
export declare function flip<A, B, C, D>(f: (a: A, b: B, c: C) => D): (c: C, b: B, a: A) => D;
|
|
16
|
+
export declare function flip<A, B, C, D, E>(f: (a: A, b: B, c: C, d: D) => E): (d: D, c: C, b: B, a: A) => E;
|
|
17
|
+
export declare function flip<A, B, C, D, E>(f: (a: A, b: B, c: C, d: D) => E): (d: D, c: C, b: B, a: A) => E;
|
|
18
|
+
export declare function flip<A, B, C, D, E, F>(f: (a: A, b: B, c: C, d: D, e: E) => F): (e: E, d: D, c: C, b: B, a: A) => F;
|
|
19
|
+
export declare function flip<A, B, C, D, E, F, G>(f: (a: A, b: B, c: C, d: D, e: E, f: F) => G): (f: F, e: E, d: D, c: C, b: B, a: A) => G;
|
|
20
|
+
export declare function id<T>(v: T): T;
|
package/function.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function u(...n) {
|
|
2
|
+
return (r) => n.reduce((t, e) => e(t), r);
|
|
3
|
+
}
|
|
4
|
+
function c(n) {
|
|
5
|
+
return n;
|
|
6
|
+
}
|
|
7
|
+
function i(n) {
|
|
8
|
+
return (r) => (...t) => n(r, ...t);
|
|
9
|
+
}
|
|
10
|
+
function o(n) {
|
|
11
|
+
return (...r) => (
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
(t) => n(...r.concat([t]))
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function f(n) {
|
|
17
|
+
return (...r) => n(...r.reverse());
|
|
18
|
+
}
|
|
19
|
+
function d(n) {
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
u as compose,
|
|
24
|
+
i as curryLeft,
|
|
25
|
+
o as curryRight,
|
|
26
|
+
f as flip,
|
|
27
|
+
d as id,
|
|
28
|
+
c as identity
|
|
29
|
+
};
|
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
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Maybe<T> = Just<T> | Nothing;
|
|
2
|
+
export type Nothing = undefined | null;
|
|
3
|
+
export type Just<T> = NonNullable<T>;
|
|
4
|
+
export declare const Maybe: {
|
|
5
|
+
nothing: Maybe<never>;
|
|
6
|
+
just: <T>(value: T) => Maybe<T>;
|
|
7
|
+
isNothing: <T>(maybe: Maybe<T>) => maybe is Nothing;
|
|
8
|
+
isJust: <T>(maybe: Maybe<T>) => maybe is Just<T>;
|
|
9
|
+
};
|