@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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./maybe.cjs"),M=require("./object.cjs");function q(t,e){return Array.from({length:t.length},(n,r)=>e(t[r],r))}function E(t,e){const n=[];for(let r=0;r<t.length;r++){const i=e(t[r],r);i!=null&&n.push(i)}return n}function j(t,e){const n=[];for(const r of t)n.push(...e(r));return n}function w(t){return t.length>0?y.Maybe.just(t[0]):y.Maybe.nothing}function A(t){return t.slice(1)}function b(t,e,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function N(t){return function(e,n){return b(e,n,t)}}function O(t){return t.length===0}function B(t){return t.length>0}function k(t,e){const n=[];for(const r of t)e(r)&&n.push(r);return n}function I(t,e){const n=[];for(let r=0;r<t.length;r++){const i=e(t[r],r);i!=null&&n.push(i)}return n}function P(t){return k(t,e=>e!=null)}function _(t){return[].concat(...t)}function S(t,e,n){for(const r of t)n=e(n,r);return n}function C(t,e){for(const n of t)if(!e(n))return!1;return!0}function R(t,e){for(const n of t)if(e(n))return!0;return!1}function T(t,e){for(const n of t)e(n)}function $(...t){return[].concat(...t)}function D(t,e=!0){return function(n,r){if(n.length<r.length)return-1*(e?1:-1);if(n.length>r.length)return 1*(e?1:-1);for(let i=0;i<n.length;i++){const u=t(n[i],r[i]);if(u!==0)return u}return 0}}function L(t,e){return e.slice().sort(t)}function d(t,e){return Array.from({length:t},(n,r)=>e(r))}function V(t,e=0){return d(t,n=>e+n)}function W(t,e){return d(t,()=>e)}function z(t){return Array.from(new Set(t))}function G(t,e){const n={};return t.forEach(r=>{n[e(r)]=r}),M.keys(n).map(r=>n[r])}function H(t,e){const n=t.indexOf(e);return n<0?!1:(t.splice(n,1),!0)}function J(t,e){const n=t.findIndex(e);return n<0?!1:(t.splice(n,1),!0)}function Q(t){const e=[];for(let n=t.next();!(n.done??!1);n=t.next())e.push(n.value);return e}function U(t,e,n){const r={removals:[],swaps:[],inserts:[]},{removals:i,inserts:u,swaps:a}=r,l=new Map;e.forEach((o,f)=>l.set(n(o),f));const s=t.map((o,f)=>[o,f]).filter(([o])=>!l.has(n(o))).map(([o,f])=>f);for(let o=s.length-1;o>=0;o--){const f=s[o],c=i.length>0?i[i.length-1]:void 0;c!=null&&c.at===f+1?(c.at--,c.qt++):i.push({at:f,qt:1})}const h=new Map;t.forEach((o,f)=>h.set(n(o),f));const g=e.map((o,f)=>[o,f]).filter(([o])=>!h.has(n(o))).map(([o,f])=>f);for(const o of g){const f=u.length>0?u[u.length-1]:void 0;f!=null&&f.at+f.values.length===o?f.values.push(e[o]):u.push({at:o,values:[e[o]]})}const p=t.filter((o,f)=>!s.includes(f)),m=new Map;for(let o=0;o<p.length;o++)m.set(n(p[o]),o);const v=e.filter((o,f)=>!g.includes(f));for(let o=0;o<v.length;o++){const f=n(v[o]),c=m.get(f);if(c==null||o===c)continue;const x=n(p[o]);m.delete(x),a.push({from:o,to:c})}return r}function X(t,e){const n=[...e];for(const{at:r,qt:i}of t.removals)n.splice(r,i);for(const{from:r,to:i}of t.swaps){const u=n[i];n[i]=n[r],n[r]=u}for(const r of t.inserts)n.splice(r.at,0,...r.values);return n}function Y(t,e=" and ",n=", "){return t.length===0?"":t.length===1?String(t[0]):`${t.slice(0,-1).join(n)}${e}${String(t[t.length-1])}`}function Z(t,e,n=!0){const r=t.map((l,s)=>[l,s]);r.sort((l,s)=>e(l[0],s[0]));const i=new Array(r.length);let u=0,a=r[0][0];for(let l=0;l<r.length;l++){const[s,h]=r[l];e(s,a)!==0&&(u=l,a=s),i[h]=u,n&&u++}return i}exports.all=C;exports.any=R;exports.applyOperations=X;exports.concat=$;exports.diffOperations=U;exports.distinctByPredicate=G;exports.distinctPrimitive=z;exports.each=T;exports.equals=b;exports.fill=W;exports.filter=k;exports.filterMap=I;exports.filterNulls=P;exports.flatMap=j;exports.flatten=_;exports.foldLeft=S;exports.hasValues=B;exports.head=w;exports.isEmpty=O;exports.joinWithConjunction=Y;exports.makeCompare=D;exports.makeEquals=N;exports.map=q;exports.mapNotNull=E;exports.numbersRange=V;exports.ofIterableIterator=Q;exports.range=d;exports.rank=Z;exports.remove=H;exports.removeByPredicate=J;exports.sort=L;exports.tail=A;
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 './maybe';
2
- import { Compare, Primitive } from './domain';
1
+ import { Compare, Maybe, Nothing, Primitive } from './domain';
3
2
 
4
- export declare function map<A, B>(arr: A[], f: (a: A, index: number) => B): B[];
5
- export declare function mapNotNull<A, B>(arr: A[], f: (a: A, index: number) => B | null | undefined): B[];
6
- export declare function flatMap<A, B>(arr: A[], f: (a: A) => B[]): B[];
7
- export declare function head<A>(arr: A[]): Maybe<A>;
8
- export declare function tail<A>(arr: A[]): A[];
9
- export declare function equals<T>(a: T[], b: T[], equality: (a: T, b: T) => boolean): boolean;
10
- export declare function makeEquals<T>(equality: (a: T, b: T) => boolean): (a: T[], b: T[]) => boolean;
11
- export declare function isEmpty<T>(arr: T[]): arr is [];
12
- export declare function hasValues<T>(arr: T[]): arr is [T, ...T[]];
13
- export declare function filter<T>(arr: T[], predicate: (v: T) => boolean): T[];
14
- export declare function filterMap<A, B>(arr: A[], f: (a: A, index: number) => Maybe<B>): B[];
15
- export declare function filterNulls<T>(arr: Array<T | null | undefined>): T[];
16
- export declare function flatten<T>(arr: T[][]): T[];
17
- export declare function foldLeft<T, B>(arr: T[], f: (acc: B, curr: T) => B, b: B): B;
18
- export declare function all<T>(arr: T[], predicate: (v: T) => boolean): boolean;
19
- export declare function any<T>(arr: T[], predicate: (v: T) => boolean): boolean;
20
- export declare function each<T>(arr: T[], f: (v: T) => void): void;
21
- export declare function concat<A>(...arrs: A[][]): A[];
22
- export declare function makeCompare<A>(comparef: Compare<A>, shorterFirst?: boolean): (a: A[], b: A[]) => number;
23
- export declare function sort<A>(compare: Compare<A>, arr: A[]): A[];
24
- export declare function range<A>(length: number, f: (index: number) => A): A[];
25
- export declare function numbersRange(length: number, startAt?: number): number[];
26
- export declare function fill<A>(length: number, value: A): A[];
27
- export declare function distinctPrimitive<T extends Primitive>(values: T[]): T[];
28
- export declare function distinctByPredicate<T>(values: T[], predicate: (a: T) => string): T[];
29
- export declare function remove<A>(arr: A[], item: A): boolean;
30
- export declare function removeByPredicate<A>(arr: A[], predicate: (a: A) => boolean): boolean;
31
- export declare function ofIterableIterator<A>(it: IterableIterator<A>): A[];
32
- export interface DiffOperations<T> {
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
- export declare function diffOperations<T, K>(from: T[], to: T[], getKey: (v: T) => K): DiffOperations<T>;
47
- export declare function applyOperations<T>(operations: DiffOperations<T>, start: T[]): T[];
48
- export declare function joinWithConjunction<A>(arr: A[], conjunction?: string, separator?: string): string;
49
- export declare function rank<T>(array: T[], compare: (a: T, b: T) => number, incrementDuplicates?: boolean): number[];
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[];