radashi 12.8.1 → 12.9.1

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
@@ -338,9 +338,8 @@ function sort(array, getter = identity, desc = false) {
338
338
  if (!array) {
339
339
  return [];
340
340
  }
341
- const asc = (a, b) => getter(a) - getter(b);
342
- const dsc = (a, b) => getter(b) - getter(a);
343
- return array.slice().sort(desc === true ? dsc : asc);
341
+ const direction = desc ? -1 : 1;
342
+ return array.slice().sort((a, b) => (getter(a) - getter(b)) * direction);
344
343
  }
345
344
 
346
345
  // src/array/toggle.ts
@@ -1079,7 +1078,7 @@ function crush(value) {
1079
1078
  if (!value) {
1080
1079
  return {};
1081
1080
  }
1082
- return function crushReducer(crushed, value2, path) {
1081
+ return (function crushReducer(crushed, value2, path) {
1083
1082
  if (isObject(value2) || isArray(value2)) {
1084
1083
  for (const [prop, propValue] of Object.entries(value2)) {
1085
1084
  crushReducer(crushed, propValue, path ? `${path}.${prop}` : prop);
@@ -1088,7 +1087,7 @@ function crush(value) {
1088
1087
  crushed[path] = value2;
1089
1088
  }
1090
1089
  return crushed;
1091
- }({}, value, "");
1090
+ })({}, value, "");
1092
1091
  }
1093
1092
 
1094
1093
  // src/object/filterKey.ts
@@ -1244,6 +1243,17 @@ function mapValues(obj, mapFunc) {
1244
1243
  );
1245
1244
  }
1246
1245
 
1246
+ // src/object/mergeOptions.ts
1247
+ function mergeOptions(a, b) {
1248
+ if (a === void 0) {
1249
+ return b;
1250
+ }
1251
+ if (b === void 0) {
1252
+ return a;
1253
+ }
1254
+ return { ...a, ...b };
1255
+ }
1256
+
1247
1257
  // src/object/omit.ts
1248
1258
  function omit(obj, keys2) {
1249
1259
  if (!obj) {
@@ -1288,7 +1298,7 @@ function set(initial, path, value) {
1288
1298
  if (!path || value === void 0) {
1289
1299
  return initial;
1290
1300
  }
1291
- return function recurse(object, keys2, index) {
1301
+ return (function recurse(object, keys2, index) {
1292
1302
  const key = keys2[index];
1293
1303
  object ??= isIntString(key) ? [] : {};
1294
1304
  if (isDangerousKey(key, object)) {
@@ -1302,7 +1312,7 @@ function set(initial, path, value) {
1302
1312
  object[key] = value;
1303
1313
  }
1304
1314
  return object;
1305
- }(initial, path.match(/[^.[\]]+/g), 0);
1315
+ })(initial, path.match(/[^.[\]]+/g), 0);
1306
1316
  }
1307
1317
 
1308
1318
  // src/object/shake.ts
@@ -2311,6 +2321,7 @@ exports.max = max;
2311
2321
  exports.memo = memo;
2312
2322
  exports.memoLastCall = memoLastCall;
2313
2323
  exports.merge = merge;
2324
+ exports.mergeOptions = mergeOptions;
2314
2325
  exports.min = min;
2315
2326
  exports.noop = noop;
2316
2327
  exports.objectify = objectify;
@@ -557,7 +557,15 @@ declare function sift<T>(array: readonly (T | Falsy)[]): T[];
557
557
  * ```
558
558
  * @version 12.1.0
559
559
  */
560
- declare function sort<T>(array: readonly T[], getter?: (item: T) => number, desc?: boolean): T[];
560
+ declare function sort<const T extends readonly any[]>(array: T, getter?: (item: T[number]) => number, desc?: boolean): SortArray<T>;
561
+ /**
562
+ * The return type of the `sort` function. Tuple types are preserved.
563
+ */
564
+ type SortArray<T extends readonly any[]> = T extends readonly [] ? [] : T extends readonly [any, ...infer TRest] ? [T[number], ...SortArrayRest<T[number], TRest>] : T[number][];
565
+ type SortArrayRest<TElement, T extends readonly any[]> = T extends readonly [
566
+ any,
567
+ ...infer TRest
568
+ ] ? [TElement, ...SortArrayRest<TElement, TRest>] : T extends readonly [] ? [] : TElement[];
561
569
 
562
570
  /**
563
571
  * Either adds or removes an item from an array, based on whether it
@@ -2911,6 +2919,61 @@ declare function mapValues<T extends object, U>(obj: T, mapFunc: (value: Require
2911
2919
  [K in keyof T]: U;
2912
2920
  };
2913
2921
 
2922
+ /**
2923
+ * Merges two option objects into a new object.
2924
+ * - If both arguments are defined, properties
2925
+ * from the second object (`b`) will override those
2926
+ * from the first one (`a`) when keys overlap
2927
+ * - If either argument is `undefined`, the other is returned
2928
+ * - If both are `undefined`, the result is `undefined`
2929
+ *
2930
+ * @param a - The first options object, or `undefined`.
2931
+ * @param b - The second options object, or `undefined`.
2932
+ * @returns A merged object when both arguments are defined, otherwise the defined argument, or `undefined` if both are `undefined`.
2933
+ * @version 12.9.0
2934
+ *
2935
+ * @see https://radashi.js.org/reference/object/mergeOptions
2936
+ *
2937
+ * @example
2938
+ * ```ts
2939
+ * // Merging two objects with overlapping keys
2940
+ * mergeOptions({ a: 1, b: 2 }, { b: 3, c: 4 })
2941
+ * // => { a: 1, b: 3, c: 4 }
2942
+ *
2943
+ * // First argument undefined
2944
+ * mergeOptions(undefined, { a: 1 })
2945
+ * // => { a: 1 }
2946
+ *
2947
+ * // Second argument undefined
2948
+ * mergeOptions({ a: 1 }, undefined)
2949
+ * // => { a: 1 }
2950
+ *
2951
+ * // Both arguments undefined
2952
+ * mergeOptions(undefined, undefined)
2953
+ * // => undefined
2954
+ * ```
2955
+ */
2956
+ declare function mergeOptions<A extends object | undefined, B extends object | undefined>(a: A, b: B): MergeOptions<A, B>;
2957
+ /**
2958
+ * Computes the merged type of two option objects, handling `undefined` and partials.
2959
+ *
2960
+ * @version 12.9.0
2961
+ */
2962
+ type MergeOptions<A extends object | undefined, B extends object | undefined> = (undefined extends A ? B : never) | (undefined extends B ? NonNullable<A> : never) | MergePresent<NonNullable<A>, NonNullable<B>>;
2963
+ type Expand<T> = T extends object ? {
2964
+ [K in keyof T]: Expand<T[K]>;
2965
+ } : T;
2966
+ type MergePresent<A, B> = [A, B] extends [never, never] ? never : A extends object ? B extends object ? Expand<MergeObjects<A, B>> : never : never;
2967
+ type MergeObjects<A extends object, B extends object> = {
2968
+ [K in MergeRequiredKeys<A, B>]: MergeValue<A, B, K>;
2969
+ } & {
2970
+ [K in MergeOptionalKeys<A, B>]?: MergeValue<A, B, K>;
2971
+ };
2972
+ type MergeRequiredKeys<A extends object, B extends object> = RequiredKeys<B> | Exclude<RequiredKeys<A>, keyof B> | (RequiredKeys<A> & OptionalKeys<B>);
2973
+ type MergeOptionalKeys<A extends object, B extends object> = Exclude<OptionalKeys<A>, keyof B> | Exclude<OptionalKeys<B>, RequiredKeys<A>>;
2974
+ type MergeValue<A extends object, B extends object, K extends keyof A | keyof B> = K extends keyof B ? K extends OptionalKeys<B> ? K extends keyof A ? PropValue<A, K> | PropValue<B, K> : PropValue<B, K> : B[K] : K extends keyof A ? PropValue<A, K> : never;
2975
+ type PropValue<T extends object, K extends keyof T> = K extends OptionalKeys<T> ? Required<Pick<T, K>>[K] : T[K];
2976
+
2914
2977
  /**
2915
2978
  * Omit a list of properties from an object returning a new object
2916
2979
  * with the properties that remain.
@@ -3984,6 +4047,12 @@ declare function isNumber(value: unknown): value is number;
3984
4047
  * `Object.create(null)` result. Objects from [other realms][1] are
3985
4048
  * also supported.
3986
4049
  *
4050
+ * Use this as a TypeScript type guard only when the input is known to
4051
+ * be either an object accepted by `isObject` or a non-object value. The
4052
+ * `object` type in TypeScript also includes arrays, functions, dates,
4053
+ * maps, sets, and other object-like values that `isObject` may reject
4054
+ * at runtime.
4055
+ *
3987
4056
  * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms
3988
4057
  *
3989
4058
  * @see https://radashi.js.org/reference/typed/isObject
@@ -4244,4 +4313,4 @@ declare function isWeakMap<K extends WeakKey = WeakKey, V = unknown>(value: unkn
4244
4313
  */
4245
4314
  declare function isWeakSet<T extends WeakKey = WeakKey>(value: unknown): value is WeakSet<T>;
4246
4315
 
4247
- export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type Awaitable, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type Class, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Concat, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, DurationParser, type DurationShortUnit, type DurationString, type DurationUnit, type Err, type ExtractArray, type ExtractClass, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type GuardReturnType, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer$1 as NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type ParallelOptions, type Primitive, type PromiseWithResolvers, QuantityParser, type QuantityString, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, Semaphore, type SemaphoreAcquireOptions, SemaphorePermit, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, TimeoutError, type ToEmpty, type ToEmptyAble, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, absoluteJitter, all, alphabetical, always, assert, assign, boil, callable, camel, capitalize, cartesianProduct, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, concat, construct, counting, crush, dash, debounce, deburr, dedent, defer, diff, draw, escapeHTML, filterKey, first, flat, flip, fork, get, getErrorMessage, getOrInsert, getOrInsertComputed, group, guard, identity, inRange, intersects, invert, isArray, isArrayEqual, isAsyncIterable, isBigInt, isBoolean, isClass, isDangerousKey, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isMapEqual, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isSetEqual, isString, isSymbol, isTagged, isUndefined, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, memoLastCall, merge, min, noop, objectify, omit, once, parallel, parseDuration, parseQuantity, partial, partob, pascal, pick, pluck, promiseChain, proportionalJitter, proxied, queueByKey, random, range, reduce, remove, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, timeout, title, toFloat, toInt, toResult, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
4316
+ export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type Awaitable, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type Class, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Concat, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, DurationParser, type DurationShortUnit, type DurationString, type DurationUnit, type Err, type ExtractArray, type ExtractClass, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type GuardReturnType, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type MergeOptions, type NoInfer$1 as NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type ParallelOptions, type Primitive, type PromiseWithResolvers, QuantityParser, type QuantityString, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, Semaphore, type SemaphoreAcquireOptions, SemaphorePermit, type Series, type Simplify, type SortArray, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, TimeoutError, type ToEmpty, type ToEmptyAble, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, absoluteJitter, all, alphabetical, always, assert, assign, boil, callable, camel, capitalize, cartesianProduct, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, concat, construct, counting, crush, dash, debounce, deburr, dedent, defer, diff, draw, escapeHTML, filterKey, first, flat, flip, fork, get, getErrorMessage, getOrInsert, getOrInsertComputed, group, guard, identity, inRange, intersects, invert, isArray, isArrayEqual, isAsyncIterable, isBigInt, isBoolean, isClass, isDangerousKey, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isMapEqual, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isSetEqual, isString, isSymbol, isTagged, isUndefined, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, memoLastCall, merge, mergeOptions, min, noop, objectify, omit, once, parallel, parseDuration, parseQuantity, partial, partob, pascal, pick, pluck, promiseChain, proportionalJitter, proxied, queueByKey, random, range, reduce, remove, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, timeout, title, toFloat, toInt, toResult, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
package/dist/radashi.d.ts CHANGED
@@ -557,7 +557,15 @@ declare function sift<T>(array: readonly (T | Falsy)[]): T[];
557
557
  * ```
558
558
  * @version 12.1.0
559
559
  */
560
- declare function sort<T>(array: readonly T[], getter?: (item: T) => number, desc?: boolean): T[];
560
+ declare function sort<const T extends readonly any[]>(array: T, getter?: (item: T[number]) => number, desc?: boolean): SortArray<T>;
561
+ /**
562
+ * The return type of the `sort` function. Tuple types are preserved.
563
+ */
564
+ type SortArray<T extends readonly any[]> = T extends readonly [] ? [] : T extends readonly [any, ...infer TRest] ? [T[number], ...SortArrayRest<T[number], TRest>] : T[number][];
565
+ type SortArrayRest<TElement, T extends readonly any[]> = T extends readonly [
566
+ any,
567
+ ...infer TRest
568
+ ] ? [TElement, ...SortArrayRest<TElement, TRest>] : T extends readonly [] ? [] : TElement[];
561
569
 
562
570
  /**
563
571
  * Either adds or removes an item from an array, based on whether it
@@ -2911,6 +2919,61 @@ declare function mapValues<T extends object, U>(obj: T, mapFunc: (value: Require
2911
2919
  [K in keyof T]: U;
2912
2920
  };
2913
2921
 
2922
+ /**
2923
+ * Merges two option objects into a new object.
2924
+ * - If both arguments are defined, properties
2925
+ * from the second object (`b`) will override those
2926
+ * from the first one (`a`) when keys overlap
2927
+ * - If either argument is `undefined`, the other is returned
2928
+ * - If both are `undefined`, the result is `undefined`
2929
+ *
2930
+ * @param a - The first options object, or `undefined`.
2931
+ * @param b - The second options object, or `undefined`.
2932
+ * @returns A merged object when both arguments are defined, otherwise the defined argument, or `undefined` if both are `undefined`.
2933
+ * @version 12.9.0
2934
+ *
2935
+ * @see https://radashi.js.org/reference/object/mergeOptions
2936
+ *
2937
+ * @example
2938
+ * ```ts
2939
+ * // Merging two objects with overlapping keys
2940
+ * mergeOptions({ a: 1, b: 2 }, { b: 3, c: 4 })
2941
+ * // => { a: 1, b: 3, c: 4 }
2942
+ *
2943
+ * // First argument undefined
2944
+ * mergeOptions(undefined, { a: 1 })
2945
+ * // => { a: 1 }
2946
+ *
2947
+ * // Second argument undefined
2948
+ * mergeOptions({ a: 1 }, undefined)
2949
+ * // => { a: 1 }
2950
+ *
2951
+ * // Both arguments undefined
2952
+ * mergeOptions(undefined, undefined)
2953
+ * // => undefined
2954
+ * ```
2955
+ */
2956
+ declare function mergeOptions<A extends object | undefined, B extends object | undefined>(a: A, b: B): MergeOptions<A, B>;
2957
+ /**
2958
+ * Computes the merged type of two option objects, handling `undefined` and partials.
2959
+ *
2960
+ * @version 12.9.0
2961
+ */
2962
+ type MergeOptions<A extends object | undefined, B extends object | undefined> = (undefined extends A ? B : never) | (undefined extends B ? NonNullable<A> : never) | MergePresent<NonNullable<A>, NonNullable<B>>;
2963
+ type Expand<T> = T extends object ? {
2964
+ [K in keyof T]: Expand<T[K]>;
2965
+ } : T;
2966
+ type MergePresent<A, B> = [A, B] extends [never, never] ? never : A extends object ? B extends object ? Expand<MergeObjects<A, B>> : never : never;
2967
+ type MergeObjects<A extends object, B extends object> = {
2968
+ [K in MergeRequiredKeys<A, B>]: MergeValue<A, B, K>;
2969
+ } & {
2970
+ [K in MergeOptionalKeys<A, B>]?: MergeValue<A, B, K>;
2971
+ };
2972
+ type MergeRequiredKeys<A extends object, B extends object> = RequiredKeys<B> | Exclude<RequiredKeys<A>, keyof B> | (RequiredKeys<A> & OptionalKeys<B>);
2973
+ type MergeOptionalKeys<A extends object, B extends object> = Exclude<OptionalKeys<A>, keyof B> | Exclude<OptionalKeys<B>, RequiredKeys<A>>;
2974
+ type MergeValue<A extends object, B extends object, K extends keyof A | keyof B> = K extends keyof B ? K extends OptionalKeys<B> ? K extends keyof A ? PropValue<A, K> | PropValue<B, K> : PropValue<B, K> : B[K] : K extends keyof A ? PropValue<A, K> : never;
2975
+ type PropValue<T extends object, K extends keyof T> = K extends OptionalKeys<T> ? Required<Pick<T, K>>[K] : T[K];
2976
+
2914
2977
  /**
2915
2978
  * Omit a list of properties from an object returning a new object
2916
2979
  * with the properties that remain.
@@ -3984,6 +4047,12 @@ declare function isNumber(value: unknown): value is number;
3984
4047
  * `Object.create(null)` result. Objects from [other realms][1] are
3985
4048
  * also supported.
3986
4049
  *
4050
+ * Use this as a TypeScript type guard only when the input is known to
4051
+ * be either an object accepted by `isObject` or a non-object value. The
4052
+ * `object` type in TypeScript also includes arrays, functions, dates,
4053
+ * maps, sets, and other object-like values that `isObject` may reject
4054
+ * at runtime.
4055
+ *
3987
4056
  * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms
3988
4057
  *
3989
4058
  * @see https://radashi.js.org/reference/typed/isObject
@@ -4244,4 +4313,4 @@ declare function isWeakMap<K extends WeakKey = WeakKey, V = unknown>(value: unkn
4244
4313
  */
4245
4314
  declare function isWeakSet<T extends WeakKey = WeakKey>(value: unknown): value is WeakSet<T>;
4246
4315
 
4247
- export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type Awaitable, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type Class, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Concat, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, DurationParser, type DurationShortUnit, type DurationString, type DurationUnit, type Err, type ExtractArray, type ExtractClass, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type GuardReturnType, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type NoInfer$1 as NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type ParallelOptions, type Primitive, type PromiseWithResolvers, QuantityParser, type QuantityString, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, Semaphore, type SemaphoreAcquireOptions, SemaphorePermit, type Series, type Simplify, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, TimeoutError, type ToEmpty, type ToEmptyAble, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, absoluteJitter, all, alphabetical, always, assert, assign, boil, callable, camel, capitalize, cartesianProduct, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, concat, construct, counting, crush, dash, debounce, deburr, dedent, defer, diff, draw, escapeHTML, filterKey, first, flat, flip, fork, get, getErrorMessage, getOrInsert, getOrInsertComputed, group, guard, identity, inRange, intersects, invert, isArray, isArrayEqual, isAsyncIterable, isBigInt, isBoolean, isClass, isDangerousKey, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isMapEqual, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isSetEqual, isString, isSymbol, isTagged, isUndefined, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, memoLastCall, merge, min, noop, objectify, omit, once, parallel, parseDuration, parseQuantity, partial, partob, pascal, pick, pluck, promiseChain, proportionalJitter, proxied, queueByKey, random, range, reduce, remove, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, timeout, title, toFloat, toInt, toResult, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
4316
+ export { AggregateErrorOrPolyfill as AggregateError, Any, type Assign, type Awaitable, type BoxedPrimitive, type BuiltInType, type CastArray, type CastArrayIfExists, type Class, type CloningStrategy, type Comparable, type ComparableProperty, type Comparator, type ComparatorMapping, type CompatibleProperty, type Concat, type Crush, type CustomClass, type CustomClassRegistry, type DebounceFunction, type DebounceOptions, DefaultCloningStrategy, DurationParser, type DurationShortUnit, type DurationString, type DurationUnit, type Err, type ExtractArray, type ExtractClass, type ExtractMap, type ExtractNotAny, type ExtractSet, type Falsy, FastCloningStrategy, type FilteredKeys, type Flip, type GuardReturnType, type Intersect, type IsExactType, type KeyFilter, type KeyFilterFunction, type LowercaseKeys, type MappedInput, type MappedOutput, type Mapping, type MappingFunction, type MemoOptions, type MergeOptions, type NoInfer$1 as NoInfer, type Ok, type OnceFunction, type OptionalKeys, type OptionalMapping, type ParallelOptions, type Primitive, type PromiseWithResolvers, QuantityParser, type QuantityString, type RequiredKeys, type Result, type ResultPromise, type RetryOptions, Semaphore, type SemaphoreAcquireOptions, SemaphorePermit, type Series, type Simplify, type SortArray, type StrictExtract, type SwitchAny, type SwitchNever, type ThrottledFunction, TimeoutError, type ToEmpty, type ToEmptyAble, type TraverseContext, type TraverseOptions, type TraverseVisitor, type TryitResult, type TypedArray, type UppercaseKeys, absoluteJitter, all, alphabetical, always, assert, assign, boil, callable, camel, capitalize, cartesianProduct, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, concat, construct, counting, crush, dash, debounce, deburr, dedent, defer, diff, draw, escapeHTML, filterKey, first, flat, flip, fork, get, getErrorMessage, getOrInsert, getOrInsertComputed, group, guard, identity, inRange, intersects, invert, isArray, isArrayEqual, isAsyncIterable, isBigInt, isBoolean, isClass, isDangerousKey, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isMapEqual, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isSetEqual, isString, isSymbol, isTagged, isUndefined, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, memoLastCall, merge, mergeOptions, min, noop, objectify, omit, once, parallel, parseDuration, parseQuantity, partial, partob, pascal, pick, pluck, promiseChain, proportionalJitter, proxied, queueByKey, random, range, reduce, remove, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, timeout, title, toFloat, toInt, toResult, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
package/dist/radashi.js CHANGED
@@ -336,9 +336,8 @@ function sort(array, getter = identity, desc = false) {
336
336
  if (!array) {
337
337
  return [];
338
338
  }
339
- const asc = (a, b) => getter(a) - getter(b);
340
- const dsc = (a, b) => getter(b) - getter(a);
341
- return array.slice().sort(desc === true ? dsc : asc);
339
+ const direction = desc ? -1 : 1;
340
+ return array.slice().sort((a, b) => (getter(a) - getter(b)) * direction);
342
341
  }
343
342
 
344
343
  // src/array/toggle.ts
@@ -1077,7 +1076,7 @@ function crush(value) {
1077
1076
  if (!value) {
1078
1077
  return {};
1079
1078
  }
1080
- return function crushReducer(crushed, value2, path) {
1079
+ return (function crushReducer(crushed, value2, path) {
1081
1080
  if (isObject(value2) || isArray(value2)) {
1082
1081
  for (const [prop, propValue] of Object.entries(value2)) {
1083
1082
  crushReducer(crushed, propValue, path ? `${path}.${prop}` : prop);
@@ -1086,7 +1085,7 @@ function crush(value) {
1086
1085
  crushed[path] = value2;
1087
1086
  }
1088
1087
  return crushed;
1089
- }({}, value, "");
1088
+ })({}, value, "");
1090
1089
  }
1091
1090
 
1092
1091
  // src/object/filterKey.ts
@@ -1242,6 +1241,17 @@ function mapValues(obj, mapFunc) {
1242
1241
  );
1243
1242
  }
1244
1243
 
1244
+ // src/object/mergeOptions.ts
1245
+ function mergeOptions(a, b) {
1246
+ if (a === void 0) {
1247
+ return b;
1248
+ }
1249
+ if (b === void 0) {
1250
+ return a;
1251
+ }
1252
+ return { ...a, ...b };
1253
+ }
1254
+
1245
1255
  // src/object/omit.ts
1246
1256
  function omit(obj, keys2) {
1247
1257
  if (!obj) {
@@ -1286,7 +1296,7 @@ function set(initial, path, value) {
1286
1296
  if (!path || value === void 0) {
1287
1297
  return initial;
1288
1298
  }
1289
- return function recurse(object, keys2, index) {
1299
+ return (function recurse(object, keys2, index) {
1290
1300
  const key = keys2[index];
1291
1301
  object ??= isIntString(key) ? [] : {};
1292
1302
  if (isDangerousKey(key, object)) {
@@ -1300,7 +1310,7 @@ function set(initial, path, value) {
1300
1310
  object[key] = value;
1301
1311
  }
1302
1312
  return object;
1303
- }(initial, path.match(/[^.[\]]+/g), 0);
1313
+ })(initial, path.match(/[^.[\]]+/g), 0);
1304
1314
  }
1305
1315
 
1306
1316
  // src/object/shake.ts
@@ -2201,4 +2211,4 @@ function isWeakSet(value) {
2201
2211
  return isTagged(value, "[object WeakSet]");
2202
2212
  }
2203
2213
 
2204
- export { AggregateErrorOrPolyfill as AggregateError, DefaultCloningStrategy, DurationParser, FastCloningStrategy, QuantityParser, Semaphore, SemaphorePermit, TimeoutError, absoluteJitter, all, alphabetical, always, assert, assign, boil, callable, camel, capitalize, cartesianProduct, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, concat, construct, counting, crush, dash, debounce, deburr, dedent, defer, diff, draw, escapeHTML, filterKey, first, flat, flip, fork, get, getErrorMessage, getOrInsert, getOrInsertComputed, group, guard, identity, inRange, intersects, invert, isArray, isArrayEqual, isAsyncIterable, isBigInt, isBoolean, isClass, isDangerousKey, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isMapEqual, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isSetEqual, isString, isSymbol, isTagged, isUndefined, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, memoLastCall, merge, min, noop, objectify, omit, once, parallel, parseDuration, parseQuantity, partial, partob, pascal, pick, pluck, promiseChain, proportionalJitter, proxied, queueByKey, random, range, reduce, remove, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, timeout, title, toFloat, toInt, toResult, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
2214
+ export { AggregateErrorOrPolyfill as AggregateError, DefaultCloningStrategy, DurationParser, FastCloningStrategy, QuantityParser, Semaphore, SemaphorePermit, TimeoutError, absoluteJitter, all, alphabetical, always, assert, assign, boil, callable, camel, capitalize, cartesianProduct, castArray, castArrayIfExists, castComparator, castMapping, chain, clamp, clone, cloneDeep, cluster, compose, concat, construct, counting, crush, dash, debounce, deburr, dedent, defer, diff, draw, escapeHTML, filterKey, first, flat, flip, fork, get, getErrorMessage, getOrInsert, getOrInsertComputed, group, guard, identity, inRange, intersects, invert, isArray, isArrayEqual, isAsyncIterable, isBigInt, isBoolean, isClass, isDangerousKey, isDate, isEmpty, isEqual, isError, isFloat, isFunction, isInt, isIntString, isIterable, isMap, isMapEqual, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isResult, isResultErr, isResultOk, isSet, isSetEqual, isString, isSymbol, isTagged, isUndefined, isWeakMap, isWeakSet, iterate, keys, last, lerp, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, mapify, max, memo, memoLastCall, merge, mergeOptions, min, noop, objectify, omit, once, parallel, parseDuration, parseQuantity, partial, partob, pascal, pick, pluck, promiseChain, proportionalJitter, proxied, queueByKey, random, range, reduce, remove, replace, replaceOrAppend, retry, round, select, selectFirst, series, set, shake, shift, shuffle, sift, similarity, sleep, snake, sort, sum, template, throttle, timeout, title, toFloat, toInt, toResult, toggle, traverse, trim, tryit as try, tryit, uid, unique, unzip, upperize, withResolvers, zip, zipToObject };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radashi",
3
- "version": "12.8.1",
3
+ "version": "12.9.1",
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": {