@tempots/std 0.12.0 → 0.14.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 +35 -67
- package/array.js +108 -167
- package/async-result.d.ts +15 -15
- package/bigint.cjs +1 -1
- package/bigint.d.ts +20 -20
- package/bigint.js +37 -78
- package/boolean.cjs +1 -1
- package/boolean.d.ts +5 -5
- package/boolean.js +10 -19
- package/equal.cjs +1 -1
- package/equal.d.ts +3 -3
- package/equal.js +31 -37
- package/error.cjs +1 -0
- package/error.d.ts +24 -0
- package/error.js +26 -0
- package/function.cjs +1 -1
- package/function.d.ts +3 -20
- package/function.js +7 -28
- package/index.cjs +1 -1
- package/index.d.ts +1 -0
- package/index.js +155 -159
- package/number.cjs +1 -1
- package/number.d.ts +25 -25
- package/number.js +39 -97
- package/object.cjs +1 -1
- package/object.d.ts +6 -6
- package/object.js +12 -27
- package/package.json +15 -1
- package/promise.cjs +1 -0
- package/promise.d.ts +11 -0
- package/promise.js +9 -0
- package/regexp.cjs +1 -1
- package/regexp.d.ts +1 -1
- package/regexp.js +8 -8
- package/result.d.ts +8 -8
- package/string.cjs +4 -4
- package/string.d.ts +337 -112
- package/string.js +193 -389
- package/validation.d.ts +7 -7
package/array.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./object.cjs")
|
|
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.uniqueByPredicate=W;exports.uniquePrimitives=V;
|
package/array.d.ts
CHANGED
|
@@ -8,10 +8,9 @@ import { Compare, Maybe, Nothing, Primitive } from './domain';
|
|
|
8
8
|
* @param arr - The input array.
|
|
9
9
|
* @param f - The function to apply to each element.
|
|
10
10
|
* @returns The new array with the results of applying the function to each element.
|
|
11
|
-
* @category manipulation
|
|
12
11
|
* @public
|
|
13
12
|
*/
|
|
14
|
-
export declare
|
|
13
|
+
export declare const mapArray: <A, B>(arr: A[], f: (a: A, index: number) => B) => B[];
|
|
15
14
|
/**
|
|
16
15
|
* Applies a mapping function to each element of an array and flattens the result.
|
|
17
16
|
*
|
|
@@ -20,29 +19,26 @@ export declare function mapArray<A, B>(arr: A[], f: (a: A, index: number) => B):
|
|
|
20
19
|
* @returns A new array with the flattened result of applying the mapping function to each element of the input array.
|
|
21
20
|
* @typeParam A - The type of the elements in the input array.
|
|
22
21
|
* @typeParam B - The type of the elements in the resulting flattened array.
|
|
23
|
-
* @category manipulation
|
|
24
22
|
* @public
|
|
25
23
|
*/
|
|
26
|
-
export declare
|
|
24
|
+
export declare const flatMapArray: <A, B>(arr: A[], f: (a: A) => B[]) => B[];
|
|
27
25
|
/**
|
|
28
26
|
* Returns the first element of an array, or `undefined` if the array is empty.
|
|
29
27
|
*
|
|
30
28
|
* @param arr - The input array.
|
|
31
29
|
* @returns The first element of the array, or `undefined` if the array is empty.
|
|
32
30
|
* @typeParam A - The type of elements in the array.
|
|
33
|
-
* @category access
|
|
34
31
|
* @public
|
|
35
32
|
*/
|
|
36
|
-
export declare
|
|
33
|
+
export declare const arrayHead: <A>(arr: A[]) => Maybe<A>;
|
|
37
34
|
/**
|
|
38
35
|
* Returns a new array containing all elements of the input array except for the first element.
|
|
39
36
|
*
|
|
40
37
|
* @param arr - The input array.
|
|
41
38
|
* @returns A new array containing all elements of the input array except for the first element.
|
|
42
|
-
* @category access
|
|
43
39
|
* @public
|
|
44
40
|
*/
|
|
45
|
-
export declare
|
|
41
|
+
export declare const arrayTail: <A>(arr: A[]) => A[];
|
|
46
42
|
/**
|
|
47
43
|
* Checks if two arrays are equal based on a custom equality function.
|
|
48
44
|
*
|
|
@@ -51,28 +47,25 @@ export declare function arrayTail<A>(arr: A[]): A[];
|
|
|
51
47
|
* @param b - The second array.
|
|
52
48
|
* @param equality - The custom equality function to compare elements.
|
|
53
49
|
* @returns Returns `true` if the arrays are equal, `false` otherwise.
|
|
54
|
-
* @category comparison
|
|
55
50
|
* @public
|
|
56
51
|
*/
|
|
57
|
-
export declare
|
|
52
|
+
export declare const areArraysEqual: <T>(a: T[], b: T[], equality: (a: T, b: T) => boolean) => boolean;
|
|
58
53
|
/**
|
|
59
54
|
* Checks if an array is empty.
|
|
60
55
|
*
|
|
61
56
|
* @param arr - The array to check.
|
|
62
57
|
* @returns `true` if the array is empty, `false` otherwise.
|
|
63
|
-
* @category query
|
|
64
58
|
* @public
|
|
65
59
|
*/
|
|
66
|
-
export declare
|
|
60
|
+
export declare const isArrayEmpty: <T>(arr: T[]) => arr is [];
|
|
67
61
|
/**
|
|
68
62
|
* Checks if an array has values.
|
|
69
63
|
*
|
|
70
64
|
* @param arr - The array to check.
|
|
71
65
|
* @returns `true` if the array has values, `false` otherwise.
|
|
72
|
-
* @category query
|
|
73
66
|
* @public
|
|
74
67
|
*/
|
|
75
|
-
export declare
|
|
68
|
+
export declare const arrayHasValues: <T>(arr: T[]) => arr is [T, ...T[]];
|
|
76
69
|
/**
|
|
77
70
|
* Filters the elements of an array based on a predicate function.
|
|
78
71
|
*
|
|
@@ -80,10 +73,9 @@ export declare function arrayHasValues<T>(arr: T[]): arr is [T, ...T[]];
|
|
|
80
73
|
* @param arr - The array to filter.
|
|
81
74
|
* @param predicate - The predicate function used to filter the elements.
|
|
82
75
|
* @returns The filtered array.
|
|
83
|
-
* @category manipulation
|
|
84
76
|
* @public
|
|
85
77
|
*/
|
|
86
|
-
export declare
|
|
78
|
+
export declare const filterArray: <T>(arr: T[], predicate: (v: T) => boolean) => T[];
|
|
87
79
|
/**
|
|
88
80
|
* Applies a mapping function to each element of an array and returns a new array
|
|
89
81
|
* containing the mapped values, excluding any `null` or `undefined` values.
|
|
@@ -93,30 +85,27 @@ export declare function filterArray<T>(arr: T[], predicate: (v: T) => boolean):
|
|
|
93
85
|
* @param arr - The input array.
|
|
94
86
|
* @param f - The mapping function to apply to each element.
|
|
95
87
|
* @returns The new array containing the mapped values.
|
|
96
|
-
* @category manipulation
|
|
97
88
|
* @public
|
|
98
89
|
*/
|
|
99
|
-
export declare
|
|
90
|
+
export declare const filterMapArray: <A, B>(arr: A[], f: (a: A, index: number) => Maybe<B>) => B[];
|
|
100
91
|
/**
|
|
101
92
|
* Filters out null and undefined values from an array.
|
|
102
93
|
*
|
|
103
94
|
* @typeParam T - The type of elements in the array.
|
|
104
95
|
* @param arr - The array to filter.
|
|
105
96
|
* @returns The filtered array.
|
|
106
|
-
* @category manipulation
|
|
107
97
|
* @public
|
|
108
98
|
*/
|
|
109
|
-
export declare
|
|
99
|
+
export declare const filterNullsFromArray: <T>(arr: Array<T | Nothing>) => T[];
|
|
110
100
|
/**
|
|
111
101
|
* Flattens a two-dimensional array into a one-dimensional array.
|
|
112
102
|
*
|
|
113
103
|
* @param arr - The two-dimensional array to flatten.
|
|
114
104
|
* @returns The flattened one-dimensional array.
|
|
115
105
|
* @typeParam T - The type of elements in the array.
|
|
116
|
-
* @category manipulation
|
|
117
106
|
* @public
|
|
118
107
|
*/
|
|
119
|
-
export declare
|
|
108
|
+
export declare const flattenArray: <T>(arr: T[][]) => T[];
|
|
120
109
|
/**
|
|
121
110
|
* Applies a function to each element of an array, accumulating the result from left to right.
|
|
122
111
|
*
|
|
@@ -126,10 +115,9 @@ export declare function flattenArray<T>(arr: T[][]): T[];
|
|
|
126
115
|
* @param f - The function to apply to each element.
|
|
127
116
|
* @param b - The initial value of the accumulator.
|
|
128
117
|
* @returns The accumulated result.
|
|
129
|
-
* @category manipulation
|
|
130
118
|
* @public
|
|
131
119
|
*/
|
|
132
|
-
export declare
|
|
120
|
+
export declare const foldLeftArray: <T, B>(arr: T[], f: (acc: B, curr: T) => B, b: B) => B;
|
|
133
121
|
/**
|
|
134
122
|
* Checks if all elements in an array satisfy a given predicate.
|
|
135
123
|
*
|
|
@@ -137,10 +125,9 @@ export declare function foldLeftArray<T, B>(arr: T[], f: (acc: B, curr: T) => B,
|
|
|
137
125
|
* @param predicate - The predicate function to apply to each element.
|
|
138
126
|
* @returns `true` if all elements satisfy the predicate, `false` otherwise.
|
|
139
127
|
* @typeParam T - The type of elements in the array.
|
|
140
|
-
* @category query
|
|
141
128
|
* @public
|
|
142
129
|
*/
|
|
143
|
-
export declare
|
|
130
|
+
export declare const allElements: <T>(arr: T[], predicate: (v: T) => boolean) => boolean;
|
|
144
131
|
/**
|
|
145
132
|
* Checks if any element in the array satisfies the given predicate.
|
|
146
133
|
*
|
|
@@ -148,30 +135,27 @@ export declare function allElements<T>(arr: T[], predicate: (v: T) => boolean):
|
|
|
148
135
|
* @param predicate - The predicate function to apply to each element.
|
|
149
136
|
* @returns `true` if any element satisfies the predicate, `false` otherwise.
|
|
150
137
|
* @typeParam T - The type of elements in the array.
|
|
151
|
-
* @category query
|
|
152
138
|
* @public
|
|
153
139
|
*/
|
|
154
|
-
export declare
|
|
140
|
+
export declare const anyElement: <T>(arr: T[], predicate: (v: T) => boolean) => boolean;
|
|
155
141
|
/**
|
|
156
142
|
* Applies a function to each element in an array.
|
|
157
143
|
*
|
|
158
144
|
* @typeParam T - The type of elements in the array.
|
|
159
145
|
* @param arr - The array to iterate over.
|
|
160
146
|
* @param f - The function to apply to each element.
|
|
161
|
-
* @category effect
|
|
162
147
|
* @public
|
|
163
148
|
*/
|
|
164
|
-
export declare
|
|
149
|
+
export declare const forEachElement: <T>(arr: T[], f: (v: T) => void) => void;
|
|
165
150
|
/**
|
|
166
151
|
* Concatenates multiple arrays into a single array.
|
|
167
152
|
*
|
|
168
153
|
* @param arrs - The arrays to concatenate.
|
|
169
154
|
* @returns The concatenated array.
|
|
170
155
|
* @typeParam A - The type of elements in the arrays.
|
|
171
|
-
* @category manipulation
|
|
172
156
|
* @public
|
|
173
157
|
*/
|
|
174
|
-
export declare
|
|
158
|
+
export declare const concatArrays: <A>(...arrs: A[][]) => A[];
|
|
175
159
|
/**
|
|
176
160
|
* Compares two arrays based on their lengths and element values.
|
|
177
161
|
*
|
|
@@ -179,12 +163,11 @@ export declare function concatArrays<A>(...arrs: A[][]): A[];
|
|
|
179
163
|
* @param a - The first array to compare.
|
|
180
164
|
* @param b - The second array to compare.
|
|
181
165
|
* @param comparef - The compare function to use for comparing the elements of the arrays.
|
|
182
|
-
* @param shorterFirst -
|
|
166
|
+
* @param shorterFirst - Specifies whether shorter arrays should be considered smaller. Defaults to true.
|
|
183
167
|
* @returns A compare function that can be used to compare arrays.
|
|
184
|
-
* @category comparison
|
|
185
168
|
* @public
|
|
186
169
|
*/
|
|
187
|
-
export declare
|
|
170
|
+
export declare const compareArrays: <A>(a: A[], b: A[], comparef: Compare<A>, shorterFirst?: boolean) => number;
|
|
188
171
|
/**
|
|
189
172
|
* Sorts an array in place using the provided compare function.
|
|
190
173
|
*
|
|
@@ -192,30 +175,27 @@ export declare function compareArrays<A>(a: A[], b: A[], comparef: Compare<A>, s
|
|
|
192
175
|
* @param arr - The array to be sorted.
|
|
193
176
|
* @param compare - The compare function used to determine the order of the elements.
|
|
194
177
|
* @returns The sorted array.
|
|
195
|
-
* @category manipulation
|
|
196
178
|
* @public
|
|
197
179
|
*/
|
|
198
|
-
export declare
|
|
180
|
+
export declare const sortArray: <A>(arr: A[], compare: Compare<A>) => A[];
|
|
199
181
|
/**
|
|
200
182
|
* Generates an array of values by applying a function to each index.
|
|
201
183
|
*
|
|
202
184
|
* @param length - The length of the resulting array.
|
|
203
185
|
* @param f - The function to apply to each index. It takes the index as a parameter and returns the corresponding value.
|
|
204
186
|
* @returns An array of values generated by applying the function to each index.
|
|
205
|
-
* @category creation
|
|
206
187
|
* @public
|
|
207
188
|
*/
|
|
208
|
-
export declare
|
|
189
|
+
export declare const generateArray: <A>(length: number, f: (index: number) => A) => A[];
|
|
209
190
|
/**
|
|
210
191
|
* Generates an array of numbers in a specified range.
|
|
211
192
|
*
|
|
212
193
|
* @param length - The length of the array to generate.
|
|
213
194
|
* @param startAt - The starting value of the range. Default is 0.
|
|
214
195
|
* @returns An array of numbers in the specified range.
|
|
215
|
-
* @category creation
|
|
216
196
|
* @public
|
|
217
197
|
*/
|
|
218
|
-
export declare
|
|
198
|
+
export declare const generateSequenceArray: (length: number, startAt?: number) => number[];
|
|
219
199
|
/**
|
|
220
200
|
* Creates a new array with the specified length and fills it with the provided value.
|
|
221
201
|
*
|
|
@@ -223,20 +203,18 @@ export declare function generateSequenceArray(length: number, startAt?: number):
|
|
|
223
203
|
* @param length - The length of the new array.
|
|
224
204
|
* @param value - The value to fill the array with.
|
|
225
205
|
* @returns A new array filled with the specified value.
|
|
226
|
-
* @category creation
|
|
227
206
|
* @public
|
|
228
207
|
*/
|
|
229
|
-
export declare
|
|
208
|
+
export declare const createFilledArray: <A>(length: number, value: A) => A[];
|
|
230
209
|
/**
|
|
231
210
|
* Returns an array containing only the distinct primitive values from the input array.
|
|
232
211
|
*
|
|
233
212
|
* @typeParam T - The type of the input array elements.
|
|
234
213
|
* @param values - The input array.
|
|
235
214
|
* @returns An array containing only the distinct primitive values from the input array.
|
|
236
|
-
* @category manipulation
|
|
237
215
|
* @public
|
|
238
216
|
*/
|
|
239
|
-
export declare
|
|
217
|
+
export declare const uniquePrimitives: <T extends Primitive>(values: T[]) => T[];
|
|
240
218
|
/**
|
|
241
219
|
* Returns an array of distinct elements from the input array based on the provided predicate.
|
|
242
220
|
*
|
|
@@ -244,10 +222,9 @@ export declare function uniquePrimitives<T extends Primitive>(values: T[]): T[];
|
|
|
244
222
|
* @param values - The input array.
|
|
245
223
|
* @param predicate - The predicate function used to determine uniqueness.
|
|
246
224
|
* @returns An array of distinct elements.
|
|
247
|
-
* @category manipulation
|
|
248
225
|
* @public
|
|
249
226
|
*/
|
|
250
|
-
export declare
|
|
227
|
+
export declare const uniqueByPredicate: <T>(values: T[], predicate: (a: T) => string) => T[];
|
|
251
228
|
/**
|
|
252
229
|
* Removes the first occurrence of an item from an array.
|
|
253
230
|
*
|
|
@@ -255,10 +232,9 @@ export declare function uniqueByPredicate<T>(values: T[], predicate: (a: T) => s
|
|
|
255
232
|
* @param arr - The array from which to remove the item.
|
|
256
233
|
* @param item - The item to remove from the array.
|
|
257
234
|
* @returns `true` if the item was found and removed, `false` otherwise.
|
|
258
|
-
* @category mutation
|
|
259
235
|
* @public
|
|
260
236
|
*/
|
|
261
|
-
export declare
|
|
237
|
+
export declare const removeOneFromArray: <A>(arr: A[], item: A) => boolean;
|
|
262
238
|
/**
|
|
263
239
|
* Removes all occurrences of an item from an array.
|
|
264
240
|
*
|
|
@@ -266,10 +242,9 @@ export declare function removeOneFromArray<A>(arr: A[], item: A): boolean;
|
|
|
266
242
|
* @param arr - The array from which to remove the item.
|
|
267
243
|
* @param item - The item to remove from the array.
|
|
268
244
|
* @returns `true` if at least one occurrence was found and removed, `false` otherwise.
|
|
269
|
-
* @category mutation
|
|
270
245
|
* @public
|
|
271
246
|
*/
|
|
272
|
-
export declare
|
|
247
|
+
export declare const removeAllFromArray: <A>(arr: A[], item: A) => boolean;
|
|
273
248
|
/**
|
|
274
249
|
* Removes the first occurrence in an array that satisfy the given predicate.
|
|
275
250
|
*
|
|
@@ -277,10 +252,9 @@ export declare function removeAllFromArray<A>(arr: A[], item: A): boolean;
|
|
|
277
252
|
* @param arr - The array from which elements will be removed.
|
|
278
253
|
* @param predicate - The predicate function used to determine which elements to remove.
|
|
279
254
|
* @returns `true` if at least one element was removed, `false` otherwise.
|
|
280
|
-
* @category mutation
|
|
281
255
|
* @public
|
|
282
256
|
*/
|
|
283
|
-
export declare
|
|
257
|
+
export declare const removeOneFromArrayByPredicate: <A>(arr: A[], predicate: (a: A) => boolean) => boolean;
|
|
284
258
|
/**
|
|
285
259
|
* Removes all occurrences in an array that satisfy the given predicate.
|
|
286
260
|
*
|
|
@@ -288,25 +262,23 @@ export declare function removeOneFromArrayByPredicate<A>(arr: A[], predicate: (a
|
|
|
288
262
|
* @param arr - The array from which elements will be removed.
|
|
289
263
|
* @param predicate - The predicate function used to determine which elements to remove.
|
|
290
264
|
* @returns `true` if at least one element was removed, `false` otherwise.
|
|
291
|
-
* @category mutation
|
|
292
265
|
* @public
|
|
293
266
|
*/
|
|
294
|
-
export declare
|
|
267
|
+
export declare const removeAllFromArrayByPredicate: <A>(arr: A[], predicate: (a: A) => boolean) => boolean;
|
|
295
268
|
/**
|
|
296
269
|
* Converts an IterableIterator to an array.
|
|
297
270
|
*
|
|
298
271
|
* @param it - The IterableIterator to convert.
|
|
299
272
|
* @returns An array containing the values from the IterableIterator.
|
|
300
|
-
* @category creation
|
|
301
273
|
* @public
|
|
302
274
|
*/
|
|
303
|
-
export declare
|
|
275
|
+
export declare const arrayOfIterableIterator: <A>(it: IterableIterator<A>) => A[];
|
|
304
276
|
/**
|
|
305
277
|
* Represents the different operations that can be performed on an array.
|
|
306
278
|
*
|
|
307
279
|
* @public
|
|
308
280
|
*/
|
|
309
|
-
export
|
|
281
|
+
export type ArrayDiffOperations<T> = {
|
|
310
282
|
removals: Array<{
|
|
311
283
|
at: number;
|
|
312
284
|
qt: number;
|
|
@@ -319,7 +291,7 @@ export interface ArrayDiffOperations<T> {
|
|
|
319
291
|
at: number;
|
|
320
292
|
values: T[];
|
|
321
293
|
}>;
|
|
322
|
-
}
|
|
294
|
+
};
|
|
323
295
|
/**
|
|
324
296
|
* Calculates the difference operations between two arrays based on a key function.
|
|
325
297
|
*
|
|
@@ -329,10 +301,9 @@ export interface ArrayDiffOperations<T> {
|
|
|
329
301
|
* @param to - The target array.
|
|
330
302
|
* @param getKey - The key function used to compare elements.
|
|
331
303
|
* @returns The difference operations between the two arrays.
|
|
332
|
-
* @category manipulation
|
|
333
304
|
* @public
|
|
334
305
|
*/
|
|
335
|
-
export declare
|
|
306
|
+
export declare const arrayDiffOperations: <T, K>(from: T[], to: T[], getKey: (v: T) => K) => ArrayDiffOperations<T>;
|
|
336
307
|
/**
|
|
337
308
|
* Applies a series of operations to an array and returns the modified array.
|
|
338
309
|
*
|
|
@@ -340,10 +311,9 @@ export declare function arrayDiffOperations<T, K>(from: T[], to: T[], getKey: (v
|
|
|
340
311
|
* @param operations - The operations to apply.
|
|
341
312
|
* @param start - The initial array.
|
|
342
313
|
* @returns The modified array after applying the operations.
|
|
343
|
-
* @category manipulation
|
|
344
314
|
* @public
|
|
345
315
|
*/
|
|
346
|
-
export declare
|
|
316
|
+
export declare const applyArrayDiffOperations: <T>(operations: ArrayDiffOperations<T>, start: T[]) => T[];
|
|
347
317
|
/**
|
|
348
318
|
* Joins an array of values into a string using a conjunction and separator.
|
|
349
319
|
*
|
|
@@ -351,10 +321,9 @@ export declare function applyArrayDiffOperations<T>(operations: ArrayDiffOperati
|
|
|
351
321
|
* @param conjunction - The conjunction to use between the second-to-last and last value. Default is ' and '.
|
|
352
322
|
* @param separator - The separator to use between each value. Default is ', '.
|
|
353
323
|
* @returns The joined string.
|
|
354
|
-
* @category transformation
|
|
355
324
|
* @public
|
|
356
325
|
*/
|
|
357
|
-
export declare
|
|
326
|
+
export declare const joinArrayWithConjunction: <A>(arr: A[], conjunction?: string, separator?: string) => string;
|
|
358
327
|
/**
|
|
359
328
|
* Assigns ranks to the elements in the array based on the provided compare function.
|
|
360
329
|
* The ranks are assigned in ascending order, with the lowest value receiving a rank of 0.
|
|
@@ -365,7 +334,6 @@ export declare function joinArrayWithConjunction<A>(arr: A[], conjunction?: stri
|
|
|
365
334
|
* @param compare - The compare function used to determine the order of elements.
|
|
366
335
|
* @param incrementDuplicates - Whether to increment the rank of duplicate values.
|
|
367
336
|
* @returns An array of ranks corresponding to the elements in the input array.
|
|
368
|
-
* @category transformation
|
|
369
337
|
* @public
|
|
370
338
|
*/
|
|
371
|
-
export declare
|
|
339
|
+
export declare const rankArray: <T>(array: T[], compare: (a: T, b: T) => number, incrementDuplicates?: boolean) => number[];
|