radashi 12.3.4 → 12.5.0-beta.8a7266a

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
@@ -204,6 +204,20 @@ function objectify(array, getKey, getValue = (item) => item) {
204
204
  );
205
205
  }
206
206
 
207
+ // src/array/pluck.ts
208
+ function pluck(array, mappings) {
209
+ return array.map(
210
+ mappings ? (item) => mappings.map(
211
+ (mapping) => isFunction(mapping) ? mapping(item) : item[mapping]
212
+ ) : Object.values
213
+ );
214
+ }
215
+
216
+ // src/array/remove.ts
217
+ function remove(array, predicate) {
218
+ return array.filter((item) => !predicate(item));
219
+ }
220
+
207
221
  // src/array/replace.ts
208
222
  function replace(array, newItem, match) {
209
223
  if (!array) {
@@ -525,17 +539,16 @@ async function reduce(array, reducer, initialValue) {
525
539
  if (!array) {
526
540
  array = [];
527
541
  }
528
- const indices = array.keys();
542
+ let index = 0;
529
543
  let acc = initialValue;
530
544
  if (acc === void 0 && arguments.length < 3) {
531
545
  if (!array.length) {
532
546
  throw new TypeError("Reduce of empty array with no initial value");
533
547
  }
534
- acc = array[0];
535
- indices.next();
548
+ acc = array[index++];
536
549
  }
537
- for (const index of indices) {
538
- acc = await reducer(acc, array[index], index);
550
+ while (index < array.length) {
551
+ acc = await reducer(acc, array[index], index++);
539
552
  }
540
553
  return acc;
541
554
  }
@@ -593,6 +606,19 @@ function timeout(ms, error) {
593
606
  );
594
607
  }
595
608
 
609
+ // src/async/toResult.ts
610
+ async function toResult(promise) {
611
+ try {
612
+ const result = await promise;
613
+ return [void 0, result];
614
+ } catch (error) {
615
+ if (isError(error)) {
616
+ return [error, void 0];
617
+ }
618
+ throw error;
619
+ }
620
+ }
621
+
596
622
  // src/async/tryit.ts
597
623
  function tryit(func) {
598
624
  return (...args) => {
@@ -702,6 +728,21 @@ function memo(func, options = {}) {
702
728
  return memoize({}, func, options.key ?? null, options.ttl ?? null);
703
729
  }
704
730
 
731
+ // src/curry/memoLastCall.ts
732
+ function memoLastCall(fn) {
733
+ let lastArgs = null;
734
+ let lastResult = null;
735
+ return (...args) => {
736
+ if (lastArgs && lastArgs.length === args.length && lastArgs.every((arg, i) => Object.is(arg, args[i]))) {
737
+ return lastResult;
738
+ }
739
+ const result = fn(...args);
740
+ lastArgs = args;
741
+ lastResult = result;
742
+ return result;
743
+ };
744
+ }
745
+
705
746
  // src/curry/once.ts
706
747
  var once = /* @__PURE__ */ (() => {
707
748
  const onceSymbol = /* @__PURE__ */ Symbol();
@@ -1575,6 +1616,20 @@ function trim(str, charsToTrim = " ") {
1575
1616
  // src/typed/isArray.ts
1576
1617
  var isArray = /* @__PURE__ */ (() => Array.isArray)();
1577
1618
 
1619
+ // src/typed/isAsyncIterable.ts
1620
+ var asyncIteratorSymbol = (
1621
+ /* c8 ignore next */
1622
+ Symbol.asyncIterator || Symbol.for("Symbol.asyncIterator")
1623
+ );
1624
+ function isAsyncIterable(value) {
1625
+ return !!value && typeof value === "object" && typeof value[asyncIteratorSymbol] === "function";
1626
+ }
1627
+
1628
+ // src/typed/isBigInt.ts
1629
+ function isBigInt(value) {
1630
+ return typeof value === "bigint";
1631
+ }
1632
+
1578
1633
  // src/typed/isBoolean.ts
1579
1634
  function isBoolean(value) {
1580
1635
  return typeof value === "boolean";
@@ -1592,24 +1647,12 @@ function isDate(value) {
1592
1647
 
1593
1648
  // src/typed/isEmpty.ts
1594
1649
  function isEmpty(value) {
1595
- if (value === true || value === false) {
1596
- return true;
1597
- }
1598
- if (value === null || value === void 0) {
1599
- return true;
1600
- }
1601
- if (isNumber(value)) {
1602
- return value === 0;
1650
+ if (typeof value !== "object" || value === null) {
1651
+ return !value || value === true;
1603
1652
  }
1604
1653
  if (isDate(value)) {
1605
1654
  return Number.isNaN(value.getTime());
1606
1655
  }
1607
- if (isFunction(value)) {
1608
- return false;
1609
- }
1610
- if (isSymbol(value)) {
1611
- return false;
1612
- }
1613
1656
  const length = value.length;
1614
1657
  if (isNumber(length)) {
1615
1658
  return length === 0;
@@ -1827,6 +1870,8 @@ exports.inRange = inRange;
1827
1870
  exports.intersects = intersects;
1828
1871
  exports.invert = invert;
1829
1872
  exports.isArray = isArray;
1873
+ exports.isAsyncIterable = isAsyncIterable;
1874
+ exports.isBigInt = isBigInt;
1830
1875
  exports.isBoolean = isBoolean;
1831
1876
  exports.isClass = isClass;
1832
1877
  exports.isDate = isDate;
@@ -1870,6 +1915,7 @@ exports.mapValues = mapValues;
1870
1915
  exports.mapify = mapify;
1871
1916
  exports.max = max;
1872
1917
  exports.memo = memo;
1918
+ exports.memoLastCall = memoLastCall;
1873
1919
  exports.merge = merge;
1874
1920
  exports.min = min;
1875
1921
  exports.noop = noop;
@@ -1881,10 +1927,12 @@ exports.partial = partial;
1881
1927
  exports.partob = partob;
1882
1928
  exports.pascal = pascal;
1883
1929
  exports.pick = pick;
1930
+ exports.pluck = pluck;
1884
1931
  exports.proxied = proxied;
1885
1932
  exports.random = random;
1886
1933
  exports.range = range;
1887
1934
  exports.reduce = reduce;
1935
+ exports.remove = remove;
1888
1936
  exports.replace = replace;
1889
1937
  exports.replaceOrAppend = replaceOrAppend;
1890
1938
  exports.retry = retry;
@@ -1908,6 +1956,7 @@ exports.timeout = timeout;
1908
1956
  exports.title = title;
1909
1957
  exports.toFloat = toFloat;
1910
1958
  exports.toInt = toInt;
1959
+ exports.toResult = toResult;
1911
1960
  exports.toggle = toggle;
1912
1961
  exports.traverse = traverse;
1913
1962
  exports.trim = trim;