Comparing version 10.9.0 to 11.0.0
@@ -81,11 +81,19 @@ /** | ||
* | ||
* Ex. max([{ num: 1 }, { num: 2 }], x => x.num) == 2 | ||
* @example | ||
* max([ 2, 3, 5]) == 5 | ||
* max([{ num: 1 }, { num: 2 }], x => x.num) == { num: 2 } | ||
*/ | ||
declare const max: <T extends number | object>(array: readonly T[], getter?: ((item: T) => number) | undefined) => T | null; | ||
declare function max(array: readonly [number, ...number[]]): number; | ||
declare function max(array: readonly number[]): number | null; | ||
declare function max<T>(array: readonly T[], getter: (item: T) => number): T | null; | ||
/** | ||
* Min gets the smallest value from a list | ||
* | ||
* Ex. max([{ num: 1 }, { num: 2 }], x => x.num) == 1 | ||
* @example | ||
* min([1, 2, 3, 4]) == 1 | ||
* min([{ num: 1 }, { num: 2 }], x => x.num) == { num: 1 } | ||
*/ | ||
declare const min: <T extends number | object>(array: readonly T[], getter?: ((item: T) => number) | undefined) => T | null; | ||
declare function min(array: readonly [number, ...number[]]): number; | ||
declare function min(array: readonly number[]): number | null; | ||
declare function min<T>(array: readonly T[], getter: (item: T) => number): T | null; | ||
/** | ||
@@ -169,2 +177,3 @@ * Splits a single list into many lists of the desired size. If | ||
}) => T[]; | ||
type Falsy = null | undefined | false | '' | 0 | 0n; | ||
/** | ||
@@ -174,3 +183,3 @@ * Given a list returns a new list with | ||
*/ | ||
declare const sift: <T>(list: readonly T[]) => NonNullable<T>[]; | ||
declare const sift: <T>(list: readonly (Falsy | T)[]) => T[]; | ||
/** | ||
@@ -203,3 +212,3 @@ * Like a reduce but does not require an array. | ||
*/ | ||
declare const reduce: <T, K>(array: readonly T[], asyncReducer: (acc: K, item: T) => Promise<K>, initValue?: K | undefined) => Promise<K>; | ||
declare const reduce: <T, K>(array: readonly T[], asyncReducer: (acc: K, item: T, index: number) => Promise<K>, initValue?: K | undefined) => Promise<K>; | ||
/** | ||
@@ -248,8 +257,9 @@ * An async map function. Works like the | ||
* @example | ||
* const [user] = await all({ | ||
* const [user] = await all([ | ||
* api.users.create(...), | ||
* s3.buckets.create(...), | ||
* slack.customerSuccessChannel.sendMessage(...) | ||
* }) | ||
* ]) | ||
*/ | ||
declare function all<T extends [Promise<any>, ...Promise<any>[]]>(promises: T): Promise<PromiseValues<T>>; | ||
declare function all<T extends Promise<any>[]>(promises: T): Promise<PromiseValues<T>>; | ||
@@ -284,4 +294,2 @@ /** | ||
declare const sleep: (milliseconds: number) => Promise<unknown>; | ||
type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never; | ||
type UnwrapPromisify<T> = T extends Promise<infer U> ? U : T; | ||
/** | ||
@@ -292,3 +300,3 @@ * A helper to try an async function without forking | ||
*/ | ||
declare const tryit: <TFunction extends (...args: any) => any>(func: TFunction) => (...args: ArgumentsType<TFunction>) => Promise<[Error, undefined] | [undefined, UnwrapPromisify<ReturnType<TFunction>>]>; | ||
declare const tryit: <Args extends any[], Return>(func: (...args: Args) => Return) => (...args: Args) => Return extends Promise<any> ? Promise<[Error, undefined] | [undefined, Awaited<Return>]> : [Error, undefined] | [undefined, Return]; | ||
/** | ||
@@ -300,3 +308,3 @@ * A helper to try an async function that returns undefined | ||
*/ | ||
declare const guard: <TFunction extends () => any>(func: TFunction, shouldGuard?: ((err: any) => boolean) | undefined) => ReturnType<TFunction> extends Promise<any> ? Promise<UnwrapPromisify<ReturnType<TFunction>> | undefined> : ReturnType<TFunction> | undefined; | ||
declare const guard: <TFunction extends () => any>(func: TFunction, shouldGuard?: ((err: any) => boolean) | undefined) => ReturnType<TFunction> extends Promise<any> ? Promise<Awaited<ReturnType<TFunction>> | undefined> : ReturnType<TFunction> | undefined; | ||
@@ -325,3 +333,3 @@ type Func<TArgs = any, KReturn = any | void> = (...args: TArgs[]) => KReturn; | ||
*/ | ||
declare const memo: <TFunc extends Function>(func: TFunc, options?: { | ||
declare const memo: <TFunc extends (...args: any) => any>(func: TFunc, options?: { | ||
key?: Func<any, string>; | ||
@@ -337,2 +345,6 @@ ttl?: number; | ||
/** | ||
* Checks if there is any invocation debounced | ||
*/ | ||
isPending(): boolean; | ||
/** | ||
* Runs the debounced function immediately | ||
@@ -342,2 +354,9 @@ */ | ||
}; | ||
type ThrottledFunction<TArgs extends any[]> = { | ||
(...args: TArgs): void; | ||
/** | ||
* Checks if there is any invocation throttled | ||
*/ | ||
isThrottled(): boolean; | ||
}; | ||
/** | ||
@@ -362,3 +381,3 @@ * Given a delay and a function returns a new function | ||
interval: number; | ||
}, func: (...args: TArgs) => any) => (...args: TArgs) => any; | ||
}, func: (...args: TArgs) => any) => ThrottledFunction<TArgs>; | ||
/** | ||
@@ -381,3 +400,3 @@ * Make an object callable. Given an object and a function | ||
*/ | ||
declare const callable: <TValue, TObj extends Record<string | number | symbol, TValue>, TFunc extends Function>(obj: TObj, fn: (self: TObj) => TFunc) => TObj & TFunc; | ||
declare const callable: <TValue, TObj extends Record<string | number | symbol, TValue>, TFunc extends (...args: any) => any>(obj: TObj, fn: (self: TObj) => TFunc) => TObj & TFunc; | ||
@@ -453,3 +472,3 @@ declare const toFloat: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T; | ||
*/ | ||
declare const get: <T, K>(value: T, path: string, defaultValue?: K | null) => K | null; | ||
declare const get: <TDefault = unknown>(value: any, path: string, defaultValue?: TDefault | undefined) => TDefault; | ||
/** | ||
@@ -548,3 +567,5 @@ * Opposite of get, dynamically set a nested value into | ||
*/ | ||
declare const snake: (str: string) => string; | ||
declare const snake: (str: string, options?: { | ||
splitOnNumber?: boolean; | ||
}) => string; | ||
/** | ||
@@ -598,3 +619,3 @@ * Formats the given string in dash case fashion | ||
declare const isSymbol: (value: any) => value is symbol; | ||
declare const isArray: (value: any) => value is unknown[]; | ||
declare const isArray: (arg: any) => arg is any[]; | ||
declare const isObject: (value: any) => value is object; | ||
@@ -616,5 +637,11 @@ /** | ||
declare const isDate: (value: any) => value is Date; | ||
/** | ||
* This is really a _best guess_ promise checking. You | ||
* should probably use Promise.resolve(value) to be 100% | ||
* sure you're handling it correctly. | ||
*/ | ||
declare const isPromise: (value: any) => value is Promise<any>; | ||
declare const isEmpty: (value: any) => boolean; | ||
declare const isEqual: <TType>(x: TType, y: TType) => boolean; | ||
export { AggregateError, all, alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, first, flat, fork, get, group, guard, intersects, invert, isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isNumber, isObject, isPrimitive, isString, isSymbol, iterate, keys, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, objectify, omit, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, select, series, set, shake, shift, shuffle, sift, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, trim, tryit as try, tryit, uid, unique, upperize, zip, zipToObject }; | ||
export { AggregateError, all, alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, first, flat, fork, get, group, guard, intersects, invert, isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, objectify, omit, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, select, series, set, shake, shift, shuffle, sift, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, trim, tryit as try, tryit, uid, unique, upperize, zip, zipToObject }; |
{ | ||
"name": "radash", | ||
"version": "10.9.0", | ||
"version": "11.0.0", | ||
"description": "Functional utility library - modern, simple, typed, powerful", | ||
@@ -15,3 +15,3 @@ "main": "dist/cjs/index.cjs", | ||
"files": [ | ||
"dist/**/*" | ||
"dist" | ||
], | ||
@@ -18,0 +18,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
270207
2720