radashi 12.9.2 → 12.9.4

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/radashi.cjs CHANGED
@@ -72,17 +72,15 @@ function concat(...values) {
72
72
 
73
73
  // src/array/counting.ts
74
74
  function counting(array, identity2) {
75
+ const counts = /* @__PURE__ */ Object.create(null);
75
76
  if (!array) {
76
- return {};
77
+ return counts;
77
78
  }
78
- return array.reduce(
79
- (acc, item) => {
80
- const id = identity2(item);
81
- acc[id] = (acc[id] ?? 0) + 1;
82
- return acc;
83
- },
84
- {}
85
- );
79
+ for (const item of array) {
80
+ const id = identity2(item);
81
+ counts[id] = (counts[id] ?? 0) + 1;
82
+ }
83
+ return counts;
86
84
  }
87
85
 
88
86
  // src/array/diff.ts
@@ -96,14 +94,11 @@ function diff(root, other, identity2 = (t) => t) {
96
94
  if (!(other == null ? void 0 : other.length)) {
97
95
  return [...root];
98
96
  }
99
- const bKeys = other.reduce(
100
- (acc, item) => {
101
- acc[identity2(item)] = true;
102
- return acc;
103
- },
104
- {}
105
- );
106
- return root.filter((a) => !bKeys[identity2(a)]);
97
+ const bKeys = /* @__PURE__ */ new Set();
98
+ for (const item of other) {
99
+ bKeys.add(identity2(item));
100
+ }
101
+ return root.filter((a) => !bKeys.has(identity2(a)));
107
102
  }
108
103
 
109
104
  // src/array/first.ts
@@ -267,10 +262,10 @@ function replace(array, newItem, match) {
267
262
 
268
263
  // src/array/replaceOrAppend.ts
269
264
  function replaceOrAppend(array, newItem, match) {
270
- if (!array && !newItem) {
265
+ if (!array && newItem == null) {
271
266
  return [];
272
267
  }
273
- if (!newItem) {
268
+ if (newItem == null) {
274
269
  return [...array];
275
270
  }
276
271
  if (!array) {
@@ -469,7 +469,7 @@ declare function replace<T>(array: readonly T[], newItem: T, match: (item: T, id
469
469
  * ```
470
470
  * @version 12.1.0
471
471
  */
472
- declare function replaceOrAppend<T>(array: readonly T[], newItem: T, match: (a: T, idx: number) => boolean): T[];
472
+ declare function replaceOrAppend<T>(array: readonly T[], newItem: T | null | undefined, match: (a: T, idx: number) => boolean): T[];
473
473
 
474
474
  /**
475
475
  * Select performs a filter and a mapper inside of a reduce, only
package/dist/radashi.d.ts CHANGED
@@ -469,7 +469,7 @@ declare function replace<T>(array: readonly T[], newItem: T, match: (item: T, id
469
469
  * ```
470
470
  * @version 12.1.0
471
471
  */
472
- declare function replaceOrAppend<T>(array: readonly T[], newItem: T, match: (a: T, idx: number) => boolean): T[];
472
+ declare function replaceOrAppend<T>(array: readonly T[], newItem: T | null | undefined, match: (a: T, idx: number) => boolean): T[];
473
473
 
474
474
  /**
475
475
  * Select performs a filter and a mapper inside of a reduce, only
package/dist/radashi.js CHANGED
@@ -70,17 +70,15 @@ function concat(...values) {
70
70
 
71
71
  // src/array/counting.ts
72
72
  function counting(array, identity2) {
73
+ const counts = /* @__PURE__ */ Object.create(null);
73
74
  if (!array) {
74
- return {};
75
+ return counts;
75
76
  }
76
- return array.reduce(
77
- (acc, item) => {
78
- const id = identity2(item);
79
- acc[id] = (acc[id] ?? 0) + 1;
80
- return acc;
81
- },
82
- {}
83
- );
77
+ for (const item of array) {
78
+ const id = identity2(item);
79
+ counts[id] = (counts[id] ?? 0) + 1;
80
+ }
81
+ return counts;
84
82
  }
85
83
 
86
84
  // src/array/diff.ts
@@ -94,14 +92,11 @@ function diff(root, other, identity2 = (t) => t) {
94
92
  if (!(other == null ? void 0 : other.length)) {
95
93
  return [...root];
96
94
  }
97
- const bKeys = other.reduce(
98
- (acc, item) => {
99
- acc[identity2(item)] = true;
100
- return acc;
101
- },
102
- {}
103
- );
104
- return root.filter((a) => !bKeys[identity2(a)]);
95
+ const bKeys = /* @__PURE__ */ new Set();
96
+ for (const item of other) {
97
+ bKeys.add(identity2(item));
98
+ }
99
+ return root.filter((a) => !bKeys.has(identity2(a)));
105
100
  }
106
101
 
107
102
  // src/array/first.ts
@@ -265,10 +260,10 @@ function replace(array, newItem, match) {
265
260
 
266
261
  // src/array/replaceOrAppend.ts
267
262
  function replaceOrAppend(array, newItem, match) {
268
- if (!array && !newItem) {
263
+ if (!array && newItem == null) {
269
264
  return [];
270
265
  }
271
- if (!newItem) {
266
+ if (newItem == null) {
272
267
  return [...array];
273
268
  }
274
269
  if (!array) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radashi",
3
- "version": "12.9.2",
3
+ "version": "12.9.4",
4
4
  "type": "module",
5
5
  "description": "The modern, community-first TypeScript toolkit with all of the fast, readable, and minimal utility functions you need. Type-safe, dependency-free, tree-shakeable, fully tested.",
6
6
  "repository": {