radashi 12.9.4 → 12.9.5

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
@@ -303,12 +303,12 @@ function selectFirst(array, mapper, condition) {
303
303
  if (!array) {
304
304
  return void 0;
305
305
  }
306
- let foundIndex = -1;
307
- const found = array.find((item, index) => {
308
- foundIndex = index;
306
+ let foundItem;
307
+ const foundIndex = array.findIndex((item, index) => {
308
+ foundItem = item;
309
309
  return condition ? condition(item, index) : mapper(item, index) != null;
310
310
  });
311
- return found === void 0 ? void 0 : mapper(found, foundIndex);
311
+ return foundIndex === -1 ? void 0 : mapper(foundItem, foundIndex);
312
312
  }
313
313
 
314
314
  // src/array/shift.ts
@@ -352,8 +352,8 @@ function toggle(array, item, toKey, options) {
352
352
  } else {
353
353
  matcher = (x) => x === item;
354
354
  }
355
- const existing = array.find(matcher);
356
- if (existing !== void 0) {
355
+ const existingIndex = array.findIndex(matcher);
356
+ if (existingIndex !== -1) {
357
357
  return array.filter((x, idx) => !matcher(x, idx));
358
358
  }
359
359
  return (options == null ? void 0 : options.strategy) === "prepend" ? [item, ...array] : [...array, item];
package/dist/radashi.js CHANGED
@@ -301,12 +301,12 @@ function selectFirst(array, mapper, condition) {
301
301
  if (!array) {
302
302
  return void 0;
303
303
  }
304
- let foundIndex = -1;
305
- const found = array.find((item, index) => {
306
- foundIndex = index;
304
+ let foundItem;
305
+ const foundIndex = array.findIndex((item, index) => {
306
+ foundItem = item;
307
307
  return condition ? condition(item, index) : mapper(item, index) != null;
308
308
  });
309
- return found === void 0 ? void 0 : mapper(found, foundIndex);
309
+ return foundIndex === -1 ? void 0 : mapper(foundItem, foundIndex);
310
310
  }
311
311
 
312
312
  // src/array/shift.ts
@@ -350,8 +350,8 @@ function toggle(array, item, toKey, options) {
350
350
  } else {
351
351
  matcher = (x) => x === item;
352
352
  }
353
- const existing = array.find(matcher);
354
- if (existing !== void 0) {
353
+ const existingIndex = array.findIndex(matcher);
354
+ if (existingIndex !== -1) {
355
355
  return array.filter((x, idx) => !matcher(x, idx));
356
356
  }
357
357
  return (options == null ? void 0 : options.strategy) === "prepend" ? [item, ...array] : [...array, item];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radashi",
3
- "version": "12.9.4",
3
+ "version": "12.9.5",
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": {