@tempots/std 0.14.0 → 0.16.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/array.cjs +1 -1
- package/array.d.ts +1 -2
- package/array.js +1 -1
- package/async-result.cjs +1 -1
- package/async-result.d.ts +29 -1
- package/async-result.js +53 -5
- package/domain.d.ts +16 -0
- package/index.cjs +1 -1
- package/index.js +158 -151
- package/json.cjs +1 -1
- package/json.d.ts +24 -1
- package/json.js +6 -1
- package/object.cjs +1 -1
- package/object.d.ts +24 -1
- package/object.js +14 -11
- package/package.json +1 -1
- package/{result-Czm7RKNP.js → result-CGd0jCdl.js} +54 -19
- package/result-CdwVhaAc.cjs +1 -0
- package/result.cjs +1 -1
- package/result.d.ts +23 -1
- package/result.js +1 -1
- package/validation.cjs +1 -1
- package/validation.d.ts +0 -1
- package/validation.js +1 -1
- package/result-DzdZiQoR.cjs +0 -1
package/array.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./object.cjs"),x=(r,t)=>Array.from({length:r.length},(e,n)=>t(r[n],n)),F=(r,t)=>{const e=[];for(const n of r)e.push(...t(n));return e},w=r=>r.length>0?r[0]:void 0,B=r=>r.slice(1),P=(r,t,e)=>{if(r.length!==t.length)return!1;for(let n=0;n<r.length;n++)if(!e(r[n],t[n]))return!1;return!0},b=r=>r.length===0,j=r=>r.length>0,g=(r,t)=>{const e=[];for(const n of r)t(n)&&e.push(n);return e},M=(r,t)=>{const e=[];for(let n=0;n<r.length;n++){const s=t(r[n],n);s!=null&&e.push(s)}return e},I=r=>g(r,t=>t!=null),S=r=>[].concat(...r),k=(r,t,e)=>{for(const n of r)e=t(e,n);return e},D=(r,t)=>{for(const e of r)if(!t(e))return!1;return!0},_=(r,t)=>{for(const e of r)if(t(e))return!0;return!1},T=(r,t)=>{for(const e of r)t(e)},H=(...r)=>[].concat(...r),N=(r,t,e,n=!0)=>{if(r.length<t.length)return-1*(n?1:-1);if(r.length>t.length)return 1*(n?1:-1);for(let s=0;s<r.length;s++){const l=e(r[s],t[s]);if(l!==0)return l}return 0},$=(r,t)=>r.slice().sort(t),p=(r,t)=>Array.from({length:r},(e,n)=>t(n)),C=(r,t=0)=>p(r,e=>t+e),L=(r,t)=>p(r,()=>t),V=r=>Array.from(new Set(r)),W=(r,t)=>{const e={};return r.forEach(n=>{e[t(n)]=n}),q.objectKeys(e).map(n=>e[n])},v=(r,t)=>{const e=r.indexOf(t);return e<0?!1:(r.splice(e,1),!0)},R=(r,t)=>{let e=!1;for(;v(r,t);)e=!0;return e},E=(r,t)=>{const e=r.findIndex(t);return e<0?!1:(r.splice(e,1),!0)},z=(r,t)=>{let e=!1;for(;E(r,t);)e=!0;return e},G=r=>{const t=[];for(let e=r.next();!(e.done??!1);e=r.next())t.push(e.value);return t},J=(r,t,e)=>{const n={removals:[],swaps:[],inserts:[]},{removals:s,inserts:l,swaps:u}=n,c=new Map;t.forEach((a,o)=>c.set(e(a),o));const f=r.map((a,o)=>[a,o]).filter(([a])=>!c.has(e(a))).map(([a,o])=>o);for(let a=f.length-1;a>=0;a--){const o=f[a],i=s.length>0?s[s.length-1]:void 0;i!=null&&i.at===o+1?(i.at--,i.qt++):s.push({at:o,qt:1})}const y=new Map;r.forEach((a,o)=>y.set(e(a),o));const h=t.map((a,o)=>[a,o]).filter(([a])=>!y.has(e(a))).map(([a,o])=>o);for(const a of h){const o=l.length>0?l[l.length-1]:void 0;o!=null&&o.at+o.values.length===a?o.values.push(t[a]):l.push({at:a,values:[t[a]]})}const A=r.filter((a,o)=>!f.includes(o)),m=new Map;for(let a=0;a<A.length;a++)m.set(e(A[a]),a);const d=t.filter((a,o)=>!h.includes(o));for(let a=0;a<d.length;a++){const o=e(d[a]),i=m.get(o);if(i==null||a===i)continue;const O=e(A[a]);m.delete(O),u.push({from:a,to:i})}return n},Q=(r,t)=>{const e=[...t];for(const{at:n,qt:s}of r.removals)e.splice(n,s);for(const{from:n,to:s}of r.swaps){const l=e[s];e[s]=e[n],e[n]=l}for(const n of r.inserts)e.splice(n.at,0,...n.values);return e},U=(r,t=" and ",e=", ")=>r.length===0?"":r.length===1?String(r[0]):`${r.slice(0,-1).join(e)}${t}${String(r[r.length-1])}`,X=(r,t,e=!0)=>{const n=r.map((c,f)=>[c,f]);n.sort((c,f)=>t(c[0],f[0]));const s=new Array(n.length);let l=0,u=n[0][0];for(let c=0;c<n.length;c++){const[f,y]=n[c];t(f,u)!==0&&(l=c,u=f),s[y]=l,e&&l++}return s};exports.allElements=D;exports.anyElement=_;exports.applyArrayDiffOperations=Q;exports.areArraysEqual=P;exports.arrayDiffOperations=J;exports.arrayHasValues=j;exports.arrayHead=w;exports.arrayOfIterableIterator=G;exports.arrayTail=B;exports.compareArrays=N;exports.concatArrays=H;exports.createFilledArray=L;exports.filterArray=g;exports.filterMapArray=M;exports.filterNullsFromArray=I;exports.flatMapArray=F;exports.flattenArray=S;exports.foldLeftArray=k;exports.forEachElement=T;exports.generateArray=p;exports.generateSequenceArray=C;exports.isArrayEmpty=b;exports.joinArrayWithConjunction=U;exports.mapArray=x;exports.rankArray=X;exports.removeAllFromArray=R;exports.removeAllFromArrayByPredicate=z;exports.removeOneFromArray=v;exports.removeOneFromArrayByPredicate=E;exports.sortArray=$;exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./object.cjs"),x=(r,t)=>Array.from({length:r.length},(e,n)=>t(r[n],n)),F=(r,t)=>{const e=[];for(const n of r)e.push(...t(n));return e},w=r=>r.length>0?r[0]:void 0,B=r=>r.slice(1),P=(r,t,e)=>{if(r.length!==t.length)return!1;for(let n=0;n<r.length;n++)if(!e(r[n],t[n]))return!1;return!0},b=r=>r.length===0,j=r=>r.length>0,g=(r,t)=>{const e=[];for(const n of r)t(n)&&e.push(n);return e},M=(r,t)=>{const e=[];for(let n=0;n<r.length;n++){const s=t(r[n],n);s!=null&&e.push(s)}return e},I=r=>g(r,t=>t!=null),S=r=>[].concat(...r),k=(r,t,e)=>{for(const n of r)e=t(e,n);return e},D=(r,t)=>{for(const e of r)if(!t(e))return!1;return!0},_=(r,t)=>{for(const e of r)if(t(e))return!0;return!1},T=(r,t)=>{for(const e of r)t(e)},H=(...r)=>[].concat(...r),N=(r,t,e,n=!0)=>{if(r.length<t.length)return-1*(n?1:-1);if(r.length>t.length)return 1*(n?1:-1);for(let s=0;s<r.length;s++){const l=e(r[s],t[s]);if(l!==0)return l}return 0},$=(r,t)=>r.slice().sort(t),p=(r,t)=>Array.from({length:r},(e,n)=>t(n)),C=(r,t=0)=>p(r,e=>t+e),L=(r,t)=>p(r,()=>t),V=r=>Array.from(new Set(r)),W=(r,t)=>{const e={};return r.forEach(n=>{e[t(n)]=n}),q.objectKeys(e).map(n=>e[n])},v=(r,t)=>{const e=r.indexOf(t);return e<0?!1:(r.splice(e,1),!0)},R=(r,t)=>{let e=!1;for(;v(r,t);)e=!0;return e},E=(r,t)=>{const e=r.findIndex(t);return e<0?!1:(r.splice(e,1),!0)},z=(r,t)=>{let e=!1;for(;E(r,t);)e=!0;return e},G=r=>{const t=[];for(let e=r.next();!(e.done??!1);e=r.next())t.push(e.value);return t},J=(r,t,e)=>{const n={removals:[],swaps:[],inserts:[]},{removals:s,inserts:l,swaps:u}=n,c=new Map;t.forEach((a,o)=>c.set(e(a),o));const f=r.map((a,o)=>[a,o]).filter(([a])=>!c.has(e(a))).map(([a,o])=>o);for(let a=f.length-1;a>=0;a--){const o=f[a],i=s.length>0?s[s.length-1]:void 0;i!=null&&i.at===o+1?(i.at--,i.qt++):s.push({at:o,qt:1})}const y=new Map;r.forEach((a,o)=>y.set(e(a),o));const h=t.map((a,o)=>[a,o]).filter(([a])=>!y.has(e(a))).map(([a,o])=>o);for(const a of h){const o=l.length>0?l[l.length-1]:void 0;o!=null&&o.at+o.values.length===a?o.values.push(t[a]):l.push({at:a,values:[t[a]]})}const A=r.filter((a,o)=>!f.includes(o)),m=new Map;for(let a=0;a<A.length;a++)m.set(e(A[a]),a);const d=t.filter((a,o)=>!h.includes(o));for(let a=0;a<d.length;a++){const o=e(d[a]),i=m.get(o);if(i==null||a===i)continue;const O=e(A[a]);m.delete(O),u.push({from:a,to:i})}return n},Q=(r,t)=>{const e=[...t];for(const{at:n,qt:s}of r.removals)e.splice(n,s);for(const{from:n,to:s}of r.swaps){const l=e[s];e[s]=e[n],e[n]=l}for(const n of r.inserts)e.splice(n.at,0,...n.values);return e},U=(r,t=" and ",e=", ")=>r.length===0?"":r.length===1?String(r[0]):`${r.slice(0,-1).join(e)}${t}${String(r[r.length-1])}`,X=(r,t,e=!0)=>{const n=r.map((c,f)=>[c,f]);n.sort((c,f)=>t(c[0],f[0]));const s=new Array(n.length);let l=0,u=n[0][0];for(let c=0;c<n.length;c++){const[f,y]=n[c];t(f,u)!==0&&(l=c,u=f),s[y]=l,e&&l++}return s};exports.allElements=D;exports.anyElement=_;exports.applyArrayDiffOperations=Q;exports.areArraysEqual=P;exports.arrayDiffOperations=J;exports.arrayHasValues=j;exports.arrayHead=w;exports.arrayOfIterableIterator=G;exports.arrayTail=B;exports.compareArrays=N;exports.concatArrays=H;exports.createFilledArray=L;exports.filterArray=g;exports.filterMapArray=M;exports.filterNullsFromArray=I;exports.flatMapArray=F;exports.flattenArray=S;exports.foldLeftArray=k;exports.forEachElement=T;exports.generateArray=p;exports.generateSequenceArray=C;exports.isArrayEmpty=b;exports.joinArrayWithConjunction=U;exports.mapArray=x;exports.rankArray=X;exports.removeAllFromArray=R;exports.removeAllFromArrayByPredicate=z;exports.removeOneFromArray=v;exports.removeOneFromArrayByPredicate=E;exports.sortArray=$;exports.uniqueByPrimitive=W;exports.uniquePrimitives=V;
|
package/array.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Compare, Maybe, Nothing, Primitive } from './domain';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Applies a function to each element of an array and returns a new array with the results.
|
|
5
4
|
*
|
|
@@ -224,7 +223,7 @@ export declare const uniquePrimitives: <T extends Primitive>(values: T[]) => T[]
|
|
|
224
223
|
* @returns An array of distinct elements.
|
|
225
224
|
* @public
|
|
226
225
|
*/
|
|
227
|
-
export declare const
|
|
226
|
+
export declare const uniqueByPrimitive: <T>(values: T[], predicate: (a: T) => string | number | symbol) => T[];
|
|
228
227
|
/**
|
|
229
228
|
* Removes the first occurrence of an item from an array.
|
|
230
229
|
*
|
package/array.js
CHANGED
package/async-result.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u={notAsked:{type:"NotAsked"},loading(e=void 0){return{type:"Loading",previousValue:e}},success(e){return{type:"AsyncSuccess",value:e}},failure(e){return{type:"AsyncFailure",error:e}},isSuccess(e){return e.type==="AsyncSuccess"},isFailure(e){return e.type==="AsyncFailure"},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},getUnsafe:e=>{if(u.isSuccess(e))return e.value;throw u.isFailure(e)?e.error:new Error("Cannot get value from a not-asked or loading result")},match:(e,{success:s,failure:r,loading:t,notAsked:n=t})=>u.isSuccess(e)?s(e.value):u.isFailure(e)?r(e.error):u.isNotAsked(e)?n():t(e.previousValue),whenSuccess:(e,s)=>(u.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(u.isFailure(e)&&s(e.error),e),equals:(e,s,r={valueEquals:(t,n)=>t===n,errorEquals:(t,n)=>t===n})=>e.type==="AsyncSuccess"&&s.type==="AsyncSuccess"?r.valueEquals(e.value,s.value):e.type==="AsyncFailure"&&s.type==="AsyncFailure"?r.errorEquals(e.error,s.error):e.type==="Loading"&&s.type==="Loading"?r.valueEquals(e.previousValue,s.previousValue):e.type==="NotAsked"&&s.type==="NotAsked",all:e=>{const s=[];for(const r of e)if(u.isSuccess(r))s.push(r.value);else return r;return u.success(s)},ofPromise:async e=>{try{const s=await e;return u.success(s)}catch(s){return u.failure(s instanceof Error?s:new Error(String(s)))}}};exports.AsyncResult=u;
|
package/async-result.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Maybe } from './domain';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Represents the state when a result has not been requested yet.
|
|
5
4
|
* @public
|
|
@@ -139,6 +138,12 @@ export declare const AsyncResult: {
|
|
|
139
138
|
* @public
|
|
140
139
|
*/
|
|
141
140
|
getOrUndefined<V, E>(r: AsyncResult<V, E>): Maybe<V>;
|
|
141
|
+
/**
|
|
142
|
+
* Gets the value of a `AsyncResult` if it is a `Success`, otherwise it throws the error contained in the `Failure`.
|
|
143
|
+
* @param r - The `AsyncResult` to get the value from.
|
|
144
|
+
* @returns The value of the `AsyncResult` if it is a `Success`.
|
|
145
|
+
*/
|
|
146
|
+
getUnsafe: <V, E>(r: AsyncResult<V, E>) => V;
|
|
142
147
|
/**
|
|
143
148
|
* Based on the state of the result, it picks the appropriate function to call and returns the result.
|
|
144
149
|
* @param success - The function to call if the result is a success.
|
|
@@ -172,4 +177,27 @@ export declare const AsyncResult: {
|
|
|
172
177
|
* @public
|
|
173
178
|
*/
|
|
174
179
|
whenFailure: <V, E>(r: AsyncResult<V, E>, apply: (e: E) => void) => AsyncResult<V, E>;
|
|
180
|
+
/**
|
|
181
|
+
* Compares two results for equality.
|
|
182
|
+
* @param r1 - The first result.
|
|
183
|
+
* @param r2 - The second result.
|
|
184
|
+
* @param options - The options to use for comparison. By default, uses strict equality.
|
|
185
|
+
* @returns `true` if the results are equal, `false` otherwise.
|
|
186
|
+
*/
|
|
187
|
+
equals: <V, E>(r1: AsyncResult<V, E>, r2: AsyncResult<V, E>, options?: {
|
|
188
|
+
valueEquals: (v1: V, v2: V) => boolean;
|
|
189
|
+
errorEquals: (e1: E, e2: E) => boolean;
|
|
190
|
+
}) => boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Combines multiple results into a single result.
|
|
193
|
+
* @param results - The results to combine.
|
|
194
|
+
* @returns A single result that is a success if all the input results are successes, otherwise a failure.
|
|
195
|
+
*/
|
|
196
|
+
all: <V, E>(results: AsyncResult<V, E>[]) => AsyncResult<V[], E>;
|
|
197
|
+
/**
|
|
198
|
+
* Converts a Promise to an AsyncResult.
|
|
199
|
+
* @param p - The Promise to convert.
|
|
200
|
+
* @returns A Promise that resolves to an AsyncResult.
|
|
201
|
+
*/
|
|
202
|
+
ofPromise: <V>(p: Promise<V>) => Promise<AsyncResult<V, Error>>;
|
|
175
203
|
};
|
package/async-result.js
CHANGED
|
@@ -108,6 +108,16 @@ const u = {
|
|
|
108
108
|
getOrUndefined(e) {
|
|
109
109
|
return u.isSuccess(e) ? e.value : void 0;
|
|
110
110
|
},
|
|
111
|
+
/**
|
|
112
|
+
* Gets the value of a `AsyncResult` if it is a `Success`, otherwise it throws the error contained in the `Failure`.
|
|
113
|
+
* @param r - The `AsyncResult` to get the value from.
|
|
114
|
+
* @returns The value of the `AsyncResult` if it is a `Success`.
|
|
115
|
+
*/
|
|
116
|
+
getUnsafe: (e) => {
|
|
117
|
+
if (u.isSuccess(e))
|
|
118
|
+
return e.value;
|
|
119
|
+
throw u.isFailure(e) ? e.error : new Error("Cannot get value from a not-asked or loading result");
|
|
120
|
+
},
|
|
111
121
|
/**
|
|
112
122
|
* Based on the state of the result, it picks the appropriate function to call and returns the result.
|
|
113
123
|
* @param success - The function to call if the result is a success.
|
|
@@ -119,10 +129,10 @@ const u = {
|
|
|
119
129
|
*/
|
|
120
130
|
match: (e, {
|
|
121
131
|
success: s,
|
|
122
|
-
failure:
|
|
123
|
-
loading:
|
|
124
|
-
notAsked:
|
|
125
|
-
}) => u.isSuccess(e) ? s(e.value) : u.isFailure(e) ?
|
|
132
|
+
failure: r,
|
|
133
|
+
loading: t,
|
|
134
|
+
notAsked: n = t
|
|
135
|
+
}) => u.isSuccess(e) ? s(e.value) : u.isFailure(e) ? r(e.error) : u.isNotAsked(e) ? n() : t(e.previousValue),
|
|
126
136
|
/**
|
|
127
137
|
* When the result is a success, it applies the function to the value.
|
|
128
138
|
*
|
|
@@ -140,7 +150,45 @@ const u = {
|
|
|
140
150
|
* @returns The result that was passed in.
|
|
141
151
|
* @public
|
|
142
152
|
*/
|
|
143
|
-
whenFailure: (e, s) => (u.isFailure(e) && s(e.error), e)
|
|
153
|
+
whenFailure: (e, s) => (u.isFailure(e) && s(e.error), e),
|
|
154
|
+
/**
|
|
155
|
+
* Compares two results for equality.
|
|
156
|
+
* @param r1 - The first result.
|
|
157
|
+
* @param r2 - The second result.
|
|
158
|
+
* @param options - The options to use for comparison. By default, uses strict equality.
|
|
159
|
+
* @returns `true` if the results are equal, `false` otherwise.
|
|
160
|
+
*/
|
|
161
|
+
equals: (e, s, r = {
|
|
162
|
+
valueEquals: (t, n) => t === n,
|
|
163
|
+
errorEquals: (t, n) => t === n
|
|
164
|
+
}) => e.type === "AsyncSuccess" && s.type === "AsyncSuccess" ? r.valueEquals(e.value, s.value) : e.type === "AsyncFailure" && s.type === "AsyncFailure" ? r.errorEquals(e.error, s.error) : e.type === "Loading" && s.type === "Loading" ? r.valueEquals(e.previousValue, s.previousValue) : e.type === "NotAsked" && s.type === "NotAsked",
|
|
165
|
+
/**
|
|
166
|
+
* Combines multiple results into a single result.
|
|
167
|
+
* @param results - The results to combine.
|
|
168
|
+
* @returns A single result that is a success if all the input results are successes, otherwise a failure.
|
|
169
|
+
*/
|
|
170
|
+
all: (e) => {
|
|
171
|
+
const s = [];
|
|
172
|
+
for (const r of e)
|
|
173
|
+
if (u.isSuccess(r))
|
|
174
|
+
s.push(r.value);
|
|
175
|
+
else
|
|
176
|
+
return r;
|
|
177
|
+
return u.success(s);
|
|
178
|
+
},
|
|
179
|
+
/**
|
|
180
|
+
* Converts a Promise to an AsyncResult.
|
|
181
|
+
* @param p - The Promise to convert.
|
|
182
|
+
* @returns A Promise that resolves to an AsyncResult.
|
|
183
|
+
*/
|
|
184
|
+
ofPromise: async (e) => {
|
|
185
|
+
try {
|
|
186
|
+
const s = await e;
|
|
187
|
+
return u.success(s);
|
|
188
|
+
} catch (s) {
|
|
189
|
+
return u.failure(s instanceof Error ? s : new Error(String(s)));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
144
192
|
};
|
|
145
193
|
export {
|
|
146
194
|
u as AsyncResult
|
package/domain.d.ts
CHANGED
|
@@ -164,3 +164,19 @@ export type SplitLiteral<T extends string, SplitBy extends string> = FilterTuple
|
|
|
164
164
|
* @public
|
|
165
165
|
*/
|
|
166
166
|
export type SplitLiteralToUnion<T extends string, SplitBy extends string> = TupleToUnion<SplitLiteral<T, SplitBy>>;
|
|
167
|
+
/**
|
|
168
|
+
* Creates a new type by making the specified key `K` of `T` optional.
|
|
169
|
+
* @typeParam T - The type to create a new type from.
|
|
170
|
+
* @typeParam K - The key of `T` to make optional.
|
|
171
|
+
* @returns A new type with the specified key made optional.
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
export type PartialBy<T, K extends keyof T> = Merge<Omit<T, K>, Partial<Pick<T, K>>>;
|
|
175
|
+
/**
|
|
176
|
+
* Creates a new type by making the specified key `K` of `T` required.
|
|
177
|
+
* @typeParam T - The type to create a new type from.
|
|
178
|
+
* @typeParam K - The key of `T` to make required.
|
|
179
|
+
* @returns A new type with the specified key made required.
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
export type RequiredBy<T, K extends keyof T> = Merge<Omit<T, K>, Required<Pick<T, K>>>;
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./array.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./array.cjs"),c=require("./async-result.cjs"),i=require("./bigint.cjs"),a=require("./equal.cjs"),n=require("./function.cjs"),o=require("./json.cjs"),t=require("./number.cjs"),s=require("./object.cjs"),m=require("./promise.cjs"),p=require("./regexp.cjs"),l=require("./result-CdwVhaAc.cjs"),e=require("./string.cjs");exports.allElements=r.allElements;exports.anyElement=r.anyElement;exports.applyArrayDiffOperations=r.applyArrayDiffOperations;exports.areArraysEqual=r.areArraysEqual;exports.arrayDiffOperations=r.arrayDiffOperations;exports.arrayHasValues=r.arrayHasValues;exports.arrayHead=r.arrayHead;exports.arrayOfIterableIterator=r.arrayOfIterableIterator;exports.arrayTail=r.arrayTail;exports.compareArrays=r.compareArrays;exports.concatArrays=r.concatArrays;exports.createFilledArray=r.createFilledArray;exports.filterArray=r.filterArray;exports.filterMapArray=r.filterMapArray;exports.filterNullsFromArray=r.filterNullsFromArray;exports.flatMapArray=r.flatMapArray;exports.flattenArray=r.flattenArray;exports.foldLeftArray=r.foldLeftArray;exports.forEachElement=r.forEachElement;exports.generateArray=r.generateArray;exports.generateSequenceArray=r.generateSequenceArray;exports.isArrayEmpty=r.isArrayEmpty;exports.joinArrayWithConjunction=r.joinArrayWithConjunction;exports.mapArray=r.mapArray;exports.rankArray=r.rankArray;exports.removeAllFromArray=r.removeAllFromArray;exports.removeAllFromArrayByPredicate=r.removeAllFromArrayByPredicate;exports.removeOneFromArray=r.removeOneFromArray;exports.removeOneFromArrayByPredicate=r.removeOneFromArrayByPredicate;exports.sortArray=r.sortArray;exports.uniqueByPrimitive=r.uniqueByPrimitive;exports.uniquePrimitives=r.uniquePrimitives;exports.AsyncResult=c.AsyncResult;exports.biAbs=i.biAbs;exports.biCeilDiv=i.biCeilDiv;exports.biCompare=i.biCompare;exports.biFloorDiv=i.biFloorDiv;exports.biGcd=i.biGcd;exports.biIsEven=i.biIsEven;exports.biIsNegative=i.biIsNegative;exports.biIsOdd=i.biIsOdd;exports.biIsOne=i.biIsOne;exports.biIsPositive=i.biIsPositive;exports.biIsPrime=i.biIsPrime;exports.biIsZero=i.biIsZero;exports.biLcm=i.biLcm;exports.biMax=i.biMax;exports.biMin=i.biMin;exports.biNextPrime=i.biNextPrime;exports.biPow=i.biPow;exports.biPrevPrime=i.biPrevPrime;exports.deepEqual=a.deepEqual;exports.looseEqual=a.looseEqual;exports.strictEqual=a.strictEqual;exports.curryLeft=n.curryLeft;exports.identity=n.identity;exports.memoize=n.memoize;exports.isJSONArray=o.isJSONArray;exports.isJSONObject=o.isJSONObject;exports.isJSONPrimitive=o.isJSONPrimitive;exports.EPSILON=t.EPSILON;exports.angleDifference=t.angleDifference;exports.ceilTo=t.ceilTo;exports.clamp=t.clamp;exports.clampInt=t.clampInt;exports.clampSym=t.clampSym;exports.compareNumbers=t.compareNumbers;exports.floorTo=t.floorTo;exports.interpolate=t.interpolate;exports.interpolateAngle=t.interpolateAngle;exports.interpolateAngleCCW=t.interpolateAngleCCW;exports.interpolateAngleCW=t.interpolateAngleCW;exports.interpolateWidestAngle=t.interpolateWidestAngle;exports.nearEqualAngles=t.nearEqualAngles;exports.nearEquals=t.nearEquals;exports.nearZero=t.nearZero;exports.root=t.root;exports.roundTo=t.roundTo;exports.sign=t.sign;exports.toHex=t.toHex;exports.widestAngleDifference=t.widestAngleDifference;exports.wrap=t.wrap;exports.wrapCircular=t.wrapCircular;exports.isEmptyObject=s.isEmptyObject;exports.isObject=s.isObject;exports.mergeObjects=s.mergeObjects;exports.objectEntries=s.objectEntries;exports.objectFromEntries=s.objectFromEntries;exports.objectKeys=s.objectKeys;exports.objectValues=s.objectValues;exports.removeObjectFields=s.removeObjectFields;exports.sameObjectKeys=s.sameObjectKeys;exports.sleep=m.sleep;exports.mapRegExp=p.mapRegExp;exports.Result=l.Result;exports.Validation=l.Validation;exports.canonicalizeNewlines=e.canonicalizeNewlines;exports.capitalize=e.capitalize;exports.capitalizeWords=e.capitalizeWords;exports.chunkString=e.chunkString;exports.collapseText=e.collapseText;exports.compareCaseInsensitive=e.compareCaseInsensitive;exports.compareStrings=e.compareStrings;exports.containsAllText=e.containsAllText;exports.containsAllTextCaseInsensitive=e.containsAllTextCaseInsensitive;exports.containsAnyText=e.containsAnyText;exports.containsAnyTextCaseInsensitive=e.containsAnyTextCaseInsensitive;exports.countStringOccurrences=e.countStringOccurrences;exports.dasherize=e.dasherize;exports.decodeBase64=e.decodeBase64;exports.deleteFirstFromString=e.deleteFirstFromString;exports.deleteStringAfter=e.deleteStringAfter;exports.deleteStringBefore=e.deleteStringBefore;exports.deleteSubstring=e.deleteSubstring;exports.ellipsis=e.ellipsis;exports.ellipsisMiddle=e.ellipsisMiddle;exports.encodeBase64=e.encodeBase64;exports.filterCharcodes=e.filterCharcodes;exports.filterChars=e.filterChars;exports.humanize=e.humanize;exports.ifEmptyString=e.ifEmptyString;exports.isAlpha=e.isAlpha;exports.isAlphaNum=e.isAlphaNum;exports.isBreakingWhitespace=e.isBreakingWhitespace;exports.isDigitsOnly=e.isDigitsOnly;exports.isEmptyString=e.isEmptyString;exports.isLowerCase=e.isLowerCase;exports.isSpaceAt=e.isSpaceAt;exports.isUpperCase=e.isUpperCase;exports.jsQuote=e.jsQuote;exports.lowerCaseFirst=e.lowerCaseFirst;exports.lpad=e.lpad;exports.mapChars=e.mapChars;exports.quote=e.quote;exports.randomString=e.randomString;exports.randomStringSequence=e.randomStringSequence;exports.randomStringSequenceBase64=e.randomStringSequenceBase64;exports.repeatString=e.repeatString;exports.replaceAll=e.replaceAll;exports.reverseString=e.reverseString;exports.rpad=e.rpad;exports.smartQuote=e.smartQuote;exports.splitStringOnFirst=e.splitStringOnFirst;exports.splitStringOnLast=e.splitStringOnLast;exports.splitStringOnce=e.splitStringOnce;exports.stringContains=e.stringContains;exports.stringEndsWith=e.stringEndsWith;exports.stringEndsWithAny=e.stringEndsWithAny;exports.stringHasContent=e.stringHasContent;exports.stringHashCode=e.stringHashCode;exports.stringStartsWith=e.stringStartsWith;exports.stringStartsWithAny=e.stringStartsWithAny;exports.stringToCharcodes=e.stringToCharcodes;exports.stringToChars=e.stringToChars;exports.stringsDifferAtIndex=e.stringsDifferAtIndex;exports.substringAfter=e.substringAfter;exports.substringAfterLast=e.substringAfterLast;exports.substringBefore=e.substringBefore;exports.substringBeforeLast=e.substringBeforeLast;exports.surroundString=e.surroundString;exports.textContainsCaseInsensitive=e.textContainsCaseInsensitive;exports.textEndsWithAnyCaseInsensitive=e.textEndsWithAnyCaseInsensitive;exports.textEndsWithCaseInsensitive=e.textEndsWithCaseInsensitive;exports.textStartsWithAnyCaseInsensitive=e.textStartsWithAnyCaseInsensitive;exports.textStartsWithCaseInsensitive=e.textStartsWithCaseInsensitive;exports.textToLines=e.textToLines;exports.trimChars=e.trimChars;exports.trimCharsLeft=e.trimCharsLeft;exports.trimCharsRight=e.trimCharsRight;exports.trimStringSlice=e.trimStringSlice;exports.underscore=e.underscore;exports.upperCaseFirst=e.upperCaseFirst;exports.wrapColumns=e.wrapColumns;exports.wrapLine=e.wrapLine;
|
package/index.js
CHANGED
|
@@ -1,181 +1,188 @@
|
|
|
1
|
-
import { allElements as t, anyElement as i, applyArrayDiffOperations as
|
|
2
|
-
import { AsyncResult as
|
|
3
|
-
import { biAbs as
|
|
4
|
-
import { deepEqual as te, looseEqual as ie, strictEqual as
|
|
1
|
+
import { allElements as t, anyElement as i, applyArrayDiffOperations as s, areArraysEqual as a, arrayDiffOperations as n, arrayHasValues as o, arrayHead as l, arrayOfIterableIterator as m, arrayTail as p, compareArrays as c, concatArrays as y, createFilledArray as g, filterArray as A, filterMapArray as f, filterNullsFromArray as d, flatMapArray as u, flattenArray as b, foldLeftArray as S, forEachElement as C, generateArray as x, generateSequenceArray as h, isArrayEmpty as v, joinArrayWithConjunction as E, mapArray as O, rankArray as I, removeAllFromArray as F, removeAllFromArrayByPredicate as W, removeOneFromArray as j, removeOneFromArrayByPredicate as q, sortArray as P, uniqueByPrimitive as T, uniquePrimitives as L } from "./array.js";
|
|
2
|
+
import { AsyncResult as N } from "./async-result.js";
|
|
3
|
+
import { biAbs as D, biCeilDiv as z, biCompare as H, biFloorDiv as M, biGcd as R, biIsEven as V, biIsNegative as k, biIsOdd as J, biIsOne as K, biIsPositive as Q, biIsPrime as Z, biIsZero as G, biLcm as U, biMax as X, biMin as Y, biNextPrime as _, biPow as $, biPrevPrime as ee } from "./bigint.js";
|
|
4
|
+
import { deepEqual as te, looseEqual as ie, strictEqual as se } from "./equal.js";
|
|
5
5
|
import { curryLeft as ne, identity as oe, memoize as le } from "./function.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { isJSONArray as pe, isJSONObject as ce, isJSONPrimitive as ye } from "./json.js";
|
|
7
|
+
import { EPSILON as Ae, angleDifference as fe, ceilTo as de, clamp as ue, clampInt as be, clampSym as Se, compareNumbers as Ce, floorTo as xe, interpolate as he, interpolateAngle as ve, interpolateAngleCCW as Ee, interpolateAngleCW as Oe, interpolateWidestAngle as Ie, nearEqualAngles as Fe, nearEquals as We, nearZero as je, root as qe, roundTo as Pe, sign as Te, toHex as Le, widestAngleDifference as Be, wrap as Ne, wrapCircular as we } from "./number.js";
|
|
8
|
+
import { isEmptyObject as ze, isObject as He, mergeObjects as Me, objectEntries as Re, objectFromEntries as Ve, objectKeys as ke, objectValues as Je, removeObjectFields as Ke, sameObjectKeys as Qe } from "./object.js";
|
|
9
|
+
import { sleep as Ge } from "./promise.js";
|
|
10
|
+
import { mapRegExp as Xe } from "./regexp.js";
|
|
11
|
+
import { R as _e, V as $e } from "./result-CGd0jCdl.js";
|
|
12
|
+
import { canonicalizeNewlines as rr, capitalize as tr, capitalizeWords as ir, chunkString as sr, collapseText as ar, compareCaseInsensitive as nr, compareStrings as or, containsAllText as lr, containsAllTextCaseInsensitive as mr, containsAnyText as pr, containsAnyTextCaseInsensitive as cr, countStringOccurrences as yr, dasherize as gr, decodeBase64 as Ar, deleteFirstFromString as fr, deleteStringAfter as dr, deleteStringBefore as ur, deleteSubstring as br, ellipsis as Sr, ellipsisMiddle as Cr, encodeBase64 as xr, filterCharcodes as hr, filterChars as vr, humanize as Er, ifEmptyString as Or, isAlpha as Ir, isAlphaNum as Fr, isBreakingWhitespace as Wr, isDigitsOnly as jr, isEmptyString as qr, isLowerCase as Pr, isSpaceAt as Tr, isUpperCase as Lr, jsQuote as Br, lowerCaseFirst as Nr, lpad as wr, mapChars as Dr, quote as zr, randomString as Hr, randomStringSequence as Mr, randomStringSequenceBase64 as Rr, repeatString as Vr, replaceAll as kr, reverseString as Jr, rpad as Kr, smartQuote as Qr, splitStringOnFirst as Zr, splitStringOnLast as Gr, splitStringOnce as Ur, stringContains as Xr, stringEndsWith as Yr, stringEndsWithAny as _r, stringHasContent as $r, stringHashCode as et, stringStartsWith as rt, stringStartsWithAny as tt, stringToCharcodes as it, stringToChars as st, stringsDifferAtIndex as at, substringAfter as nt, substringAfterLast as ot, substringBefore as lt, substringBeforeLast as mt, surroundString as pt, textContainsCaseInsensitive as ct, textEndsWithAnyCaseInsensitive as yt, textEndsWithCaseInsensitive as gt, textStartsWithAnyCaseInsensitive as At, textStartsWithCaseInsensitive as ft, textToLines as dt, trimChars as ut, trimCharsLeft as bt, trimCharsRight as St, trimStringSlice as Ct, underscore as xt, upperCaseFirst as ht, wrapColumns as vt, wrapLine as Et } from "./string.js";
|
|
12
13
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
N as AsyncResult,
|
|
15
|
+
Ae as EPSILON,
|
|
16
|
+
_e as Result,
|
|
17
|
+
$e as Validation,
|
|
17
18
|
t as allElements,
|
|
18
|
-
|
|
19
|
+
fe as angleDifference,
|
|
19
20
|
i as anyElement,
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
s as applyArrayDiffOperations,
|
|
22
|
+
a as areArraysEqual,
|
|
22
23
|
n as arrayDiffOperations,
|
|
23
24
|
o as arrayHasValues,
|
|
24
25
|
l as arrayHead,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
m as arrayOfIterableIterator,
|
|
27
|
+
p as arrayTail,
|
|
28
|
+
D as biAbs,
|
|
28
29
|
z as biCeilDiv,
|
|
29
30
|
H as biCompare,
|
|
30
31
|
M as biFloorDiv,
|
|
31
32
|
R as biGcd,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
V as biIsEven,
|
|
34
|
+
k as biIsNegative,
|
|
35
|
+
J as biIsOdd,
|
|
36
|
+
K as biIsOne,
|
|
37
|
+
Q as biIsPositive,
|
|
38
|
+
Z as biIsPrime,
|
|
39
|
+
G as biIsZero,
|
|
40
|
+
U as biLcm,
|
|
40
41
|
X as biMax,
|
|
41
42
|
Y as biMin,
|
|
42
43
|
_ as biNextPrime,
|
|
43
44
|
$ as biPow,
|
|
44
45
|
ee as biPrevPrime,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
rr as canonicalizeNewlines,
|
|
47
|
+
tr as capitalize,
|
|
48
|
+
ir as capitalizeWords,
|
|
49
|
+
de as ceilTo,
|
|
50
|
+
sr as chunkString,
|
|
51
|
+
ue as clamp,
|
|
52
|
+
be as clampInt,
|
|
53
|
+
Se as clampSym,
|
|
54
|
+
ar as collapseText,
|
|
54
55
|
c as compareArrays,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
nr as compareCaseInsensitive,
|
|
57
|
+
Ce as compareNumbers,
|
|
58
|
+
or as compareStrings,
|
|
59
|
+
y as concatArrays,
|
|
60
|
+
lr as containsAllText,
|
|
61
|
+
mr as containsAllTextCaseInsensitive,
|
|
62
|
+
pr as containsAnyText,
|
|
63
|
+
cr as containsAnyTextCaseInsensitive,
|
|
64
|
+
yr as countStringOccurrences,
|
|
65
|
+
g as createFilledArray,
|
|
65
66
|
ne as curryLeft,
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
gr as dasherize,
|
|
68
|
+
Ar as decodeBase64,
|
|
68
69
|
te as deepEqual,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
fr as deleteFirstFromString,
|
|
71
|
+
dr as deleteStringAfter,
|
|
72
|
+
ur as deleteStringBefore,
|
|
73
|
+
br as deleteSubstring,
|
|
74
|
+
Sr as ellipsis,
|
|
75
|
+
Cr as ellipsisMiddle,
|
|
76
|
+
xr as encodeBase64,
|
|
76
77
|
A as filterArray,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
hr as filterCharcodes,
|
|
79
|
+
vr as filterChars,
|
|
80
|
+
f as filterMapArray,
|
|
81
|
+
d as filterNullsFromArray,
|
|
81
82
|
u as flatMapArray,
|
|
82
83
|
b as flattenArray,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
xe as floorTo,
|
|
85
|
+
S as foldLeftArray,
|
|
86
|
+
C as forEachElement,
|
|
86
87
|
x as generateArray,
|
|
87
88
|
h as generateSequenceArray,
|
|
88
|
-
|
|
89
|
+
Er as humanize,
|
|
89
90
|
oe as identity,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
Or as ifEmptyString,
|
|
92
|
+
he as interpolate,
|
|
93
|
+
ve as interpolateAngle,
|
|
94
|
+
Ee as interpolateAngleCCW,
|
|
95
|
+
Oe as interpolateAngleCW,
|
|
96
|
+
Ie as interpolateWidestAngle,
|
|
97
|
+
Ir as isAlpha,
|
|
98
|
+
Fr as isAlphaNum,
|
|
98
99
|
v as isArrayEmpty,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
Wr as isBreakingWhitespace,
|
|
101
|
+
jr as isDigitsOnly,
|
|
102
|
+
ze as isEmptyObject,
|
|
103
|
+
qr as isEmptyString,
|
|
104
|
+
pe as isJSONArray,
|
|
105
|
+
ce as isJSONObject,
|
|
106
|
+
ye as isJSONPrimitive,
|
|
107
|
+
Pr as isLowerCase,
|
|
108
|
+
He as isObject,
|
|
109
|
+
Tr as isSpaceAt,
|
|
110
|
+
Lr as isUpperCase,
|
|
107
111
|
E as joinArrayWithConjunction,
|
|
108
|
-
|
|
112
|
+
Br as jsQuote,
|
|
109
113
|
ie as looseEqual,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
Nr as lowerCaseFirst,
|
|
115
|
+
wr as lpad,
|
|
116
|
+
O as mapArray,
|
|
117
|
+
Dr as mapChars,
|
|
118
|
+
Xe as mapRegExp,
|
|
115
119
|
le as memoize,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
120
|
+
Me as mergeObjects,
|
|
121
|
+
Fe as nearEqualAngles,
|
|
122
|
+
We as nearEquals,
|
|
123
|
+
je as nearZero,
|
|
124
|
+
Re as objectEntries,
|
|
125
|
+
Ve as objectFromEntries,
|
|
126
|
+
ke as objectKeys,
|
|
127
|
+
Je as objectValues,
|
|
128
|
+
zr as quote,
|
|
129
|
+
Hr as randomString,
|
|
130
|
+
Mr as randomStringSequence,
|
|
131
|
+
Rr as randomStringSequenceBase64,
|
|
132
|
+
I as rankArray,
|
|
133
|
+
F as removeAllFromArray,
|
|
134
|
+
W as removeAllFromArrayByPredicate,
|
|
135
|
+
Ke as removeObjectFields,
|
|
136
|
+
j as removeOneFromArray,
|
|
137
|
+
q as removeOneFromArrayByPredicate,
|
|
138
|
+
Vr as repeatString,
|
|
139
|
+
kr as replaceAll,
|
|
140
|
+
Jr as reverseString,
|
|
141
|
+
qe as root,
|
|
142
|
+
Pe as roundTo,
|
|
143
|
+
Kr as rpad,
|
|
144
|
+
Qe as sameObjectKeys,
|
|
145
|
+
Te as sign,
|
|
146
|
+
Ge as sleep,
|
|
147
|
+
Qr as smartQuote,
|
|
148
|
+
P as sortArray,
|
|
149
|
+
Zr as splitStringOnFirst,
|
|
150
|
+
Gr as splitStringOnLast,
|
|
151
|
+
Ur as splitStringOnce,
|
|
152
|
+
se as strictEqual,
|
|
153
|
+
Xr as stringContains,
|
|
154
|
+
Yr as stringEndsWith,
|
|
155
|
+
_r as stringEndsWithAny,
|
|
156
|
+
$r as stringHasContent,
|
|
157
|
+
et as stringHashCode,
|
|
158
|
+
rt as stringStartsWith,
|
|
159
|
+
tt as stringStartsWithAny,
|
|
160
|
+
it as stringToCharcodes,
|
|
161
|
+
st as stringToChars,
|
|
162
|
+
at as stringsDifferAtIndex,
|
|
163
|
+
nt as substringAfter,
|
|
164
|
+
ot as substringAfterLast,
|
|
165
|
+
lt as substringBefore,
|
|
166
|
+
mt as substringBeforeLast,
|
|
167
|
+
pt as surroundString,
|
|
168
|
+
ct as textContainsCaseInsensitive,
|
|
169
|
+
yt as textEndsWithAnyCaseInsensitive,
|
|
170
|
+
gt as textEndsWithCaseInsensitive,
|
|
171
|
+
At as textStartsWithAnyCaseInsensitive,
|
|
172
|
+
ft as textStartsWithCaseInsensitive,
|
|
173
|
+
dt as textToLines,
|
|
174
|
+
Le as toHex,
|
|
175
|
+
ut as trimChars,
|
|
176
|
+
bt as trimCharsLeft,
|
|
177
|
+
St as trimCharsRight,
|
|
178
|
+
Ct as trimStringSlice,
|
|
179
|
+
xt as underscore,
|
|
180
|
+
T as uniqueByPrimitive,
|
|
181
|
+
L as uniquePrimitives,
|
|
182
|
+
ht as upperCaseFirst,
|
|
183
|
+
Be as widestAngleDifference,
|
|
184
|
+
Ne as wrap,
|
|
185
|
+
we as wrapCircular,
|
|
186
|
+
vt as wrapColumns,
|
|
187
|
+
Et as wrapLine
|
|
181
188
|
};
|
package/json.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=r=>typeof r=="object"&&!Array.isArray(r)&&r!=null,i=r=>Array.isArray(r),o=r=>typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r==null;exports.isJSONArray=i;exports.isJSONObject=t;exports.isJSONPrimitive=o;
|
package/json.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Nothing } from './domain';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Represents a JSON primitive value.
|
|
5
4
|
* It can be a string, boolean, number, or Nothing (null or undefined).
|
|
@@ -23,3 +22,27 @@ export type JSONArray = JSONValue[];
|
|
|
23
22
|
* @public
|
|
24
23
|
*/
|
|
25
24
|
export type JSONValue = JSONPrimitive | JSONObject | JSONArray;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if the value is a JSON object.
|
|
27
|
+
*
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @returns `true` if the value is a JSON object; otherwise, `false`.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare const isJSONObject: (value: JSONValue) => value is JSONObject;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if the value is a JSON array.
|
|
35
|
+
*
|
|
36
|
+
* @param value - The value to check.
|
|
37
|
+
* @returns `true` if the value is a JSON array; otherwise, `false`.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare const isJSONArray: (value: JSONValue) => value is JSONArray;
|
|
41
|
+
/**
|
|
42
|
+
* Checks if the value is a JSON primitive.
|
|
43
|
+
*
|
|
44
|
+
* @param value - The value to check.
|
|
45
|
+
* @returns `true` if the value is a JSON primitive; otherwise, `false`.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export declare const isJSONPrimitive: (value: JSONValue) => value is JSONPrimitive;
|
package/json.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
const t = (r) => typeof r == "object" && !Array.isArray(r) && r != null, o = (r) => Array.isArray(r), i = (r) => typeof r == "string" || typeof r == "boolean" || typeof r == "number" || r == null;
|
|
2
|
+
export {
|
|
3
|
+
o as isJSONArray,
|
|
4
|
+
t as isJSONObject,
|
|
5
|
+
i as isJSONPrimitive
|
|
6
|
+
};
|
package/object.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=e=>Object.keys(e),r=e=>Object.values(e),b=e=>Object.entries(e),j=e=>Object.fromEntries(e),i=(e,t)=>{const n=o(e),c=o(t);if(n.length!==c.length)return!1;for(const s of n)if(!(s in t))return!1;return!0},O=e=>e!=null&&Object.getPrototypeOf(e)===Object.prototype,l=(e,...t)=>o(e).reduce((c,s)=>(t.includes(s)||(c[s]=e[s]),c),{}),u=(e,t)=>Object.assign({},e,t),m=e=>Object.keys(e).length===0;exports.isEmptyObject=m;exports.isObject=O;exports.mergeObjects=u;exports.objectEntries=b;exports.objectFromEntries=j;exports.objectKeys=o;exports.objectValues=r;exports.removeObjectFields=l;exports.sameObjectKeys=i;
|
package/object.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IndexKey, Merge, TupleToUnion } from './domain';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Returns an array of keys from the given object.
|
|
5
4
|
*
|
|
@@ -8,6 +7,30 @@ import { IndexKey, Merge, TupleToUnion } from './domain';
|
|
|
8
7
|
* @public
|
|
9
8
|
*/
|
|
10
9
|
export declare const objectKeys: <T extends object>(obj: T) => Array<keyof T>;
|
|
10
|
+
/**
|
|
11
|
+
* Returns an array of values from the given object.
|
|
12
|
+
*
|
|
13
|
+
* @param obj - The object from which to extract values.
|
|
14
|
+
* @returns An array of values from the object.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare const objectValues: <T extends object>(obj: T) => Array<T[keyof T]>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns an array of entries (key-value pairs) from the given object.
|
|
20
|
+
*
|
|
21
|
+
* @param obj - The object from which to extract entries.
|
|
22
|
+
* @returns An array of tuples, where each tuple contains a key and its corresponding value from the object.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare const objectEntries: <T extends object>(obj: T) => [keyof T, T[keyof T]][];
|
|
26
|
+
/**
|
|
27
|
+
* Creates an object from an array of entries.
|
|
28
|
+
*
|
|
29
|
+
* @param entries - The array of entries to create an object from.
|
|
30
|
+
* @returns The created object.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare const objectFromEntries: <T extends object>(entries: [keyof T, T[keyof T]][]) => T;
|
|
11
34
|
/**
|
|
12
35
|
* Checks if two objects have the same keys.
|
|
13
36
|
*
|
package/object.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
if (
|
|
4
|
-
for (const s of
|
|
1
|
+
const o = (e) => Object.keys(e), r = (e) => Object.values(e), j = (e) => Object.entries(e), b = (e) => Object.fromEntries(e), O = (e, t) => {
|
|
2
|
+
const n = o(e), c = o(t);
|
|
3
|
+
if (n.length !== c.length) return !1;
|
|
4
|
+
for (const s of n)
|
|
5
5
|
if (!(s in t)) return !1;
|
|
6
6
|
return !0;
|
|
7
|
-
},
|
|
7
|
+
}, i = (e) => e != null && Object.getPrototypeOf(e) === Object.prototype, l = (e, ...t) => o(e).reduce((c, s) => (t.includes(s) || (c[s] = e[s]), c), {}), u = (e, t) => Object.assign({}, e, t), f = (e) => Object.keys(e).length === 0;
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
o as
|
|
9
|
+
f as isEmptyObject,
|
|
10
|
+
i as isObject,
|
|
11
|
+
u as mergeObjects,
|
|
12
|
+
j as objectEntries,
|
|
13
|
+
b as objectFromEntries,
|
|
14
|
+
o as objectKeys,
|
|
15
|
+
r as objectValues,
|
|
16
|
+
l as removeObjectFields,
|
|
17
|
+
O as sameObjectKeys
|
|
15
18
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AsyncResult as
|
|
2
|
-
const
|
|
1
|
+
import { AsyncResult as c } from "./async-result.js";
|
|
2
|
+
const a = {
|
|
3
3
|
/**
|
|
4
4
|
* Creates a valid `Validation`.
|
|
5
5
|
* @returns A `Validation` that is `Valid`.
|
|
@@ -37,14 +37,14 @@ const t = {
|
|
|
37
37
|
* @param invalid - The mapping function for an invalid value.
|
|
38
38
|
* @returns The mapped value.
|
|
39
39
|
*/
|
|
40
|
-
match: (e, s, r) =>
|
|
40
|
+
match: (e, s, r) => a.isValid(e) ? s() : r(e.error),
|
|
41
41
|
/**
|
|
42
42
|
* Maps the value of a `Validation` to a new `Validation`.
|
|
43
43
|
* @param validation - The `Validation` to map.
|
|
44
44
|
* @param value - The value to map.
|
|
45
45
|
* @returns A new `Validation` with the mapped value.
|
|
46
46
|
*/
|
|
47
|
-
toResult: (e, s) =>
|
|
47
|
+
toResult: (e, s) => a.match(
|
|
48
48
|
e,
|
|
49
49
|
() => u.success(s),
|
|
50
50
|
(r) => u.failure(r)
|
|
@@ -56,7 +56,7 @@ const t = {
|
|
|
56
56
|
* @param apply - The function to execute when the `Validation` is valid.
|
|
57
57
|
* @returns The `Validation` object.
|
|
58
58
|
*/
|
|
59
|
-
whenValid: (e, s) => (
|
|
59
|
+
whenValid: (e, s) => (a.isValid(e) && s(), e),
|
|
60
60
|
/**
|
|
61
61
|
* Execute a function when the `Validation` is invalid.
|
|
62
62
|
*
|
|
@@ -64,7 +64,7 @@ const t = {
|
|
|
64
64
|
* @param apply - The function to execute when the `Validation` is invalid.
|
|
65
65
|
* @returns The `Validation` object.
|
|
66
66
|
*/
|
|
67
|
-
whenInvalid: (e, s) => (
|
|
67
|
+
whenInvalid: (e, s) => (a.isInvalid(e) && s(e.error), e)
|
|
68
68
|
}, u = {
|
|
69
69
|
/**
|
|
70
70
|
* Creates a successful `Result`.
|
|
@@ -111,8 +111,8 @@ const t = {
|
|
|
111
111
|
toAsync(e) {
|
|
112
112
|
return u.match(
|
|
113
113
|
e,
|
|
114
|
-
(s) =>
|
|
115
|
-
(s) =>
|
|
114
|
+
(s) => c.success(s),
|
|
115
|
+
(s) => c.failure(s)
|
|
116
116
|
);
|
|
117
117
|
},
|
|
118
118
|
/**
|
|
@@ -124,8 +124,8 @@ const t = {
|
|
|
124
124
|
toValidation(e) {
|
|
125
125
|
return u.match(
|
|
126
126
|
e,
|
|
127
|
-
() =>
|
|
128
|
-
(s) =>
|
|
127
|
+
() => a.valid,
|
|
128
|
+
(s) => a.invalid(s)
|
|
129
129
|
);
|
|
130
130
|
},
|
|
131
131
|
/**
|
|
@@ -184,6 +184,16 @@ const t = {
|
|
|
184
184
|
getOrUndefined(e) {
|
|
185
185
|
return u.isSuccess(e) ? e.value : void 0;
|
|
186
186
|
},
|
|
187
|
+
/**
|
|
188
|
+
* Gets the value of a `Result` if it is a `Success`, otherwise it throws the error contained in the `Failure`.
|
|
189
|
+
* @param r - The `Result` to get the value from.
|
|
190
|
+
* @returns The value of the `Result` if it is a `Success`.
|
|
191
|
+
*/
|
|
192
|
+
getUnsafe: (e) => {
|
|
193
|
+
if (u.isSuccess(e))
|
|
194
|
+
return e.value;
|
|
195
|
+
throw e.error;
|
|
196
|
+
},
|
|
187
197
|
/**
|
|
188
198
|
* Based on the state of the result, it picks the appropriate function to call and returns the result.
|
|
189
199
|
* @param success - The function to call if the result is a success.
|
|
@@ -209,22 +219,47 @@ const t = {
|
|
|
209
219
|
* @returns The combined result.
|
|
210
220
|
* @public
|
|
211
221
|
*/
|
|
212
|
-
combine: (e, s, r,
|
|
222
|
+
combine: (e, s, r, i) => u.match(
|
|
213
223
|
e,
|
|
214
|
-
(
|
|
224
|
+
(t) => u.match(
|
|
215
225
|
s,
|
|
216
|
-
(
|
|
217
|
-
(
|
|
226
|
+
(l) => u.success(r(t, l)),
|
|
227
|
+
(l) => u.failure(l)
|
|
218
228
|
),
|
|
219
|
-
(
|
|
229
|
+
(t) => u.match(
|
|
220
230
|
s,
|
|
221
231
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
222
|
-
(
|
|
223
|
-
(
|
|
232
|
+
(l) => u.failure(t),
|
|
233
|
+
(l) => u.failure(i(t, l))
|
|
224
234
|
)
|
|
225
|
-
)
|
|
235
|
+
),
|
|
236
|
+
/**
|
|
237
|
+
* Compares two results for equality.
|
|
238
|
+
* @param r1 - The first result.
|
|
239
|
+
* @param r2 - The second result.
|
|
240
|
+
* @param options - The options to use for comparison. By default, uses strict equality.
|
|
241
|
+
* @returns `true` if the results are equal, `false` otherwise.
|
|
242
|
+
*/
|
|
243
|
+
equals: (e, s, r = {
|
|
244
|
+
valueEquals: (i, t) => i === t,
|
|
245
|
+
errorEquals: (i, t) => i === t
|
|
246
|
+
}) => e.type === "Success" && s.type === "Success" ? r.valueEquals(e.value, s.value) : e.type === "Failure" && s.type === "Failure" ? r.errorEquals(e.error, s.error) : !1,
|
|
247
|
+
/**
|
|
248
|
+
* Combines multiple results into a single result.
|
|
249
|
+
* @param results - The results to combine.
|
|
250
|
+
* @returns A single result that is a success if all the input results are successes, otherwise a failure.
|
|
251
|
+
*/
|
|
252
|
+
all: (e) => {
|
|
253
|
+
const s = [];
|
|
254
|
+
for (const r of e)
|
|
255
|
+
if (u.isSuccess(r))
|
|
256
|
+
s.push(r.value);
|
|
257
|
+
else
|
|
258
|
+
return r;
|
|
259
|
+
return u.success(s);
|
|
260
|
+
}
|
|
226
261
|
};
|
|
227
262
|
export {
|
|
228
263
|
u as R,
|
|
229
|
-
|
|
264
|
+
a as V
|
|
230
265
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=require("./async-result.cjs"),l={valid:{type:"valid"},invalid(e){return{type:"invalid",error:e}},isValid(e){return e.type==="valid"},isInvalid(e){return e.type==="invalid"},match:(e,s,r)=>l.isValid(e)?s():r(e.error),toResult:(e,s)=>l.match(e,()=>u.success(s),r=>u.failure(r)),whenValid:(e,s)=>(l.isValid(e)&&s(),e),whenInvalid:(e,s)=>(l.isInvalid(e)&&s(e.error),e)},u={success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},map:(e,s)=>e.type==="Success"?u.success(s(e.value)):e,flatMap:(e,s)=>e.type==="Success"?s(e.value):e,toAsync(e){return u.match(e,s=>c.AsyncResult.success(s),s=>c.AsyncResult.failure(s))},toValidation(e){return u.match(e,()=>l.valid,s=>l.invalid(s))},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},getUnsafe:e=>{if(u.isSuccess(e))return e.value;throw e.error},match:(e,s,r)=>u.isSuccess(e)?s(e.value):r(e.error),whenSuccess:(e,s)=>(u.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(u.isFailure(e)&&s(e.error),e),combine:(e,s,r,i)=>u.match(e,t=>u.match(s,a=>u.success(r(t,a)),a=>u.failure(a)),t=>u.match(s,a=>u.failure(t),a=>u.failure(i(t,a)))),equals:(e,s,r={valueEquals:(i,t)=>i===t,errorEquals:(i,t)=>i===t})=>e.type==="Success"&&s.type==="Success"?r.valueEquals(e.value,s.value):e.type==="Failure"&&s.type==="Failure"?r.errorEquals(e.error,s.error):!1,all:e=>{const s=[];for(const r of e)if(u.isSuccess(r))s.push(r.value);else return r;return u.success(s)}};exports.Result=u;exports.Validation=l;
|
package/result.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./async-result.cjs");const e=require("./result-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./async-result.cjs");const e=require("./result-CdwVhaAc.cjs");exports.Result=e.Result;
|
package/result.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AsyncResult } from './async-result';
|
|
2
2
|
import { Maybe } from './domain';
|
|
3
3
|
import { Validation } from './validation';
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Represents a successful result.
|
|
7
6
|
* @typeParam V - The type of the value.
|
|
@@ -127,6 +126,12 @@ export declare const Result: {
|
|
|
127
126
|
* @public
|
|
128
127
|
*/
|
|
129
128
|
getOrUndefined<V, E>(r: Result<V, E>): Maybe<V>;
|
|
129
|
+
/**
|
|
130
|
+
* Gets the value of a `Result` if it is a `Success`, otherwise it throws the error contained in the `Failure`.
|
|
131
|
+
* @param r - The `Result` to get the value from.
|
|
132
|
+
* @returns The value of the `Result` if it is a `Success`.
|
|
133
|
+
*/
|
|
134
|
+
getUnsafe: <V, E>(r: Result<V, E>) => V;
|
|
130
135
|
/**
|
|
131
136
|
* Based on the state of the result, it picks the appropriate function to call and returns the result.
|
|
132
137
|
* @param success - The function to call if the result is a success.
|
|
@@ -153,4 +158,21 @@ export declare const Result: {
|
|
|
153
158
|
* @public
|
|
154
159
|
*/
|
|
155
160
|
combine: <V, E>(r1: Result<V, E>, r2: Result<V, E>, combineV: (v1: V, v2: V) => V, combineE: (e1: E, e2: E) => E) => Result<V, E>;
|
|
161
|
+
/**
|
|
162
|
+
* Compares two results for equality.
|
|
163
|
+
* @param r1 - The first result.
|
|
164
|
+
* @param r2 - The second result.
|
|
165
|
+
* @param options - The options to use for comparison. By default, uses strict equality.
|
|
166
|
+
* @returns `true` if the results are equal, `false` otherwise.
|
|
167
|
+
*/
|
|
168
|
+
equals: <V, E>(r1: Result<V, E>, r2: Result<V, E>, options?: {
|
|
169
|
+
valueEquals: (v1: V, v2: V) => boolean;
|
|
170
|
+
errorEquals: (e1: E, e2: E) => boolean;
|
|
171
|
+
}) => boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Combines multiple results into a single result.
|
|
174
|
+
* @param results - The results to combine.
|
|
175
|
+
* @returns A single result that is a success if all the input results are successes, otherwise a failure.
|
|
176
|
+
*/
|
|
177
|
+
all: <V, E>(results: Result<V, E>[]) => Result<V[], E>;
|
|
156
178
|
};
|
package/result.js
CHANGED
package/validation.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./result-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./result-CdwVhaAc.cjs");exports.Validation=i.Validation;
|
package/validation.d.ts
CHANGED
package/validation.js
CHANGED
package/result-DzdZiQoR.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const a=require("./async-result.cjs"),i={valid:{type:"valid"},invalid(e){return{type:"invalid",error:e}},isValid(e){return e.type==="valid"},isInvalid(e){return e.type==="invalid"},match:(e,s,t)=>i.isValid(e)?s():t(e.error),toResult:(e,s)=>i.match(e,()=>u.success(s),t=>u.failure(t)),whenValid:(e,s)=>(i.isValid(e)&&s(),e),whenInvalid:(e,s)=>(i.isInvalid(e)&&s(e.error),e)},u={success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},map:(e,s)=>e.type==="Success"?u.success(s(e.value)):e,flatMap:(e,s)=>e.type==="Success"?s(e.value):e,toAsync(e){return u.match(e,s=>a.AsyncResult.success(s),s=>a.AsyncResult.failure(s))},toValidation(e){return u.match(e,()=>i.valid,s=>i.invalid(s))},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},match:(e,s,t)=>u.isSuccess(e)?s(e.value):t(e.error),whenSuccess:(e,s)=>(u.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(u.isFailure(e)&&s(e.error),e),combine:(e,s,t,c)=>u.match(e,l=>u.match(s,r=>u.success(t(l,r)),r=>u.failure(r)),l=>u.match(s,r=>u.failure(l),r=>u.failure(c(l,r))))};exports.Result=u;exports.Validation=i;
|