pepka 1.12.2 → 1.13.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/dist/bundle.cjs +34 -18
- package/dist/bundle.d.ts +16 -4
- package/dist/bundle.mjs +33 -19
- package/package.json +1 -1
- package/src/common.ts +21 -10
- package/src/internal.ts +1 -2
- package/src/quick.ts +11 -8
- package/src/safe.ts +2 -5
package/dist/bundle.cjs
CHANGED
|
@@ -69,8 +69,7 @@ function curry3(fn) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const length = (s) => s.length;
|
|
72
|
-
const
|
|
73
|
-
const is_typed_arr = (t) => typed_arr_re.test(t);
|
|
72
|
+
const is_typed_arr = (x) => ArrayBuffer.isView(x);
|
|
74
73
|
/** @param start string | any[] @param s string | any[] */
|
|
75
74
|
const startsWithWith = (comparator) => curry2((start, s) => {
|
|
76
75
|
const len_start = length(start);
|
|
@@ -144,20 +143,32 @@ const type = (s) => {
|
|
|
144
143
|
const typeIs = curry2((t, s) => type(s) === t);
|
|
145
144
|
const eq = curry2((a, b) => a === b);
|
|
146
145
|
const equals = curry2((a, b) => {
|
|
146
|
+
if (a === b)
|
|
147
|
+
return true;
|
|
147
148
|
const typea = type(a);
|
|
148
|
-
|
|
149
|
+
const ta = is_typed_arr(a);
|
|
150
|
+
if (eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array') || ta)) {
|
|
151
|
+
if (ta) {
|
|
152
|
+
if (typea === 'Buffer')
|
|
153
|
+
return a.equals(b);
|
|
154
|
+
const len = length(a);
|
|
155
|
+
if (len !== length(b))
|
|
156
|
+
return false;
|
|
157
|
+
for (let i = 0; i < len; i++)
|
|
158
|
+
if (a[i] !== b[i])
|
|
159
|
+
return false;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
149
162
|
if (isNull(a) || isNull(b))
|
|
150
163
|
return eq(a, b);
|
|
151
|
-
if (eq(a, b))
|
|
152
|
-
return true;
|
|
153
164
|
for (const v of [a, b])
|
|
154
165
|
for (const k in v)
|
|
155
|
-
if (!(
|
|
156
|
-
!(
|
|
166
|
+
if (!(v === b && (k in a)) &&
|
|
167
|
+
!(v === a && (k in b) && equals(a[k], b[k])))
|
|
157
168
|
return false;
|
|
158
169
|
return true;
|
|
159
170
|
}
|
|
160
|
-
return
|
|
171
|
+
return false;
|
|
161
172
|
});
|
|
162
173
|
const includes = curry2((s, ss) => {
|
|
163
174
|
if (isStr(ss))
|
|
@@ -169,6 +180,9 @@ const includes = curry2((s, ss) => {
|
|
|
169
180
|
return false;
|
|
170
181
|
}
|
|
171
182
|
});
|
|
183
|
+
const always = (s) => () => s;
|
|
184
|
+
const identity = (s) => s;
|
|
185
|
+
const trim = (s) => s.trim();
|
|
172
186
|
|
|
173
187
|
const { min } = Math;
|
|
174
188
|
const z = 0;
|
|
@@ -341,23 +355,26 @@ const rmel = (index, xs) => {
|
|
|
341
355
|
return xs;
|
|
342
356
|
};
|
|
343
357
|
const seen = new Set();
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
let size = length(xs);
|
|
358
|
+
const quniqWith = curry2((getter, xs) => {
|
|
359
|
+
let size = length(xs), cur;
|
|
347
360
|
for (let i = z; i < size; i++) {
|
|
348
361
|
const x = xs[i];
|
|
349
|
-
|
|
362
|
+
cur = getter(x);
|
|
363
|
+
if (seen.has(cur)) {
|
|
350
364
|
rmel(i, xs);
|
|
351
365
|
size--;
|
|
352
366
|
i--;
|
|
353
367
|
}
|
|
354
368
|
else
|
|
355
|
-
seen.add(
|
|
369
|
+
seen.add(cur);
|
|
356
370
|
}
|
|
371
|
+
seen.clear();
|
|
357
372
|
return xs;
|
|
358
|
-
};
|
|
373
|
+
});
|
|
374
|
+
const quniq = quniqWith(identity);
|
|
359
375
|
// Aliases.
|
|
360
376
|
const qpush = qappend;
|
|
377
|
+
const quniqBy = quniqWith;
|
|
361
378
|
|
|
362
379
|
const { assign } = Object;
|
|
363
380
|
// TODO: over, reduceAsync, propsEq is up to 20x slow due to deep equals.
|
|
@@ -413,9 +430,6 @@ const find = curry2((fn, s) => s.find(fn));
|
|
|
413
430
|
const findIndex = curry2((fn, s) => s.findIndex(fn));
|
|
414
431
|
const indexOf = curry2((x, xs) => findIndex(equals(x), xs));
|
|
415
432
|
const divide = curry2((a, b) => b / a);
|
|
416
|
-
const always = (s) => () => s;
|
|
417
|
-
const identity = (s) => s;
|
|
418
|
-
const trim = (s) => s.trim();
|
|
419
433
|
const not = (x) => !x;
|
|
420
434
|
const keys = (o) => Object.keys(o);
|
|
421
435
|
const values = (o) => Object.values(o);
|
|
@@ -568,7 +582,7 @@ const clone = (s, shallow = false) => {
|
|
|
568
582
|
case 'Symbol':
|
|
569
583
|
return s;
|
|
570
584
|
default:
|
|
571
|
-
return is_typed_arr(
|
|
585
|
+
return is_typed_arr(s) ? s.constructor.from(s) : s;
|
|
572
586
|
}
|
|
573
587
|
};
|
|
574
588
|
const cloneShallow = (s) => clone(s, true);
|
|
@@ -937,6 +951,8 @@ exports.qreverse = qreverse;
|
|
|
937
951
|
exports.qslice = qslice;
|
|
938
952
|
exports.qsort = qsort;
|
|
939
953
|
exports.quniq = quniq;
|
|
954
|
+
exports.quniqBy = quniqBy;
|
|
955
|
+
exports.quniqWith = quniqWith;
|
|
940
956
|
exports.qwaitAll = qwaitAll;
|
|
941
957
|
exports.range = range;
|
|
942
958
|
exports.reduce = reduce;
|
package/dist/bundle.d.ts
CHANGED
|
@@ -111,6 +111,9 @@ export declare const includes: {
|
|
|
111
111
|
(a: unknown): (b: unknown[]) => boolean;
|
|
112
112
|
(a: unknown, b: unknown[]): boolean;
|
|
113
113
|
};
|
|
114
|
+
export declare const always: <T extends any>(s: T) => () => T;
|
|
115
|
+
export declare const identity: <T extends any>(s: T) => T;
|
|
116
|
+
export declare const trim: (s: string) => string;
|
|
114
117
|
export declare const qappend: {
|
|
115
118
|
(a: Placeholder, b: any[]): (a: any) => any[];
|
|
116
119
|
(a: any, b: Placeholder): (b: any[]) => any[];
|
|
@@ -231,13 +234,25 @@ export declare const qpick: {
|
|
|
231
234
|
(a: string[], b: AnyObject): AnyObject;
|
|
232
235
|
};
|
|
233
236
|
export declare const qslice: (...args: AnyArgs) => any;
|
|
234
|
-
export declare const
|
|
237
|
+
export declare const quniqWith: {
|
|
238
|
+
(a: Placeholder, b: any[]): (a: AnyFunc) => any[];
|
|
239
|
+
(a: AnyFunc, b: Placeholder): (b: any[]) => any[];
|
|
240
|
+
(a: AnyFunc): (b: any[]) => any[];
|
|
241
|
+
(a: AnyFunc, b: any[]): any[];
|
|
242
|
+
};
|
|
243
|
+
export declare const quniq: (b: any[]) => any[];
|
|
235
244
|
export declare const qpush: {
|
|
236
245
|
(a: Placeholder, b: any[]): (a: any) => any[];
|
|
237
246
|
(a: any, b: Placeholder): (b: any[]) => any[];
|
|
238
247
|
(a: any): (b: any[]) => any[];
|
|
239
248
|
(a: any, b: any[]): any[];
|
|
240
249
|
};
|
|
250
|
+
export declare const quniqBy: {
|
|
251
|
+
(a: Placeholder, b: any[]): (a: AnyFunc) => any[];
|
|
252
|
+
(a: AnyFunc, b: Placeholder): (b: any[]) => any[];
|
|
253
|
+
(a: AnyFunc): (b: any[]) => any[];
|
|
254
|
+
(a: AnyFunc, b: any[]): any[];
|
|
255
|
+
};
|
|
241
256
|
export declare const isNil: <T extends any>(s: T) => T extends (null | undefined) ? true : false;
|
|
242
257
|
export declare class QPromise<T> extends Promise<T> {
|
|
243
258
|
private oncancel;
|
|
@@ -390,9 +405,6 @@ export declare const divide: {
|
|
|
390
405
|
(a: number): (b: number) => number;
|
|
391
406
|
(a: number, b: number): number;
|
|
392
407
|
};
|
|
393
|
-
export declare const always: <T extends any>(s: T) => () => T;
|
|
394
|
-
export declare const identity: <T extends any>(s: T) => T;
|
|
395
|
-
export declare const trim: (s: string) => string;
|
|
396
408
|
type T_not = {
|
|
397
409
|
(x: true): false;
|
|
398
410
|
(x: false): true;
|
package/dist/bundle.mjs
CHANGED
|
@@ -67,8 +67,7 @@ function curry3(fn) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const length = (s) => s.length;
|
|
70
|
-
const
|
|
71
|
-
const is_typed_arr = (t) => typed_arr_re.test(t);
|
|
70
|
+
const is_typed_arr = (x) => ArrayBuffer.isView(x);
|
|
72
71
|
/** @param start string | any[] @param s string | any[] */
|
|
73
72
|
const startsWithWith = (comparator) => curry2((start, s) => {
|
|
74
73
|
const len_start = length(start);
|
|
@@ -142,20 +141,32 @@ const type = (s) => {
|
|
|
142
141
|
const typeIs = curry2((t, s) => type(s) === t);
|
|
143
142
|
const eq = curry2((a, b) => a === b);
|
|
144
143
|
const equals = curry2((a, b) => {
|
|
144
|
+
if (a === b)
|
|
145
|
+
return true;
|
|
145
146
|
const typea = type(a);
|
|
146
|
-
|
|
147
|
+
const ta = is_typed_arr(a);
|
|
148
|
+
if (eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array') || ta)) {
|
|
149
|
+
if (ta) {
|
|
150
|
+
if (typea === 'Buffer')
|
|
151
|
+
return a.equals(b);
|
|
152
|
+
const len = length(a);
|
|
153
|
+
if (len !== length(b))
|
|
154
|
+
return false;
|
|
155
|
+
for (let i = 0; i < len; i++)
|
|
156
|
+
if (a[i] !== b[i])
|
|
157
|
+
return false;
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
147
160
|
if (isNull(a) || isNull(b))
|
|
148
161
|
return eq(a, b);
|
|
149
|
-
if (eq(a, b))
|
|
150
|
-
return true;
|
|
151
162
|
for (const v of [a, b])
|
|
152
163
|
for (const k in v)
|
|
153
|
-
if (!(
|
|
154
|
-
!(
|
|
164
|
+
if (!(v === b && (k in a)) &&
|
|
165
|
+
!(v === a && (k in b) && equals(a[k], b[k])))
|
|
155
166
|
return false;
|
|
156
167
|
return true;
|
|
157
168
|
}
|
|
158
|
-
return
|
|
169
|
+
return false;
|
|
159
170
|
});
|
|
160
171
|
const includes = curry2((s, ss) => {
|
|
161
172
|
if (isStr(ss))
|
|
@@ -167,6 +178,9 @@ const includes = curry2((s, ss) => {
|
|
|
167
178
|
return false;
|
|
168
179
|
}
|
|
169
180
|
});
|
|
181
|
+
const always = (s) => () => s;
|
|
182
|
+
const identity = (s) => s;
|
|
183
|
+
const trim = (s) => s.trim();
|
|
170
184
|
|
|
171
185
|
const { min } = Math;
|
|
172
186
|
const z = 0;
|
|
@@ -339,23 +353,26 @@ const rmel = (index, xs) => {
|
|
|
339
353
|
return xs;
|
|
340
354
|
};
|
|
341
355
|
const seen = new Set();
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
let size = length(xs);
|
|
356
|
+
const quniqWith = curry2((getter, xs) => {
|
|
357
|
+
let size = length(xs), cur;
|
|
345
358
|
for (let i = z; i < size; i++) {
|
|
346
359
|
const x = xs[i];
|
|
347
|
-
|
|
360
|
+
cur = getter(x);
|
|
361
|
+
if (seen.has(cur)) {
|
|
348
362
|
rmel(i, xs);
|
|
349
363
|
size--;
|
|
350
364
|
i--;
|
|
351
365
|
}
|
|
352
366
|
else
|
|
353
|
-
seen.add(
|
|
367
|
+
seen.add(cur);
|
|
354
368
|
}
|
|
369
|
+
seen.clear();
|
|
355
370
|
return xs;
|
|
356
|
-
};
|
|
371
|
+
});
|
|
372
|
+
const quniq = quniqWith(identity);
|
|
357
373
|
// Aliases.
|
|
358
374
|
const qpush = qappend;
|
|
375
|
+
const quniqBy = quniqWith;
|
|
359
376
|
|
|
360
377
|
const { assign } = Object;
|
|
361
378
|
// TODO: over, reduceAsync, propsEq is up to 20x slow due to deep equals.
|
|
@@ -411,9 +428,6 @@ const find = curry2((fn, s) => s.find(fn));
|
|
|
411
428
|
const findIndex = curry2((fn, s) => s.findIndex(fn));
|
|
412
429
|
const indexOf = curry2((x, xs) => findIndex(equals(x), xs));
|
|
413
430
|
const divide = curry2((a, b) => b / a);
|
|
414
|
-
const always = (s) => () => s;
|
|
415
|
-
const identity = (s) => s;
|
|
416
|
-
const trim = (s) => s.trim();
|
|
417
431
|
const not = (x) => !x;
|
|
418
432
|
const keys = (o) => Object.keys(o);
|
|
419
433
|
const values = (o) => Object.values(o);
|
|
@@ -566,7 +580,7 @@ const clone = (s, shallow = false) => {
|
|
|
566
580
|
case 'Symbol':
|
|
567
581
|
return s;
|
|
568
582
|
default:
|
|
569
|
-
return is_typed_arr(
|
|
583
|
+
return is_typed_arr(s) ? s.constructor.from(s) : s;
|
|
570
584
|
}
|
|
571
585
|
};
|
|
572
586
|
const cloneShallow = (s) => clone(s, true);
|
|
@@ -814,4 +828,4 @@ const wait = (time) => new QPromise((ff) => setTimeout(ff, time), (timeout) => c
|
|
|
814
828
|
// TODO: possibly introduce a second argument limiting unfolding.
|
|
815
829
|
const uncurry = (fn) => (...args) => qreduce(((fn, arg) => fn ? fn(arg) : fn), fn, args);
|
|
816
830
|
|
|
817
|
-
export { F, QPromise, T, __, add, all, allPass, always, any, anyPass, append, assoc, assocPath, bind, both, callFrom, callWith, clone, cloneShallow, complement, compose, composeAsync, concat, cond, curry, curry2, curry3, debounce, diff, divide, echo, empty, eq, equals, explore, filter, find, findIndex, flat, flatShallow, flatTo, flip, forEach, forEachParallel, forEachSerial, freeze, freezeShallow, fromPairs, genBy, getTmpl, gt, gte, head, identity, ifElse, includes, indexOf, intersection, isEmpty, isNil, join, keys, last, length, lt, lte, map, mapKeys, mapObj, memoize, mergeDeep, mergeDeepAdd, mergeDeepX, mergeShallow, mirror, multiply, noop, not, notf, nth, omit, once, overProp, path, pathEq, pathExists, pathOr, pathsEq, pick, pickBy, prepend, prop, propEq, propLens, propsEq, push, qappend, qassoc, qassocPath, qempty, qfilter, qfilterAsync, qfreeze, qfreezeShallow, qmap, qmapKeys, qmapObj, qmergeDeep, qmergeDeepAdd, qmergeDeepX, qmergeShallow, qomit, qoverProp, qpick, qprepend, qpush, qreduce, qreverse, qslice, qsort, quniq, qwaitAll, range, reduce, reflect, replace, reverse, sizeof, slice, some, sort, split, startsWith, startsWithShallow, subtract, symbol, tail, take, tap, test, throttle, toLower, toPairs, toUpper, trim, type, typeIs, uncurry, uniq, uniqBy, uniqWith, values, wait, waitAll, waitTap, weakEq, when, zip, zipObj, zipWith };
|
|
831
|
+
export { F, QPromise, T, __, add, all, allPass, always, any, anyPass, append, assoc, assocPath, bind, both, callFrom, callWith, clone, cloneShallow, complement, compose, composeAsync, concat, cond, curry, curry2, curry3, debounce, diff, divide, echo, empty, eq, equals, explore, filter, find, findIndex, flat, flatShallow, flatTo, flip, forEach, forEachParallel, forEachSerial, freeze, freezeShallow, fromPairs, genBy, getTmpl, gt, gte, head, identity, ifElse, includes, indexOf, intersection, isEmpty, isNil, join, keys, last, length, lt, lte, map, mapKeys, mapObj, memoize, mergeDeep, mergeDeepAdd, mergeDeepX, mergeShallow, mirror, multiply, noop, not, notf, nth, omit, once, overProp, path, pathEq, pathExists, pathOr, pathsEq, pick, pickBy, prepend, prop, propEq, propLens, propsEq, push, qappend, qassoc, qassocPath, qempty, qfilter, qfilterAsync, qfreeze, qfreezeShallow, qmap, qmapKeys, qmapObj, qmergeDeep, qmergeDeepAdd, qmergeDeepX, qmergeShallow, qomit, qoverProp, qpick, qprepend, qpush, qreduce, qreverse, qslice, qsort, quniq, quniqBy, quniqWith, qwaitAll, range, reduce, reflect, replace, reverse, sizeof, slice, some, sort, split, startsWith, startsWithShallow, subtract, symbol, tail, take, tap, test, throttle, toLower, toPairs, toUpper, trim, type, typeIs, uncurry, uniq, uniqBy, uniqWith, values, wait, waitAll, waitTap, weakEq, when, zip, zipObj, zipWith };
|
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
43
43
|
"all": "npm run dev && npm run prod"
|
|
44
44
|
},
|
|
45
|
-
"version": "1.
|
|
45
|
+
"version": "1.13.0",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
package/src/common.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { curry2 } from "./curry"
|
|
2
|
-
import { is_typed_arr } from "./internal"
|
|
2
|
+
import { is_typed_arr, length } from "./internal"
|
|
3
3
|
import { isNull, isStr, to } from "./utils"
|
|
4
4
|
const {isNaN} = Number
|
|
5
5
|
|
|
@@ -21,19 +21,26 @@ export const typeIs = curry2((t: string, s: any) => type(s)===t)
|
|
|
21
21
|
|
|
22
22
|
export const eq = curry2((a: any, b: any) => a===b)
|
|
23
23
|
export const equals = curry2((a: any, b: any) => {
|
|
24
|
+
if(a===b) return true
|
|
24
25
|
const typea = type(a)
|
|
25
|
-
|
|
26
|
+
const ta = is_typed_arr(a)
|
|
27
|
+
if(eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array') || ta)) {
|
|
28
|
+
if(ta) {
|
|
29
|
+
if(typea==='Buffer') return (a as Buffer).equals(b)
|
|
30
|
+
const len = length(a as any)
|
|
31
|
+
if(len!==length(b)) return false
|
|
32
|
+
for(let i=0; i<len; i++) if(a[i]!==b[i]) return false
|
|
33
|
+
return true
|
|
34
|
+
}
|
|
26
35
|
if(isNull(a) || isNull(b)) return eq(a, b)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
!((eq(v, a)) && (k in b) && equals(a[k], b[k]))
|
|
33
|
-
) return false
|
|
36
|
+
for(const v of [a, b]) for(const k in v)
|
|
37
|
+
if(
|
|
38
|
+
!(v===b && (k in a)) &&
|
|
39
|
+
!(v===a && (k in b) && equals(a[k], b[k]))
|
|
40
|
+
) return false
|
|
34
41
|
return true
|
|
35
42
|
}
|
|
36
|
-
return
|
|
43
|
+
return false
|
|
37
44
|
})
|
|
38
45
|
export const includes = curry2(
|
|
39
46
|
<T>(s: T, ss: T[]) => {
|
|
@@ -44,5 +51,9 @@ export const includes = curry2(
|
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
)
|
|
54
|
+
export const always = <T extends any>(s: T) => () => s
|
|
55
|
+
export const identity = <T extends any>(s: T) => s
|
|
56
|
+
export const trim = (s: string) => s.trim()
|
|
57
|
+
|
|
47
58
|
export { length } from './internal'
|
|
48
59
|
|
package/src/internal.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { curry2 } from "./curry"
|
|
|
2
2
|
import { AnyArray, StrLen } from "./internal_types"
|
|
3
3
|
|
|
4
4
|
export const length = <T extends AnyArray | string>(s: T): T extends string ? StrLen<T> : T['length'] => s.length as any
|
|
5
|
-
const
|
|
6
|
-
export const is_typed_arr = (t: string) => typed_arr_re.test(t)
|
|
5
|
+
export const is_typed_arr = (x: any) => ArrayBuffer.isView(x)
|
|
7
6
|
/** @param start string | any[] @param s string | any[] */
|
|
8
7
|
export const startsWithWith = (comparator: (x: any, y: any)=>boolean) => curry2(
|
|
9
8
|
(start: any[] | string, s: any[] | string) => {
|
package/src/quick.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { includes, length, type } from "./common"
|
|
1
|
+
import { identity, includes, length, type } from "./common"
|
|
2
2
|
import { curry2, curry3 } from "./curry"
|
|
3
3
|
import { AnyFunc, AnyObject, Reducer } from "./types"
|
|
4
4
|
import { inf, isArray, isFunc, isNil, isNum, isObj, isSafe } from "./utils"
|
|
@@ -175,16 +175,19 @@ const rmel = (index: number, xs: any[]) => {
|
|
|
175
175
|
return xs
|
|
176
176
|
}
|
|
177
177
|
const seen = new Set()
|
|
178
|
-
export const
|
|
179
|
-
|
|
180
|
-
let size = length(xs)
|
|
178
|
+
export const quniqWith = curry2((getter: AnyFunc, xs: any[]) => {
|
|
179
|
+
let size = length(xs), cur: any
|
|
181
180
|
for(let i=z; i<size; i++) {
|
|
182
181
|
const x = xs[i]
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
cur = getter(x)
|
|
183
|
+
if(seen.has(cur)) {rmel(i, xs); size--; i--}
|
|
184
|
+
else seen.add(cur)
|
|
185
185
|
}
|
|
186
|
+
seen.clear()
|
|
186
187
|
return xs
|
|
187
|
-
}
|
|
188
|
+
})
|
|
189
|
+
export const quniq = quniqWith(identity)
|
|
188
190
|
|
|
189
191
|
// Aliases.
|
|
190
|
-
export const qpush = qappend
|
|
192
|
+
export const qpush = qappend
|
|
193
|
+
export const quniqBy = quniqWith
|
package/src/safe.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { eq, equals, includes, length, symbol, type } from './common'
|
|
1
|
+
import { always, eq, equals, identity, includes, length, symbol, type } from './common'
|
|
2
2
|
import { __, curry, curry2, curry3 } from './curry'
|
|
3
3
|
import { is_typed_arr, startsWithWith } from './internal'
|
|
4
4
|
import { AnyArray, IndexesOfArray, Split } from './internal_types'
|
|
@@ -108,9 +108,6 @@ export const find = curry2((fn: Cond, s: any[]) => s.find(fn))
|
|
|
108
108
|
export const findIndex = curry2((fn: Cond, s: any[]) => s.findIndex(fn))
|
|
109
109
|
export const indexOf = curry2((x: any, xs: any[]) => findIndex(equals(x), xs))
|
|
110
110
|
export const divide = curry2((a: number, b: number) => b/a)
|
|
111
|
-
export const always = <T extends any>(s: T) => () => s
|
|
112
|
-
export const identity = <T extends any>(s: T) => s
|
|
113
|
-
export const trim = (s: string) => s.trim()
|
|
114
111
|
|
|
115
112
|
type T_not = {
|
|
116
113
|
(x: true): false
|
|
@@ -304,7 +301,7 @@ export const clone = <T extends any>(s: T, shallow = false): T => {
|
|
|
304
301
|
case 'Boolean': case 'Symbol':
|
|
305
302
|
return s
|
|
306
303
|
default:
|
|
307
|
-
return is_typed_arr(
|
|
304
|
+
return is_typed_arr(s) ? (s as any).constructor.from(s) : s
|
|
308
305
|
}
|
|
309
306
|
}
|
|
310
307
|
export const cloneShallow = (s: any) => clone(s, true)
|