radashi 12.2.0-beta.3a97871 → 12.2.0-beta.45f2ac3
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/README.md +10 -4
- package/dist/index.cjs +10 -23
- package/dist/index.d.cts +4 -18
- package/dist/index.d.ts +4 -18
- package/dist/index.js +10 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,7 +51,9 @@
|
|
|
51
51
|
- ⚠️ **Beware:** Preview releases are not audited by the Radashi team. Always look at their
|
|
52
52
|
changes in the PR to ensure no malicious code was introduced.
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
<img src="https://github.com/radashi-org/radashi/raw/main/img/rule.png" width="100%" />
|
|
55
57
|
|
|
56
58
|
## Install
|
|
57
59
|
|
|
@@ -67,7 +69,9 @@ yarn add radashi
|
|
|
67
69
|
npm install radashi
|
|
68
70
|
```
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
<img src="https://github.com/radashi-org/radashi/raw/main/img/rule.png" width="100%" />
|
|
71
75
|
|
|
72
76
|
## Contributing
|
|
73
77
|
|
|
@@ -77,7 +81,9 @@ Contributions are welcome and appreciated! Check out the contributing guide befo
|
|
|
77
81
|
<img src="https://github.com/radashi-org/radashi/raw/main/img/contributing-button.png" alt="Contributing to Radashi" width="250px" />
|
|
78
82
|
</a>
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
<img src="https://github.com/radashi-org/radashi/raw/main/img/rule.png" width="100%" />
|
|
81
87
|
|
|
82
88
|
## Changelog
|
|
83
89
|
|
|
@@ -91,6 +97,6 @@ This section documents the changes between the original `radash` library and thi
|
|
|
91
97
|
|
|
92
98
|
<div align="center">
|
|
93
99
|
<p align="center">
|
|
94
|
-
<img src="https://github.com/radashi-org/radashi/raw/
|
|
100
|
+
<img src="https://github.com/radashi-org/radashi/raw/main/img/footer.png" alt="Radashi" width="100%" />
|
|
95
101
|
</p>
|
|
96
102
|
</div>
|
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,6 @@ __export(src_exports, {
|
|
|
40
40
|
defer: () => defer,
|
|
41
41
|
diff: () => diff,
|
|
42
42
|
draw: () => draw,
|
|
43
|
-
filterKey: () => filterKey,
|
|
44
43
|
first: () => first,
|
|
45
44
|
flat: () => flat,
|
|
46
45
|
fork: () => fork,
|
|
@@ -316,10 +315,9 @@ var replaceOrAppend = (list2, newItem, match) => {
|
|
|
316
315
|
// src/array/select.ts
|
|
317
316
|
var select = (array, mapper, condition) => {
|
|
318
317
|
if (!array) return [];
|
|
319
|
-
let mapped;
|
|
320
318
|
return array.reduce((acc, item, index) => {
|
|
321
|
-
if (condition
|
|
322
|
-
|
|
319
|
+
if (!condition(item, index)) return acc;
|
|
320
|
+
acc.push(mapper(item, index));
|
|
323
321
|
return acc;
|
|
324
322
|
}, []);
|
|
325
323
|
};
|
|
@@ -365,18 +363,13 @@ var toggle = (list2, item, toKey, options) => {
|
|
|
365
363
|
|
|
366
364
|
// src/array/unique.ts
|
|
367
365
|
var unique = (array, toKey) => {
|
|
368
|
-
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
return acc;
|
|
377
|
-
}, []);
|
|
378
|
-
}
|
|
379
|
-
return [...new Set(array)];
|
|
366
|
+
const valueMap = array.reduce((acc, item) => {
|
|
367
|
+
const key = toKey ? toKey(item) : item;
|
|
368
|
+
if (acc[key]) return acc;
|
|
369
|
+
acc[key] = item;
|
|
370
|
+
return acc;
|
|
371
|
+
}, {});
|
|
372
|
+
return Object.values(valueMap);
|
|
380
373
|
};
|
|
381
374
|
|
|
382
375
|
// src/array/zip.ts
|
|
@@ -755,11 +748,6 @@ var crush = (value) => {
|
|
|
755
748
|
);
|
|
756
749
|
};
|
|
757
750
|
|
|
758
|
-
// src/object/filterKey.ts
|
|
759
|
-
var filterKey = (obj, key, filter) => {
|
|
760
|
-
return Object.hasOwnProperty.call(obj, key) && (filter == null || (isArray(filter) ? filter.includes(key) : filter(obj[key], key, obj)));
|
|
761
|
-
};
|
|
762
|
-
|
|
763
751
|
// src/object/get.ts
|
|
764
752
|
var get = (value, path, defaultValue) => {
|
|
765
753
|
const segments = path.split(/[\.\[\]]/g);
|
|
@@ -1052,7 +1040,7 @@ var trim = (str, charsToTrim = " ") => {
|
|
|
1052
1040
|
};
|
|
1053
1041
|
|
|
1054
1042
|
// src/typed/isArray.ts
|
|
1055
|
-
var isArray =
|
|
1043
|
+
var isArray = Array.isArray;
|
|
1056
1044
|
|
|
1057
1045
|
// src/typed/isDate.ts
|
|
1058
1046
|
var isDate = (value) => {
|
|
@@ -1186,7 +1174,6 @@ var isSymbol = (value) => {
|
|
|
1186
1174
|
defer,
|
|
1187
1175
|
diff,
|
|
1188
1176
|
draw,
|
|
1189
|
-
filterKey,
|
|
1190
1177
|
first,
|
|
1191
1178
|
flat,
|
|
1192
1179
|
fork,
|
package/dist/index.d.cts
CHANGED
|
@@ -156,7 +156,7 @@ declare const replaceOrAppend: <T>(list: readonly T[], newItem: T, match: (a: T,
|
|
|
156
156
|
* @example
|
|
157
157
|
* select([1, 2, 3, 4], x => x*x, x > 2) == [9, 16]
|
|
158
158
|
*/
|
|
159
|
-
declare const select: <T, K>(array: readonly T[], mapper: (item: T, index: number) => K, condition
|
|
159
|
+
declare const select: <T, K>(array: readonly T[], mapper: (item: T, index: number) => K, condition: (item: T, index: number) => boolean) => K[];
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* Shift array items by n steps If n > 0 items will shift n steps to
|
|
@@ -196,7 +196,7 @@ declare const toggle: <T>(list: readonly T[], item: T, toKey?: ((item: T, idx: n
|
|
|
196
196
|
* Accepts an optional identity function to convert each item in the
|
|
197
197
|
* list to a comparable identity value
|
|
198
198
|
*/
|
|
199
|
-
declare const unique: <T, K
|
|
199
|
+
declare const unique: <T, K extends string | number | symbol>(array: readonly T[], toKey?: ((item: T) => K) | undefined) => T[];
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
202
|
* Creates an array of grouped elements, the first of which contains
|
|
@@ -511,20 +511,6 @@ declare const construct: <TObject extends object>(obj: TObject) => object;
|
|
|
511
511
|
*/
|
|
512
512
|
declare const crush: <TValue extends object>(value: TValue) => object;
|
|
513
513
|
|
|
514
|
-
type KeyOf<T extends object> = object extends T ? keyof any : keyof T;
|
|
515
|
-
type ValueOf<T extends object> = object extends T ? unknown : T[keyof T];
|
|
516
|
-
type KeyFilterFunction<T extends object = object> = (value: ValueOf<T>, key: KeyOf<T>, obj: T) => boolean;
|
|
517
|
-
/**
|
|
518
|
-
* Functions can use this type to accept either an array of keys or a
|
|
519
|
-
* filter function.
|
|
520
|
-
*/
|
|
521
|
-
type KeyFilter<T extends object = object, Key extends keyof any = keyof any> = KeyFilterFunction<T> | readonly Key[];
|
|
522
|
-
/**
|
|
523
|
-
* Returns true if the key is in the “keys array” or if the “filter
|
|
524
|
-
* function” returns true.
|
|
525
|
-
*/
|
|
526
|
-
declare const filterKey: (obj: object, key: keyof any, filter: KeyFilter | null | undefined) => boolean;
|
|
527
|
-
|
|
528
514
|
/**
|
|
529
515
|
* Dynamically get a nested value from an array or object with a
|
|
530
516
|
* string.
|
|
@@ -713,7 +699,7 @@ declare const title: (str: string | null | undefined) => string;
|
|
|
713
699
|
*/
|
|
714
700
|
declare const trim: (str: string | null | undefined, charsToTrim?: string) => string;
|
|
715
701
|
|
|
716
|
-
declare const isArray: (
|
|
702
|
+
declare const isArray: (arg: any) => arg is any[];
|
|
717
703
|
|
|
718
704
|
declare const isDate: (value: any) => value is Date;
|
|
719
705
|
|
|
@@ -757,4 +743,4 @@ declare const isString: (value: any) => value is string;
|
|
|
757
743
|
|
|
758
744
|
declare const isSymbol: (value: any) => value is symbol;
|
|
759
745
|
|
|
760
|
-
export { AggregateError, type DebounceFunction, type
|
|
746
|
+
export { AggregateError, type DebounceFunction, type RetryOptions, type ThrottledFunction, all, alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, first, flat, fork, get, group, guard, inRange, intersects, invert, isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isIntString, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, objectify, omit, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, select, series, set, shake, shift, shuffle, sift, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, trim, tryit as try, tryit, uid, unique, upperize, zip, zipToObject };
|
package/dist/index.d.ts
CHANGED
|
@@ -156,7 +156,7 @@ declare const replaceOrAppend: <T>(list: readonly T[], newItem: T, match: (a: T,
|
|
|
156
156
|
* @example
|
|
157
157
|
* select([1, 2, 3, 4], x => x*x, x > 2) == [9, 16]
|
|
158
158
|
*/
|
|
159
|
-
declare const select: <T, K>(array: readonly T[], mapper: (item: T, index: number) => K, condition
|
|
159
|
+
declare const select: <T, K>(array: readonly T[], mapper: (item: T, index: number) => K, condition: (item: T, index: number) => boolean) => K[];
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* Shift array items by n steps If n > 0 items will shift n steps to
|
|
@@ -196,7 +196,7 @@ declare const toggle: <T>(list: readonly T[], item: T, toKey?: ((item: T, idx: n
|
|
|
196
196
|
* Accepts an optional identity function to convert each item in the
|
|
197
197
|
* list to a comparable identity value
|
|
198
198
|
*/
|
|
199
|
-
declare const unique: <T, K
|
|
199
|
+
declare const unique: <T, K extends string | number | symbol>(array: readonly T[], toKey?: ((item: T) => K) | undefined) => T[];
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
202
|
* Creates an array of grouped elements, the first of which contains
|
|
@@ -511,20 +511,6 @@ declare const construct: <TObject extends object>(obj: TObject) => object;
|
|
|
511
511
|
*/
|
|
512
512
|
declare const crush: <TValue extends object>(value: TValue) => object;
|
|
513
513
|
|
|
514
|
-
type KeyOf<T extends object> = object extends T ? keyof any : keyof T;
|
|
515
|
-
type ValueOf<T extends object> = object extends T ? unknown : T[keyof T];
|
|
516
|
-
type KeyFilterFunction<T extends object = object> = (value: ValueOf<T>, key: KeyOf<T>, obj: T) => boolean;
|
|
517
|
-
/**
|
|
518
|
-
* Functions can use this type to accept either an array of keys or a
|
|
519
|
-
* filter function.
|
|
520
|
-
*/
|
|
521
|
-
type KeyFilter<T extends object = object, Key extends keyof any = keyof any> = KeyFilterFunction<T> | readonly Key[];
|
|
522
|
-
/**
|
|
523
|
-
* Returns true if the key is in the “keys array” or if the “filter
|
|
524
|
-
* function” returns true.
|
|
525
|
-
*/
|
|
526
|
-
declare const filterKey: (obj: object, key: keyof any, filter: KeyFilter | null | undefined) => boolean;
|
|
527
|
-
|
|
528
514
|
/**
|
|
529
515
|
* Dynamically get a nested value from an array or object with a
|
|
530
516
|
* string.
|
|
@@ -713,7 +699,7 @@ declare const title: (str: string | null | undefined) => string;
|
|
|
713
699
|
*/
|
|
714
700
|
declare const trim: (str: string | null | undefined, charsToTrim?: string) => string;
|
|
715
701
|
|
|
716
|
-
declare const isArray: (
|
|
702
|
+
declare const isArray: (arg: any) => arg is any[];
|
|
717
703
|
|
|
718
704
|
declare const isDate: (value: any) => value is Date;
|
|
719
705
|
|
|
@@ -757,4 +743,4 @@ declare const isString: (value: any) => value is string;
|
|
|
757
743
|
|
|
758
744
|
declare const isSymbol: (value: any) => value is symbol;
|
|
759
745
|
|
|
760
|
-
export { AggregateError, type DebounceFunction, type
|
|
746
|
+
export { AggregateError, type DebounceFunction, type RetryOptions, type ThrottledFunction, all, alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, first, flat, fork, get, group, guard, inRange, intersects, invert, isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isIntString, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, objectify, omit, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, select, series, set, shake, shift, shuffle, sift, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, trim, tryit as try, tryit, uid, unique, upperize, zip, zipToObject };
|
package/dist/index.js
CHANGED
|
@@ -193,10 +193,9 @@ var replaceOrAppend = (list2, newItem, match) => {
|
|
|
193
193
|
// src/array/select.ts
|
|
194
194
|
var select = (array, mapper, condition) => {
|
|
195
195
|
if (!array) return [];
|
|
196
|
-
let mapped;
|
|
197
196
|
return array.reduce((acc, item, index) => {
|
|
198
|
-
if (condition
|
|
199
|
-
|
|
197
|
+
if (!condition(item, index)) return acc;
|
|
198
|
+
acc.push(mapper(item, index));
|
|
200
199
|
return acc;
|
|
201
200
|
}, []);
|
|
202
201
|
};
|
|
@@ -242,18 +241,13 @@ var toggle = (list2, item, toKey, options) => {
|
|
|
242
241
|
|
|
243
242
|
// src/array/unique.ts
|
|
244
243
|
var unique = (array, toKey) => {
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
return acc;
|
|
254
|
-
}, []);
|
|
255
|
-
}
|
|
256
|
-
return [...new Set(array)];
|
|
244
|
+
const valueMap = array.reduce((acc, item) => {
|
|
245
|
+
const key = toKey ? toKey(item) : item;
|
|
246
|
+
if (acc[key]) return acc;
|
|
247
|
+
acc[key] = item;
|
|
248
|
+
return acc;
|
|
249
|
+
}, {});
|
|
250
|
+
return Object.values(valueMap);
|
|
257
251
|
};
|
|
258
252
|
|
|
259
253
|
// src/array/zip.ts
|
|
@@ -632,11 +626,6 @@ var crush = (value) => {
|
|
|
632
626
|
);
|
|
633
627
|
};
|
|
634
628
|
|
|
635
|
-
// src/object/filterKey.ts
|
|
636
|
-
var filterKey = (obj, key, filter) => {
|
|
637
|
-
return Object.hasOwnProperty.call(obj, key) && (filter == null || (isArray(filter) ? filter.includes(key) : filter(obj[key], key, obj)));
|
|
638
|
-
};
|
|
639
|
-
|
|
640
629
|
// src/object/get.ts
|
|
641
630
|
var get = (value, path, defaultValue) => {
|
|
642
631
|
const segments = path.split(/[\.\[\]]/g);
|
|
@@ -929,7 +918,7 @@ var trim = (str, charsToTrim = " ") => {
|
|
|
929
918
|
};
|
|
930
919
|
|
|
931
920
|
// src/typed/isArray.ts
|
|
932
|
-
var isArray =
|
|
921
|
+
var isArray = Array.isArray;
|
|
933
922
|
|
|
934
923
|
// src/typed/isDate.ts
|
|
935
924
|
var isDate = (value) => {
|
|
@@ -1062,7 +1051,6 @@ export {
|
|
|
1062
1051
|
defer,
|
|
1063
1052
|
diff,
|
|
1064
1053
|
draw,
|
|
1065
|
-
filterKey,
|
|
1066
1054
|
first,
|
|
1067
1055
|
flat,
|
|
1068
1056
|
fork,
|