radashi 12.2.0 → 12.2.2
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 +1 -1
- package/dist/radashi.cjs +12 -17
- package/dist/radashi.d.cts +38 -22
- package/dist/radashi.d.ts +38 -22
- package/dist/radashi.js +12 -17
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<img src="https://github.com/radashi-org/radashi/raw/main/.github/img/banner.png" alt="Radashi" width="100%" />
|
|
6
6
|
</p>
|
|
7
7
|
<a href="https://github.com/radashi-org/radashi/blob/main/LICENSE.md"><img src="https://img.shields.io/npm/l/radashi" alt="License" /></a>
|
|
8
|
-
<a href="https://github.com/radashi-org/radashi/actions/workflows/
|
|
8
|
+
<a href="https://github.com/radashi-org/radashi/actions/workflows/check-main.yml"><img src="https://img.shields.io/github/actions/workflow/status/radashi-org/radashi/check-main.yml?logo=github" alt="Build Status" /></a>
|
|
9
9
|
<a href="https://app.codecov.io/gh/radashi-org/radashi/tree/main/src"><img src="https://img.shields.io/codecov/c/github/radashi-org/radashi?logo=codecov" alt="Codecov" /></a>
|
|
10
10
|
<a href="https://biomejs.dev/"><img src="https://img.shields.io/badge/code_style-biome.js-blue?logo=biome" alt="Code Style: Biome.js" /></a>
|
|
11
11
|
<a href="https://github.com/radashi-org/radashi/discussions"><img src="https://img.shields.io/github/discussions/radashi-org/radashi?logo=github" alt="GitHub Discussions" /></a>
|
package/dist/radashi.cjs
CHANGED
|
@@ -358,20 +358,17 @@ function zipToObject(keys2, values) {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
// src/async/AggregateError.ts
|
|
361
|
-
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() =>
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
|
|
371
|
-
this.errors = errors;
|
|
372
|
-
}
|
|
361
|
+
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => globalThis.AggregateError ?? class AggregateError extends Error {
|
|
362
|
+
constructor(errors = []) {
|
|
363
|
+
var _a, _b;
|
|
364
|
+
super();
|
|
365
|
+
const name = ((_a = errors.find((e) => e.name)) == null ? void 0 : _a.name) ?? "";
|
|
366
|
+
this.name = `AggregateError(${name}...)`;
|
|
367
|
+
this.message = `AggregateError with ${errors.length} errors`;
|
|
368
|
+
this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
|
|
369
|
+
this.errors = errors;
|
|
373
370
|
}
|
|
374
|
-
)
|
|
371
|
+
})();
|
|
375
372
|
|
|
376
373
|
// src/async/all.ts
|
|
377
374
|
async function all(promises) {
|
|
@@ -1060,8 +1057,7 @@ function mapKeys(obj, mapFunc) {
|
|
|
1060
1057
|
|
|
1061
1058
|
// src/object/mapValues.ts
|
|
1062
1059
|
function mapValues(obj, mapFunc) {
|
|
1063
|
-
|
|
1064
|
-
return keys2.reduce(
|
|
1060
|
+
return Object.keys(obj).reduce(
|
|
1065
1061
|
(acc, key) => {
|
|
1066
1062
|
acc[key] = mapFunc(obj[key], key);
|
|
1067
1063
|
return acc;
|
|
@@ -1130,8 +1126,7 @@ function shake(obj, filter = (value) => value === void 0) {
|
|
|
1130
1126
|
if (!obj) {
|
|
1131
1127
|
return {};
|
|
1132
1128
|
}
|
|
1133
|
-
|
|
1134
|
-
return keys2.reduce((acc, key) => {
|
|
1129
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
1135
1130
|
if (!filter(obj[key])) {
|
|
1136
1131
|
acc[key] = obj[key];
|
|
1137
1132
|
}
|
package/dist/radashi.d.cts
CHANGED
|
@@ -125,8 +125,7 @@ declare function diff<T>(root: readonly T[], other: readonly T[], identity?: (it
|
|
|
125
125
|
* ```
|
|
126
126
|
* @version 12.1.0
|
|
127
127
|
*/
|
|
128
|
-
declare function first<
|
|
129
|
-
declare function first<T, U>(array: readonly T[], defaultValue: U): T | U;
|
|
128
|
+
declare function first<const TArray extends readonly any[], const TDefault = undefined>(array: TArray, defaultValue?: TDefault): TArray extends readonly [infer TFirst, ...any[]] ? TFirst : TArray[number] | TDefault;
|
|
130
129
|
|
|
131
130
|
/**
|
|
132
131
|
* Given an array of arrays, returns a single dimensional array with
|
|
@@ -220,8 +219,7 @@ declare function iterate<T>(count: number, func: (currentValue: T, iteration: nu
|
|
|
220
219
|
* ```
|
|
221
220
|
* @version 12.1.0
|
|
222
221
|
*/
|
|
223
|
-
declare function last<
|
|
224
|
-
declare function last<T, U>(array: readonly T[], defaultValue: U): T | U;
|
|
222
|
+
declare function last<const TArray extends readonly any[], const TDefault = undefined>(array: TArray, defaultValue?: TDefault): TArray extends readonly [...any[], infer TLast] ? TLast : TArray[number] | TDefault;
|
|
225
223
|
|
|
226
224
|
/**
|
|
227
225
|
* Creates a list of given start, end, value, and step parameters.
|
|
@@ -530,8 +528,16 @@ declare function zip<T1, T2>(array1: readonly T1[], array2: readonly T2[]): [T1,
|
|
|
530
528
|
* ```
|
|
531
529
|
* @version 12.1.0
|
|
532
530
|
*/
|
|
533
|
-
declare function zipToObject<K extends string | number | symbol, V>(keys: K[], values: V | ((key: K, idx: number) => V) | V[]): Record<K, V>;
|
|
531
|
+
declare function zipToObject<K extends string | number | symbol, V>(keys: readonly K[], values: V | ((key: K, idx: number) => V) | readonly V[]): Record<K, V>;
|
|
534
532
|
|
|
533
|
+
interface AggregateError extends Error {
|
|
534
|
+
errors: any[];
|
|
535
|
+
}
|
|
536
|
+
interface AggregateErrorConstructor {
|
|
537
|
+
new (errors: Iterable<any>, message?: string): AggregateError;
|
|
538
|
+
(errors: Iterable<any>, message?: string): AggregateError;
|
|
539
|
+
readonly prototype: AggregateError;
|
|
540
|
+
}
|
|
535
541
|
/**
|
|
536
542
|
* The `AggregateError` object represents an error when several errors
|
|
537
543
|
* need to be wrapped in a single error.
|
|
@@ -1774,15 +1780,8 @@ declare function mapKeys<TValue, TKey extends string | number | symbol, TNewKey
|
|
|
1774
1780
|
* ```
|
|
1775
1781
|
* @version 12.1.0
|
|
1776
1782
|
*/
|
|
1777
|
-
declare function mapValues<
|
|
1778
|
-
[K in
|
|
1779
|
-
}, mapFunc: (value: TValue, key: TKey) => TNewValue): {
|
|
1780
|
-
[K in TKey]: TNewValue;
|
|
1781
|
-
};
|
|
1782
|
-
declare function mapValues<TValue, TKey extends string | number | symbol, TNewValue>(obj: {
|
|
1783
|
-
[K in TKey]?: TValue;
|
|
1784
|
-
}, mapFunc: (value: TValue, key: TKey) => TNewValue): {
|
|
1785
|
-
[K in TKey]?: TNewValue;
|
|
1783
|
+
declare function mapValues<T extends object, U>(obj: T, mapFunc: (value: Required<T>[keyof T], key: keyof T) => U): {
|
|
1784
|
+
[K in keyof T]: U;
|
|
1786
1785
|
};
|
|
1787
1786
|
|
|
1788
1787
|
/**
|
|
@@ -1842,6 +1841,8 @@ declare function set<T extends object, K>(initial: T, path: string, value: K): T
|
|
|
1842
1841
|
* Removes (shakes out) undefined entries from an object. Optional
|
|
1843
1842
|
* second argument shakes out values by custom evaluation.
|
|
1844
1843
|
*
|
|
1844
|
+
* Note that non-enumerable keys are never shaken out.
|
|
1845
|
+
*
|
|
1845
1846
|
* @see https://radashi.js.org/reference/object/shake
|
|
1846
1847
|
* @example
|
|
1847
1848
|
* ```ts
|
|
@@ -1851,7 +1852,10 @@ declare function set<T extends object, K>(initial: T, path: string, value: K): T
|
|
|
1851
1852
|
* ```
|
|
1852
1853
|
* @version 12.1.0
|
|
1853
1854
|
*/
|
|
1854
|
-
declare function shake<T extends object>(obj: T
|
|
1855
|
+
declare function shake<T extends object>(obj: T): {
|
|
1856
|
+
[K in keyof T]: Exclude<T[K], undefined>;
|
|
1857
|
+
};
|
|
1858
|
+
declare function shake<T extends object>(obj: T, filter: ((value: unknown) => boolean) | undefined): T;
|
|
1855
1859
|
|
|
1856
1860
|
interface TraverseOptions<Key = string | number | symbol> {
|
|
1857
1861
|
/**
|
|
@@ -1980,7 +1984,7 @@ declare function upperize<T extends Record<string, any>>(obj: T): UppercaseKeys<
|
|
|
1980
1984
|
* ```
|
|
1981
1985
|
* @version 12.1.0
|
|
1982
1986
|
*/
|
|
1983
|
-
declare function draw<T>(array: readonly T[]
|
|
1987
|
+
declare function draw<const T extends readonly any[]>(array: T): T extends readonly [any, ...any[]] ? T[number] : T[number] | null;
|
|
1984
1988
|
|
|
1985
1989
|
/**
|
|
1986
1990
|
* Generates a random integer between min and max. Both min and max
|
|
@@ -2240,15 +2244,14 @@ declare function isDate(value: unknown): value is Date;
|
|
|
2240
2244
|
|
|
2241
2245
|
/**
|
|
2242
2246
|
* Return true if the given value is empty.
|
|
2247
|
+
* This function also uses [Type Guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards) to ensure type safety
|
|
2243
2248
|
*
|
|
2244
2249
|
* Empty values include:
|
|
2245
2250
|
* - `null`
|
|
2246
2251
|
* - `undefined`
|
|
2247
2252
|
* - `0`
|
|
2248
|
-
* -
|
|
2249
|
-
* -
|
|
2250
|
-
* - `[]`
|
|
2251
|
-
* - `{}`
|
|
2253
|
+
* - empty string
|
|
2254
|
+
* - empty array
|
|
2252
2255
|
* - invalid `Date` time
|
|
2253
2256
|
* - object with `length` property of `0`
|
|
2254
2257
|
* - object with `size` property of `0`
|
|
@@ -2265,7 +2268,20 @@ declare function isDate(value: unknown): value is Date;
|
|
|
2265
2268
|
* ```
|
|
2266
2269
|
* @version 12.1.0
|
|
2267
2270
|
*/
|
|
2268
|
-
declare function isEmpty(value:
|
|
2271
|
+
declare function isEmpty<T extends ToEmptyAble>(value: T): value is ToEmpty<T>;
|
|
2272
|
+
declare function isEmpty(value: unknown): boolean;
|
|
2273
|
+
type NeverEmpty = symbol | Function;
|
|
2274
|
+
/**
|
|
2275
|
+
* A type that can be narrowed by `isEmpty`.
|
|
2276
|
+
*/
|
|
2277
|
+
type ToEmptyAble = NeverEmpty | boolean | number | string | readonly any[] | null | undefined;
|
|
2278
|
+
/**
|
|
2279
|
+
* Narrow a type to an empty value.
|
|
2280
|
+
*
|
|
2281
|
+
* Due to TypeScript limitations, object types cannot be narrowed,
|
|
2282
|
+
* except for arrays and functions.
|
|
2283
|
+
*/
|
|
2284
|
+
type ToEmpty<T extends ToEmptyAble> = (T extends any[] ? never[] : Extract<false | 0 | '' | readonly never[] | null | undefined, T>) extends infer U ? Extract<U, T> : never;
|
|
2269
2285
|
|
|
2270
2286
|
/**
|
|
2271
2287
|
* Return true if the given values are equal.
|
|
@@ -3363,4 +3379,4 @@ type GlobalObjectType<Identifier extends string> = [Identifier] extends [Any] ?
|
|
|
3363
3379
|
[P in Identifier]: any;
|
|
3364
3380
|
} ? InstanceType<(typeof globalThis)[Identifier]> : never;
|
|
3365
3381
|
|
|
3366
|
-
export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, type Err, type ExtractArray, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type Primitive, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, all, alphabetical, always, assign, boil, callable, camel, capitalize, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, first, flat, flip, fork, get, group, guard, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isString, isSymbol, isTagged, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, merge, min, noop, objectify, omit, once, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
|
|
3382
|
+
export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, type Err, type ExtractArray, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type Primitive, type PromiseWithResolvers, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, type ToEmpty, type ToEmptyAble, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, all, alphabetical, always, assign, boil, callable, camel, capitalize, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, first, flat, flip, fork, get, group, guard, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isString, isSymbol, isTagged, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, merge, min, noop, objectify, omit, once, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
|
package/dist/radashi.d.ts
CHANGED
|
@@ -125,8 +125,7 @@ declare function diff<T>(root: readonly T[], other: readonly T[], identity?: (it
|
|
|
125
125
|
* ```
|
|
126
126
|
* @version 12.1.0
|
|
127
127
|
*/
|
|
128
|
-
declare function first<
|
|
129
|
-
declare function first<T, U>(array: readonly T[], defaultValue: U): T | U;
|
|
128
|
+
declare function first<const TArray extends readonly any[], const TDefault = undefined>(array: TArray, defaultValue?: TDefault): TArray extends readonly [infer TFirst, ...any[]] ? TFirst : TArray[number] | TDefault;
|
|
130
129
|
|
|
131
130
|
/**
|
|
132
131
|
* Given an array of arrays, returns a single dimensional array with
|
|
@@ -220,8 +219,7 @@ declare function iterate<T>(count: number, func: (currentValue: T, iteration: nu
|
|
|
220
219
|
* ```
|
|
221
220
|
* @version 12.1.0
|
|
222
221
|
*/
|
|
223
|
-
declare function last<
|
|
224
|
-
declare function last<T, U>(array: readonly T[], defaultValue: U): T | U;
|
|
222
|
+
declare function last<const TArray extends readonly any[], const TDefault = undefined>(array: TArray, defaultValue?: TDefault): TArray extends readonly [...any[], infer TLast] ? TLast : TArray[number] | TDefault;
|
|
225
223
|
|
|
226
224
|
/**
|
|
227
225
|
* Creates a list of given start, end, value, and step parameters.
|
|
@@ -530,8 +528,16 @@ declare function zip<T1, T2>(array1: readonly T1[], array2: readonly T2[]): [T1,
|
|
|
530
528
|
* ```
|
|
531
529
|
* @version 12.1.0
|
|
532
530
|
*/
|
|
533
|
-
declare function zipToObject<K extends string | number | symbol, V>(keys: K[], values: V | ((key: K, idx: number) => V) | V[]): Record<K, V>;
|
|
531
|
+
declare function zipToObject<K extends string | number | symbol, V>(keys: readonly K[], values: V | ((key: K, idx: number) => V) | readonly V[]): Record<K, V>;
|
|
534
532
|
|
|
533
|
+
interface AggregateError extends Error {
|
|
534
|
+
errors: any[];
|
|
535
|
+
}
|
|
536
|
+
interface AggregateErrorConstructor {
|
|
537
|
+
new (errors: Iterable<any>, message?: string): AggregateError;
|
|
538
|
+
(errors: Iterable<any>, message?: string): AggregateError;
|
|
539
|
+
readonly prototype: AggregateError;
|
|
540
|
+
}
|
|
535
541
|
/**
|
|
536
542
|
* The `AggregateError` object represents an error when several errors
|
|
537
543
|
* need to be wrapped in a single error.
|
|
@@ -1774,15 +1780,8 @@ declare function mapKeys<TValue, TKey extends string | number | symbol, TNewKey
|
|
|
1774
1780
|
* ```
|
|
1775
1781
|
* @version 12.1.0
|
|
1776
1782
|
*/
|
|
1777
|
-
declare function mapValues<
|
|
1778
|
-
[K in
|
|
1779
|
-
}, mapFunc: (value: TValue, key: TKey) => TNewValue): {
|
|
1780
|
-
[K in TKey]: TNewValue;
|
|
1781
|
-
};
|
|
1782
|
-
declare function mapValues<TValue, TKey extends string | number | symbol, TNewValue>(obj: {
|
|
1783
|
-
[K in TKey]?: TValue;
|
|
1784
|
-
}, mapFunc: (value: TValue, key: TKey) => TNewValue): {
|
|
1785
|
-
[K in TKey]?: TNewValue;
|
|
1783
|
+
declare function mapValues<T extends object, U>(obj: T, mapFunc: (value: Required<T>[keyof T], key: keyof T) => U): {
|
|
1784
|
+
[K in keyof T]: U;
|
|
1786
1785
|
};
|
|
1787
1786
|
|
|
1788
1787
|
/**
|
|
@@ -1842,6 +1841,8 @@ declare function set<T extends object, K>(initial: T, path: string, value: K): T
|
|
|
1842
1841
|
* Removes (shakes out) undefined entries from an object. Optional
|
|
1843
1842
|
* second argument shakes out values by custom evaluation.
|
|
1844
1843
|
*
|
|
1844
|
+
* Note that non-enumerable keys are never shaken out.
|
|
1845
|
+
*
|
|
1845
1846
|
* @see https://radashi.js.org/reference/object/shake
|
|
1846
1847
|
* @example
|
|
1847
1848
|
* ```ts
|
|
@@ -1851,7 +1852,10 @@ declare function set<T extends object, K>(initial: T, path: string, value: K): T
|
|
|
1851
1852
|
* ```
|
|
1852
1853
|
* @version 12.1.0
|
|
1853
1854
|
*/
|
|
1854
|
-
declare function shake<T extends object>(obj: T
|
|
1855
|
+
declare function shake<T extends object>(obj: T): {
|
|
1856
|
+
[K in keyof T]: Exclude<T[K], undefined>;
|
|
1857
|
+
};
|
|
1858
|
+
declare function shake<T extends object>(obj: T, filter: ((value: unknown) => boolean) | undefined): T;
|
|
1855
1859
|
|
|
1856
1860
|
interface TraverseOptions<Key = string | number | symbol> {
|
|
1857
1861
|
/**
|
|
@@ -1980,7 +1984,7 @@ declare function upperize<T extends Record<string, any>>(obj: T): UppercaseKeys<
|
|
|
1980
1984
|
* ```
|
|
1981
1985
|
* @version 12.1.0
|
|
1982
1986
|
*/
|
|
1983
|
-
declare function draw<T>(array: readonly T[]
|
|
1987
|
+
declare function draw<const T extends readonly any[]>(array: T): T extends readonly [any, ...any[]] ? T[number] : T[number] | null;
|
|
1984
1988
|
|
|
1985
1989
|
/**
|
|
1986
1990
|
* Generates a random integer between min and max. Both min and max
|
|
@@ -2240,15 +2244,14 @@ declare function isDate(value: unknown): value is Date;
|
|
|
2240
2244
|
|
|
2241
2245
|
/**
|
|
2242
2246
|
* Return true if the given value is empty.
|
|
2247
|
+
* This function also uses [Type Guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards) to ensure type safety
|
|
2243
2248
|
*
|
|
2244
2249
|
* Empty values include:
|
|
2245
2250
|
* - `null`
|
|
2246
2251
|
* - `undefined`
|
|
2247
2252
|
* - `0`
|
|
2248
|
-
* -
|
|
2249
|
-
* -
|
|
2250
|
-
* - `[]`
|
|
2251
|
-
* - `{}`
|
|
2253
|
+
* - empty string
|
|
2254
|
+
* - empty array
|
|
2252
2255
|
* - invalid `Date` time
|
|
2253
2256
|
* - object with `length` property of `0`
|
|
2254
2257
|
* - object with `size` property of `0`
|
|
@@ -2265,7 +2268,20 @@ declare function isDate(value: unknown): value is Date;
|
|
|
2265
2268
|
* ```
|
|
2266
2269
|
* @version 12.1.0
|
|
2267
2270
|
*/
|
|
2268
|
-
declare function isEmpty(value:
|
|
2271
|
+
declare function isEmpty<T extends ToEmptyAble>(value: T): value is ToEmpty<T>;
|
|
2272
|
+
declare function isEmpty(value: unknown): boolean;
|
|
2273
|
+
type NeverEmpty = symbol | Function;
|
|
2274
|
+
/**
|
|
2275
|
+
* A type that can be narrowed by `isEmpty`.
|
|
2276
|
+
*/
|
|
2277
|
+
type ToEmptyAble = NeverEmpty | boolean | number | string | readonly any[] | null | undefined;
|
|
2278
|
+
/**
|
|
2279
|
+
* Narrow a type to an empty value.
|
|
2280
|
+
*
|
|
2281
|
+
* Due to TypeScript limitations, object types cannot be narrowed,
|
|
2282
|
+
* except for arrays and functions.
|
|
2283
|
+
*/
|
|
2284
|
+
type ToEmpty<T extends ToEmptyAble> = (T extends any[] ? never[] : Extract<false | 0 | '' | readonly never[] | null | undefined, T>) extends infer U ? Extract<U, T> : never;
|
|
2269
2285
|
|
|
2270
2286
|
/**
|
|
2271
2287
|
* Return true if the given values are equal.
|
|
@@ -3363,4 +3379,4 @@ type GlobalObjectType<Identifier extends string> = [Identifier] extends [Any] ?
|
|
|
3363
3379
|
[P in Identifier]: any;
|
|
3364
3380
|
} ? InstanceType<(typeof globalThis)[Identifier]> : never;
|
|
3365
3381
|
|
|
3366
|
-
export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, type Err, type ExtractArray, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type Primitive, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, all, alphabetical, always, assign, boil, callable, camel, capitalize, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, first, flat, flip, fork, get, group, guard, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isString, isSymbol, isTagged, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, merge, min, noop, objectify, omit, once, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
|
|
3382
|
+
export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, type Err, type ExtractArray, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type Primitive, type PromiseWithResolvers, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, type ToEmpty, type ToEmptyAble, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, all, alphabetical, always, assign, boil, callable, camel, capitalize, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, filterKey, first, flat, flip, fork, get, group, guard, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isString, isSymbol, isTagged, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, merge, min, noop, objectify, omit, once, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
|
package/dist/radashi.js
CHANGED
|
@@ -356,20 +356,17 @@ function zipToObject(keys2, values) {
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
// src/async/AggregateError.ts
|
|
359
|
-
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() =>
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
|
|
369
|
-
this.errors = errors;
|
|
370
|
-
}
|
|
359
|
+
var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => globalThis.AggregateError ?? class AggregateError extends Error {
|
|
360
|
+
constructor(errors = []) {
|
|
361
|
+
var _a, _b;
|
|
362
|
+
super();
|
|
363
|
+
const name = ((_a = errors.find((e) => e.name)) == null ? void 0 : _a.name) ?? "";
|
|
364
|
+
this.name = `AggregateError(${name}...)`;
|
|
365
|
+
this.message = `AggregateError with ${errors.length} errors`;
|
|
366
|
+
this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
|
|
367
|
+
this.errors = errors;
|
|
371
368
|
}
|
|
372
|
-
)
|
|
369
|
+
})();
|
|
373
370
|
|
|
374
371
|
// src/async/all.ts
|
|
375
372
|
async function all(promises) {
|
|
@@ -1058,8 +1055,7 @@ function mapKeys(obj, mapFunc) {
|
|
|
1058
1055
|
|
|
1059
1056
|
// src/object/mapValues.ts
|
|
1060
1057
|
function mapValues(obj, mapFunc) {
|
|
1061
|
-
|
|
1062
|
-
return keys2.reduce(
|
|
1058
|
+
return Object.keys(obj).reduce(
|
|
1063
1059
|
(acc, key) => {
|
|
1064
1060
|
acc[key] = mapFunc(obj[key], key);
|
|
1065
1061
|
return acc;
|
|
@@ -1128,8 +1124,7 @@ function shake(obj, filter = (value) => value === void 0) {
|
|
|
1128
1124
|
if (!obj) {
|
|
1129
1125
|
return {};
|
|
1130
1126
|
}
|
|
1131
|
-
|
|
1132
|
-
return keys2.reduce((acc, key) => {
|
|
1127
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
1133
1128
|
if (!filter(obj[key])) {
|
|
1134
1129
|
acc[key] = obj[key];
|
|
1135
1130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "radashi",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.2",
|
|
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": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"Ray Epps"
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
|
+
"packageManager": "pnpm@9.1.3",
|
|
15
16
|
"engines": {
|
|
16
17
|
"node": ">=16.0.0"
|
|
17
18
|
},
|
|
@@ -29,6 +30,20 @@
|
|
|
29
30
|
"files": [
|
|
30
31
|
"dist"
|
|
31
32
|
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"add-function": "bash ./scripts/add-function.sh",
|
|
35
|
+
"bench": "vitest bench",
|
|
36
|
+
"build": "tsup --clean",
|
|
37
|
+
"bundle-impact": "bash ./scripts/bundle-impact.sh",
|
|
38
|
+
"dev": "tsup --clean --watch --sourcemap",
|
|
39
|
+
"format": "bash ./scripts/format.sh",
|
|
40
|
+
"lint": "bash ./scripts/lint.sh",
|
|
41
|
+
"move-function": "bash ./scripts/move-function.sh",
|
|
42
|
+
"test": "vitest run --coverage",
|
|
43
|
+
"test-branch": "bash ./scripts/test-branch.sh",
|
|
44
|
+
"test-single": "bash ./scripts/test-single.sh",
|
|
45
|
+
"update-browserslist": "bash ./scripts/update-browserslist.sh"
|
|
46
|
+
},
|
|
32
47
|
"devDependencies": {
|
|
33
48
|
"@biomejs/biome": "^1.8.3",
|
|
34
49
|
"@radashi-org/biome-config": "link:scripts/biome-config",
|
|
@@ -66,20 +81,5 @@
|
|
|
66
81
|
"unreleased opera versions",
|
|
67
82
|
"unreleased firefox versions",
|
|
68
83
|
"node >= 16"
|
|
69
|
-
]
|
|
70
|
-
|
|
71
|
-
"add-function": "bash ./scripts/add-function.sh",
|
|
72
|
-
"bench": "vitest bench",
|
|
73
|
-
"build": "tsup --clean",
|
|
74
|
-
"bundle-impact": "bash ./scripts/bundle-impact.sh",
|
|
75
|
-
"dev": "tsup --clean --watch --sourcemap",
|
|
76
|
-
"format": "bash ./scripts/format.sh",
|
|
77
|
-
"lint": "bash ./scripts/lint.sh",
|
|
78
|
-
"move-function": "bash ./scripts/move-function.sh",
|
|
79
|
-
"release": "bash ./scripts/release.sh",
|
|
80
|
-
"test": "vitest run --coverage",
|
|
81
|
-
"test-branch": "bash ./scripts/test-branch.sh",
|
|
82
|
-
"test-single": "bash ./scripts/test-single.sh",
|
|
83
|
-
"update-browserslist": "bash ./scripts/update-browserslist.sh"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
84
|
+
]
|
|
85
|
+
}
|