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