radashi 12.2.0-beta.45f2ac3 → 12.2.0-beta.649f0d1

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 CHANGED
@@ -51,9 +51,7 @@
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
-  
55
-
56
- <img src="https://github.com/radashi-org/radashi/raw/main/img/rule.png" width="100%" />
54
+ <img src="https://github.com/radashi-org/radashi/raw/b80a0e4/img/rule.png" width="100%" />
57
55
 
58
56
  ## Install
59
57
 
@@ -69,9 +67,7 @@ yarn add radashi
69
67
  npm install radashi
70
68
  ```
71
69
 
72
- &nbsp;
73
-
74
- <img src="https://github.com/radashi-org/radashi/raw/main/img/rule.png" width="100%" />
70
+ <img src="https://github.com/radashi-org/radashi/raw/b80a0e4/img/rule.png" width="100%" />
75
71
 
76
72
  ## Contributing
77
73
 
@@ -81,9 +77,7 @@ Contributions are welcome and appreciated! Check out the contributing guide befo
81
77
  <img src="https://github.com/radashi-org/radashi/raw/main/img/contributing-button.png" alt="Contributing to Radashi" width="250px" />
82
78
  </a>
83
79
 
84
- &nbsp;
85
-
86
- <img src="https://github.com/radashi-org/radashi/raw/main/img/rule.png" width="100%" />
80
+ <img src="https://github.com/radashi-org/radashi/raw/b80a0e4/img/rule.png" width="100%" />
87
81
 
88
82
  ## Changelog
89
83
 
@@ -97,6 +91,6 @@ This section documents the changes between the original `radash` library and thi
97
91
 
98
92
  <div align="center">
99
93
  <p align="center">
100
- <img src="https://github.com/radashi-org/radashi/raw/main/img/footer.png" alt="Radashi" width="100%" />
94
+ <img src="https://github.com/radashi-org/radashi/raw/46c8897/img/footer.png" alt="Radashi" width="100%" />
101
95
  </p>
102
96
  </div>
@@ -17,9 +17,9 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
20
+ // src/mod.ts
21
+ var mod_exports = {};
22
+ __export(mod_exports, {
23
23
  AggregateError: () => AggregateError,
24
24
  all: () => all,
25
25
  alphabetical: () => alphabetical,
@@ -40,6 +40,7 @@ __export(src_exports, {
40
40
  defer: () => defer,
41
41
  diff: () => diff,
42
42
  draw: () => draw,
43
+ filterKey: () => filterKey,
43
44
  first: () => first,
44
45
  flat: () => flat,
45
46
  fork: () => fork,
@@ -118,7 +119,7 @@ __export(src_exports, {
118
119
  zip: () => zip,
119
120
  zipToObject: () => zipToObject
120
121
  });
121
- module.exports = __toCommonJS(src_exports);
122
+ module.exports = __toCommonJS(mod_exports);
122
123
 
123
124
  // src/array/alphabetical.ts
124
125
  var alphabetical = (array, getter, dir = "asc") => {
@@ -315,9 +316,10 @@ var replaceOrAppend = (list2, newItem, match) => {
315
316
  // src/array/select.ts
316
317
  var select = (array, mapper, condition) => {
317
318
  if (!array) return [];
319
+ let mapped;
318
320
  return array.reduce((acc, item, index) => {
319
- if (!condition(item, index)) return acc;
320
- acc.push(mapper(item, index));
321
+ if (condition) condition(item, index) && acc.push(mapper(item, index));
322
+ else (mapped = mapper(item, index)) != null && acc.push(mapped);
321
323
  return acc;
322
324
  }, []);
323
325
  };
@@ -363,13 +365,18 @@ var toggle = (list2, item, toKey, options) => {
363
365
 
364
366
  // src/array/unique.ts
365
367
  var unique = (array, toKey) => {
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);
368
+ if (toKey) {
369
+ const keys2 = /* @__PURE__ */ new Set();
370
+ return array.reduce((acc, item) => {
371
+ const key = toKey(item);
372
+ if (!keys2.has(key)) {
373
+ keys2.add(key);
374
+ acc.push(item);
375
+ }
376
+ return acc;
377
+ }, []);
378
+ }
379
+ return [...new Set(array)];
373
380
  };
374
381
 
375
382
  // src/array/zip.ts
@@ -681,23 +688,23 @@ function inRange(number, start, end) {
681
688
  return number >= Math.min(start, end) && number < Math.max(start, end);
682
689
  }
683
690
 
684
- // src/number/toInt.ts
685
- var toInt = (value, defaultValue) => {
691
+ // src/number/toFloat.ts
692
+ var toFloat = (value, defaultValue) => {
686
693
  const def = defaultValue === void 0 ? 0 : defaultValue;
687
694
  if (value === null || value === void 0) {
688
695
  return def;
689
696
  }
690
- const result = parseInt(value);
697
+ const result = parseFloat(value);
691
698
  return isNaN(result) ? def : result;
692
699
  };
693
700
 
694
- // src/number/toFloat.ts
695
- var toFloat = (value, defaultValue) => {
701
+ // src/number/toInt.ts
702
+ var toInt = (value, defaultValue) => {
696
703
  const def = defaultValue === void 0 ? 0 : defaultValue;
697
704
  if (value === null || value === void 0) {
698
705
  return def;
699
706
  }
700
- const result = parseFloat(value);
707
+ const result = parseInt(value);
701
708
  return isNaN(result) ? def : result;
702
709
  };
703
710
 
@@ -748,6 +755,11 @@ var crush = (value) => {
748
755
  );
749
756
  };
750
757
 
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
+
751
763
  // src/object/get.ts
752
764
  var get = (value, path, defaultValue) => {
753
765
  const segments = path.split(/[\.\[\]]/g);
@@ -776,18 +788,27 @@ var invert = (obj) => {
776
788
  // src/object/keys.ts
777
789
  var keys = (value) => {
778
790
  if (!value) return [];
779
- const getKeys = (nested, paths) => {
780
- if (isPlainObject(nested)) {
781
- return Object.entries(nested).flatMap(
782
- ([k, v]) => getKeys(v, [...paths, k])
783
- );
784
- }
785
- if (isArray(nested)) {
786
- return nested.flatMap((item, i) => getKeys(item, [...paths, `${i}`]));
791
+ const keys2 = [];
792
+ const keyPath = [];
793
+ const recurse = (value2) => {
794
+ if (isPlainObject(value2)) {
795
+ for (const [prop, propValue] of Object.entries(value2)) {
796
+ keyPath.push(prop);
797
+ recurse(propValue);
798
+ keyPath.pop();
799
+ }
800
+ } else if (isArray(value2)) {
801
+ value2.forEach((item, index) => {
802
+ keyPath.push(index);
803
+ recurse(item);
804
+ keyPath.pop();
805
+ });
806
+ } else {
807
+ keys2.push(keyPath.join("."));
787
808
  }
788
- return [paths.join(".")];
789
809
  };
790
- return getKeys(value, []);
810
+ recurse(value);
811
+ return keys2;
791
812
  };
792
813
 
793
814
  // src/object/listify.ts
@@ -824,13 +845,13 @@ var mapKeys = (obj, mapFunc) => {
824
845
  };
825
846
 
826
847
  // src/object/mapValues.ts
827
- var mapValues = (obj, mapFunc) => {
848
+ function mapValues(obj, mapFunc) {
828
849
  const keys2 = Object.keys(obj);
829
850
  return keys2.reduce((acc, key) => {
830
851
  acc[key] = mapFunc(obj[key], key);
831
852
  return acc;
832
853
  }, {});
833
- };
854
+ }
834
855
 
835
856
  // src/object/omit.ts
836
857
  var omit = (obj, keys2) => {
@@ -1040,7 +1061,7 @@ var trim = (str, charsToTrim = " ") => {
1040
1061
  };
1041
1062
 
1042
1063
  // src/typed/isArray.ts
1043
- var isArray = Array.isArray;
1064
+ var isArray = /* @__PURE__ */ (() => Array.isArray)();
1044
1065
 
1045
1066
  // src/typed/isDate.ts
1046
1067
  var isDate = (value) => {
@@ -1174,6 +1195,7 @@ var isSymbol = (value) => {
1174
1195
  defer,
1175
1196
  diff,
1176
1197
  draw,
1198
+ filterKey,
1177
1199
  first,
1178
1200
  flat,
1179
1201
  fork,
@@ -50,7 +50,7 @@ declare const fork: <T>(list: readonly T[], condition: (item: T) => boolean) =>
50
50
  * where the keys are the group ids the given getGroupId function
51
51
  * produced and the value is an array of each item in that group.
52
52
  */
53
- declare const group: <T, Key extends string | number | symbol>(array: readonly T[], getGroupId: (item: T) => Key) => Partial<Record<Key, T[]>>;
53
+ declare const group: <T, Key extends string | number | symbol>(array: readonly T[], getGroupId: (item: T) => Key) => { [K in Key]?: T[] | undefined; };
54
54
 
55
55
  /**
56
56
  * Given two arrays, returns true if any elements intersect
@@ -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: (item: T, index: number) => boolean) => K[];
159
+ declare const select: <T, K>(array: readonly T[], mapper: (item: T, index: number) => K, condition?: ((item: T, index: number) => boolean) | undefined) => 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 extends string | number | symbol>(array: readonly T[], toKey?: ((item: T) => K) | undefined) => T[];
199
+ declare const unique: <T, K = T>(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
@@ -473,10 +473,10 @@ declare function inRange(number: number, end: number): boolean;
473
473
  */
474
474
  declare function inRange(number: number, start: number, end: number): boolean;
475
475
 
476
- declare const toInt: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
477
-
478
476
  declare const toFloat: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
479
477
 
478
+ declare const toInt: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
479
+
480
480
  /**
481
481
  * Merges two objects together recursivly into a new object applying
482
482
  * values from right to left. Recursion only applies to child object
@@ -511,6 +511,20 @@ 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
+
514
528
  /**
515
529
  * Dynamically get a nested value from an array or object with a
516
530
  * string.
@@ -532,7 +546,7 @@ declare const invert: <TKey extends string | number | symbol, TValue extends str
532
546
  * keys({ name: 'ra' }) // ['name']
533
547
  * keys({ name: 'ra', children: [{ name: 'hathor' }] }) // ['name', 'children.0.name']
534
548
  */
535
- declare const keys: <TValue extends object>(value: TValue) => string[];
549
+ declare const keys: (value: object) => string[];
536
550
 
537
551
  /**
538
552
  * Convert an object to a list, mapping each entry into a list item
@@ -560,7 +574,16 @@ declare const mapKeys: <TValue, TKey extends string | number | symbol, TNewKey e
560
574
  /**
561
575
  * Map over all the keys to create a new object
562
576
  */
563
- declare const mapValues: <TValue, TKey extends string | number | symbol, TNewValue>(obj: Record<TKey, TValue>, mapFunc: (value: TValue, key: TKey) => TNewValue) => Record<TKey, TNewValue>;
577
+ declare function mapValues<TValue, TKey extends string | number | symbol, TNewValue>(obj: {
578
+ [K in TKey]: TValue;
579
+ }, mapFunc: (value: TValue, key: TKey) => TNewValue): {
580
+ [K in TKey]: TNewValue;
581
+ };
582
+ declare function mapValues<TValue, TKey extends string | number | symbol, TNewValue>(obj: {
583
+ [K in TKey]?: TValue;
584
+ }, mapFunc: (value: TValue, key: TKey) => TNewValue): {
585
+ [K in TKey]?: TNewValue;
586
+ };
564
587
 
565
588
  /**
566
589
  * Omit a list of properties from an object returning a new object
@@ -699,7 +722,7 @@ declare const title: (str: string | null | undefined) => string;
699
722
  */
700
723
  declare const trim: (str: string | null | undefined, charsToTrim?: string) => string;
701
724
 
702
- declare const isArray: (arg: any) => arg is any[];
725
+ declare const isArray: (value: unknown) => value is readonly any[];
703
726
 
704
727
  declare const isDate: (value: any) => value is Date;
705
728
 
@@ -743,4 +766,4 @@ declare const isString: (value: any) => value is string;
743
766
 
744
767
  declare const isSymbol: (value: any) => value is symbol;
745
768
 
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 };
769
+ export { AggregateError, type DebounceFunction, type KeyFilter, type KeyFilterFunction, type RetryOptions, type ThrottledFunction, all, alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, 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 };
@@ -50,7 +50,7 @@ declare const fork: <T>(list: readonly T[], condition: (item: T) => boolean) =>
50
50
  * where the keys are the group ids the given getGroupId function
51
51
  * produced and the value is an array of each item in that group.
52
52
  */
53
- declare const group: <T, Key extends string | number | symbol>(array: readonly T[], getGroupId: (item: T) => Key) => Partial<Record<Key, T[]>>;
53
+ declare const group: <T, Key extends string | number | symbol>(array: readonly T[], getGroupId: (item: T) => Key) => { [K in Key]?: T[] | undefined; };
54
54
 
55
55
  /**
56
56
  * Given two arrays, returns true if any elements intersect
@@ -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: (item: T, index: number) => boolean) => K[];
159
+ declare const select: <T, K>(array: readonly T[], mapper: (item: T, index: number) => K, condition?: ((item: T, index: number) => boolean) | undefined) => 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 extends string | number | symbol>(array: readonly T[], toKey?: ((item: T) => K) | undefined) => T[];
199
+ declare const unique: <T, K = T>(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
@@ -473,10 +473,10 @@ declare function inRange(number: number, end: number): boolean;
473
473
  */
474
474
  declare function inRange(number: number, start: number, end: number): boolean;
475
475
 
476
- declare const toInt: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
477
-
478
476
  declare const toFloat: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
479
477
 
478
+ declare const toInt: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
479
+
480
480
  /**
481
481
  * Merges two objects together recursivly into a new object applying
482
482
  * values from right to left. Recursion only applies to child object
@@ -511,6 +511,20 @@ 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
+
514
528
  /**
515
529
  * Dynamically get a nested value from an array or object with a
516
530
  * string.
@@ -532,7 +546,7 @@ declare const invert: <TKey extends string | number | symbol, TValue extends str
532
546
  * keys({ name: 'ra' }) // ['name']
533
547
  * keys({ name: 'ra', children: [{ name: 'hathor' }] }) // ['name', 'children.0.name']
534
548
  */
535
- declare const keys: <TValue extends object>(value: TValue) => string[];
549
+ declare const keys: (value: object) => string[];
536
550
 
537
551
  /**
538
552
  * Convert an object to a list, mapping each entry into a list item
@@ -560,7 +574,16 @@ declare const mapKeys: <TValue, TKey extends string | number | symbol, TNewKey e
560
574
  /**
561
575
  * Map over all the keys to create a new object
562
576
  */
563
- declare const mapValues: <TValue, TKey extends string | number | symbol, TNewValue>(obj: Record<TKey, TValue>, mapFunc: (value: TValue, key: TKey) => TNewValue) => Record<TKey, TNewValue>;
577
+ declare function mapValues<TValue, TKey extends string | number | symbol, TNewValue>(obj: {
578
+ [K in TKey]: TValue;
579
+ }, mapFunc: (value: TValue, key: TKey) => TNewValue): {
580
+ [K in TKey]: TNewValue;
581
+ };
582
+ declare function mapValues<TValue, TKey extends string | number | symbol, TNewValue>(obj: {
583
+ [K in TKey]?: TValue;
584
+ }, mapFunc: (value: TValue, key: TKey) => TNewValue): {
585
+ [K in TKey]?: TNewValue;
586
+ };
564
587
 
565
588
  /**
566
589
  * Omit a list of properties from an object returning a new object
@@ -699,7 +722,7 @@ declare const title: (str: string | null | undefined) => string;
699
722
  */
700
723
  declare const trim: (str: string | null | undefined, charsToTrim?: string) => string;
701
724
 
702
- declare const isArray: (arg: any) => arg is any[];
725
+ declare const isArray: (value: unknown) => value is readonly any[];
703
726
 
704
727
  declare const isDate: (value: any) => value is Date;
705
728
 
@@ -743,4 +766,4 @@ declare const isString: (value: any) => value is string;
743
766
 
744
767
  declare const isSymbol: (value: any) => value is symbol;
745
768
 
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 };
769
+ export { AggregateError, type DebounceFunction, type KeyFilter, type KeyFilterFunction, type RetryOptions, type ThrottledFunction, all, alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, 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 };
@@ -193,9 +193,10 @@ 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;
196
197
  return array.reduce((acc, item, index) => {
197
- if (!condition(item, index)) return acc;
198
- acc.push(mapper(item, index));
198
+ if (condition) condition(item, index) && acc.push(mapper(item, index));
199
+ else (mapped = mapper(item, index)) != null && acc.push(mapped);
199
200
  return acc;
200
201
  }, []);
201
202
  };
@@ -241,13 +242,18 @@ var toggle = (list2, item, toKey, options) => {
241
242
 
242
243
  // src/array/unique.ts
243
244
  var unique = (array, toKey) => {
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);
245
+ if (toKey) {
246
+ const keys2 = /* @__PURE__ */ new Set();
247
+ return array.reduce((acc, item) => {
248
+ const key = toKey(item);
249
+ if (!keys2.has(key)) {
250
+ keys2.add(key);
251
+ acc.push(item);
252
+ }
253
+ return acc;
254
+ }, []);
255
+ }
256
+ return [...new Set(array)];
251
257
  };
252
258
 
253
259
  // src/array/zip.ts
@@ -559,23 +565,23 @@ function inRange(number, start, end) {
559
565
  return number >= Math.min(start, end) && number < Math.max(start, end);
560
566
  }
561
567
 
562
- // src/number/toInt.ts
563
- var toInt = (value, defaultValue) => {
568
+ // src/number/toFloat.ts
569
+ var toFloat = (value, defaultValue) => {
564
570
  const def = defaultValue === void 0 ? 0 : defaultValue;
565
571
  if (value === null || value === void 0) {
566
572
  return def;
567
573
  }
568
- const result = parseInt(value);
574
+ const result = parseFloat(value);
569
575
  return isNaN(result) ? def : result;
570
576
  };
571
577
 
572
- // src/number/toFloat.ts
573
- var toFloat = (value, defaultValue) => {
578
+ // src/number/toInt.ts
579
+ var toInt = (value, defaultValue) => {
574
580
  const def = defaultValue === void 0 ? 0 : defaultValue;
575
581
  if (value === null || value === void 0) {
576
582
  return def;
577
583
  }
578
- const result = parseFloat(value);
584
+ const result = parseInt(value);
579
585
  return isNaN(result) ? def : result;
580
586
  };
581
587
 
@@ -626,6 +632,11 @@ var crush = (value) => {
626
632
  );
627
633
  };
628
634
 
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
+
629
640
  // src/object/get.ts
630
641
  var get = (value, path, defaultValue) => {
631
642
  const segments = path.split(/[\.\[\]]/g);
@@ -654,18 +665,27 @@ var invert = (obj) => {
654
665
  // src/object/keys.ts
655
666
  var keys = (value) => {
656
667
  if (!value) return [];
657
- const getKeys = (nested, paths) => {
658
- if (isPlainObject(nested)) {
659
- return Object.entries(nested).flatMap(
660
- ([k, v]) => getKeys(v, [...paths, k])
661
- );
662
- }
663
- if (isArray(nested)) {
664
- return nested.flatMap((item, i) => getKeys(item, [...paths, `${i}`]));
668
+ const keys2 = [];
669
+ const keyPath = [];
670
+ const recurse = (value2) => {
671
+ if (isPlainObject(value2)) {
672
+ for (const [prop, propValue] of Object.entries(value2)) {
673
+ keyPath.push(prop);
674
+ recurse(propValue);
675
+ keyPath.pop();
676
+ }
677
+ } else if (isArray(value2)) {
678
+ value2.forEach((item, index) => {
679
+ keyPath.push(index);
680
+ recurse(item);
681
+ keyPath.pop();
682
+ });
683
+ } else {
684
+ keys2.push(keyPath.join("."));
665
685
  }
666
- return [paths.join(".")];
667
686
  };
668
- return getKeys(value, []);
687
+ recurse(value);
688
+ return keys2;
669
689
  };
670
690
 
671
691
  // src/object/listify.ts
@@ -702,13 +722,13 @@ var mapKeys = (obj, mapFunc) => {
702
722
  };
703
723
 
704
724
  // src/object/mapValues.ts
705
- var mapValues = (obj, mapFunc) => {
725
+ function mapValues(obj, mapFunc) {
706
726
  const keys2 = Object.keys(obj);
707
727
  return keys2.reduce((acc, key) => {
708
728
  acc[key] = mapFunc(obj[key], key);
709
729
  return acc;
710
730
  }, {});
711
- };
731
+ }
712
732
 
713
733
  // src/object/omit.ts
714
734
  var omit = (obj, keys2) => {
@@ -918,7 +938,7 @@ var trim = (str, charsToTrim = " ") => {
918
938
  };
919
939
 
920
940
  // src/typed/isArray.ts
921
- var isArray = Array.isArray;
941
+ var isArray = /* @__PURE__ */ (() => Array.isArray)();
922
942
 
923
943
  // src/typed/isDate.ts
924
944
  var isDate = (value) => {
@@ -1051,6 +1071,7 @@ export {
1051
1071
  defer,
1052
1072
  diff,
1053
1073
  draw,
1074
+ filterKey,
1054
1075
  first,
1055
1076
  flat,
1056
1077
  fork,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radashi",
3
- "version": "12.2.0-beta.45f2ac3",
3
+ "version": "12.2.0-beta.649f0d1",
4
4
  "description": "Functional utility library - modern, simple, typed, powerful",
5
5
  "sideEffects": false,
6
6
  "author": "Alec Larson",
@@ -38,15 +38,15 @@
38
38
  "repository": {
39
39
  "url": "https://github.com/radashi-org/radashi"
40
40
  },
41
- "main": "dist/index.cjs",
42
- "module": "dist/index.js",
43
- "types": "dist/index.d.cts",
41
+ "main": "dist/radashi.cjs",
42
+ "module": "dist/radashi.js",
43
+ "types": "dist/radashi.d.cts",
44
44
  "exports": {
45
45
  "require": {
46
- "types": "./dist/index.d.cts",
47
- "default": "./dist/index.cjs"
46
+ "types": "./dist/radashi.d.cts",
47
+ "default": "./dist/radashi.cjs"
48
48
  },
49
- "types": "./dist/index.d.ts",
50
- "default": "./dist/index.js"
49
+ "types": "./dist/radashi.d.ts",
50
+ "default": "./dist/radashi.js"
51
51
  }
52
52
  }