radashi 12.2.0-beta.437b4fe → 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 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
- <img src="https://github.com/radashi-org/radashi/raw/b80a0e4/img/rule.png" width="100%" />
54
+ &nbsp;
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
- <img src="https://github.com/radashi-org/radashi/raw/b80a0e4/img/rule.png" width="100%" />
72
+ &nbsp;
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
- <img src="https://github.com/radashi-org/radashi/raw/b80a0e4/img/rule.png" width="100%" />
84
+ &nbsp;
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/46c8897/img/footer.png" alt="Radashi" width="100%" />
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
@@ -315,10 +315,9 @@ var replaceOrAppend = (list2, newItem, match) => {
315
315
  // src/array/select.ts
316
316
  var select = (array, mapper, condition) => {
317
317
  if (!array) return [];
318
- let mapped;
319
318
  return array.reduce((acc, item, index) => {
320
- if (condition) condition(item, index) && acc.push(mapper(item, index));
321
- else (mapped = mapper(item, index)) != null && acc.push(mapped);
319
+ if (!condition(item, index)) return acc;
320
+ acc.push(mapper(item, index));
322
321
  return acc;
323
322
  }, []);
324
323
  };
@@ -364,18 +363,13 @@ var toggle = (list2, item, toKey, options) => {
364
363
 
365
364
  // src/array/unique.ts
366
365
  var unique = (array, toKey) => {
367
- if (toKey) {
368
- const keys2 = /* @__PURE__ */ new Set();
369
- return array.reduce((acc, item) => {
370
- const key = toKey(item);
371
- if (!keys2.has(key)) {
372
- keys2.add(key);
373
- acc.push(item);
374
- }
375
- return acc;
376
- }, []);
377
- }
378
- 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);
379
373
  };
380
374
 
381
375
  // src/array/zip.ts
@@ -1046,7 +1040,7 @@ var trim = (str, charsToTrim = " ") => {
1046
1040
  };
1047
1041
 
1048
1042
  // src/typed/isArray.ts
1049
- var isArray = /* @__PURE__ */ (() => Array.isArray)();
1043
+ var isArray = Array.isArray;
1050
1044
 
1051
1045
  // src/typed/isDate.ts
1052
1046
  var isDate = (value) => {
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?: ((item: T, index: number) => boolean) | undefined) => K[];
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 = T>(array: readonly T[], toKey?: ((item: T) => K) | undefined) => T[];
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
@@ -699,7 +699,7 @@ declare const title: (str: string | null | undefined) => string;
699
699
  */
700
700
  declare const trim: (str: string | null | undefined, charsToTrim?: string) => string;
701
701
 
702
- declare const isArray: (value: unknown) => value is readonly any[];
702
+ declare const isArray: (arg: any) => arg is any[];
703
703
 
704
704
  declare const isDate: (value: any) => value is Date;
705
705
 
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?: ((item: T, index: number) => boolean) | undefined) => K[];
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 = T>(array: readonly T[], toKey?: ((item: T) => K) | undefined) => T[];
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
@@ -699,7 +699,7 @@ declare const title: (str: string | null | undefined) => string;
699
699
  */
700
700
  declare const trim: (str: string | null | undefined, charsToTrim?: string) => string;
701
701
 
702
- declare const isArray: (value: unknown) => value is readonly any[];
702
+ declare const isArray: (arg: any) => arg is any[];
703
703
 
704
704
  declare const isDate: (value: any) => value is Date;
705
705
 
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) condition(item, index) && acc.push(mapper(item, index));
199
- else (mapped = mapper(item, index)) != null && acc.push(mapped);
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
- 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)];
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
@@ -924,7 +918,7 @@ var trim = (str, charsToTrim = " ") => {
924
918
  };
925
919
 
926
920
  // src/typed/isArray.ts
927
- var isArray = /* @__PURE__ */ (() => Array.isArray)();
921
+ var isArray = Array.isArray;
928
922
 
929
923
  // src/typed/isDate.ts
930
924
  var isDate = (value) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radashi",
3
- "version": "12.2.0-beta.437b4fe",
3
+ "version": "12.2.0-beta.45f2ac3",
4
4
  "description": "Functional utility library - modern, simple, typed, powerful",
5
5
  "sideEffects": false,
6
6
  "author": "Alec Larson",