@hdsydsvenskan/utils
Advanced tools
Comparing version 4.19.0 to 4.20.0
@@ -28,1 +28,15 @@ import { Primitive } from 'type-fest'; | ||
unknown; | ||
type MaybePromised<T> = T|Promise<T>; | ||
export type ResolveValueParam<T, P extends any[]> = ((...params: P) => MaybePromised<T>)|MaybePromised<T>; | ||
export type ResolveValueRawParam<T, P extends any[]> = ((...params: P) => T)|T; | ||
export type ResolveValueWithThisParam<T, C, P extends any[]> = ((this: C, ...params: P) => MaybePromised<T>)|MaybePromised<T>; | ||
declare function resolveValue<T, P extends any[]> (value: ResolveValueParam<T, P>, ...valueArgs: P): Promise<T>; | ||
declare function resolveValueRaw<T, P extends any[]> (value: ResolveValueRawParam<T, P>, ...valueArgs: P): T; | ||
declare function resolveValueWithThis<T, C, P extends any[]> (value: ResolveValueWithThisParam<T, C, P>, thisContext: C, ...valueArgs: P): T; | ||
export type ResolveValue = typeof resolveValue; | ||
export type ResolveValueRaw = typeof resolveValueRaw; | ||
export type ResolveValueWithThis = typeof resolveValueWithThis; |
@@ -18,4 +18,5 @@ export type CacheStore = import("./types").BasicCacheStore & import("./types").CacheStoreExtras; | ||
export type MaybePromised<T> = T | Promise<T>; | ||
export type ResolveValueParam<T, P extends any[]> = T | Promise<T> | ((...params: P) => T | Promise<T>); | ||
export type ResolveValueParam<T, P extends any[]> = T | Promise<T> | ((...params: P) => import("./advanced-types").MaybePromised<T>); | ||
export type ResolveValueRawParam<T, P extends any[]> = T | ((...params: P) => T); | ||
export type ResolveValueWithThisParam<T, C, P extends any[]> = T | Promise<T> | ((this: C, ...params: P) => import("./advanced-types").MaybePromised<T>); | ||
export type EnsureArray<X> = import("../lib-ts/array").UnpackArray<X>[]; | ||
@@ -75,8 +76,8 @@ export type UnpackArray<X> = X extends (infer U)[] ? U : X; | ||
export const isValidUUID: (uuid: string) => boolean; | ||
export const resolveNonObjectValue: <T extends string | number | boolean | any[] | null | undefined, P extends any[]>(value: T | Promise<T> | ((...params: P) => T | Promise<T>), ...valueArgs: P) => Promise<T>; | ||
export const resolveNonObjectValueRaw: <T extends string | number | boolean | any[] | null | undefined, P extends any[]>(value: T | ((...params: P) => T), ...valueArgs: P) => T; | ||
export const resolveNonObjectValueWithThis: <T extends string | number | boolean | any[] | null | undefined, P extends any[]>(value: T | Promise<T> | ((...params: P) => T | Promise<T>), thisContext: any, ...valueArgs: P) => Promise<T>; | ||
export const resolveValue: (value: any, ...valueArgs: any[]) => Promise<any>; | ||
export const resolveValueRaw: (value: any, ...valueArgs: any[]) => any; | ||
export const resolveValueWithThis: (value: any, thisContext: any, ...valueArgs: any[]) => Promise<any>; | ||
export const resolveNonObjectValue: typeof import("./advanced-types").resolveValue; | ||
export const resolveNonObjectValueRaw: typeof import("./advanced-types").resolveValueRaw; | ||
export const resolveNonObjectValueWithThis: typeof import("./advanced-types").resolveValueWithThis; | ||
export const resolveValue: typeof import("./advanced-types").resolveValue; | ||
export const resolveValueRaw: typeof import("./advanced-types").resolveValueRaw; | ||
export const resolveValueWithThis: typeof import("./advanced-types").resolveValueWithThis; | ||
export const createMemoizedSeededListSorter: (cacheCount: number) => (name: string, list: any[], seed: string | number | Buffer) => any[]; | ||
@@ -83,0 +84,0 @@ export const seededRandom: (seed: string | number | Buffer) => (max: number) => number; |
@@ -116,3 +116,3 @@ // @ts-check | ||
* @template {any[]} P | ||
* @typedef {((...params: P) => MaybePromised<T>) | MaybePromised<T>} ResolveValueParam | ||
* @typedef {import("./advanced-types").ResolveValueParam<T, P>} ResolveValueParam | ||
*/ | ||
@@ -123,6 +123,13 @@ | ||
* @template {any[]} P | ||
* @typedef {((...params: P) => T) | T} ResolveValueRawParam | ||
* @typedef {import("./advanced-types").ResolveValueRawParam<T, P>} ResolveValueRawParam | ||
*/ | ||
/** | ||
* @template T | ||
* @template C | ||
* @template {any[]} P | ||
* @typedef {import("./advanced-types").ResolveValueWithThisParam<T, C, P>} ResolveValueWithThisParam | ||
*/ | ||
/** | ||
* @template X | ||
@@ -129,0 +136,0 @@ * @typedef {import("../lib-ts/array").EnsureArray<X>} EnsureArray |
export type MaybePromised<T> = T | Promise<T>; | ||
export type NonObject = string | number | boolean | any[] | null | undefined; | ||
export function resolveNonObjectValue<T extends string | number | boolean | any[] | null | undefined, P extends any[]>(value: T | Promise<T> | ((...params: P) => T | Promise<T>), ...valueArgs: P): Promise<T>; | ||
export function resolveNonObjectValueRaw<T extends string | number | boolean | any[] | null | undefined, P extends any[]>(value: T | ((...params: P) => T), ...valueArgs: P): T; | ||
export function resolveNonObjectValueWithThis<T extends string | number | boolean | any[] | null | undefined, P extends any[]>(value: T | Promise<T> | ((...params: P) => T | Promise<T>), thisContext: any, ...valueArgs: P): Promise<T>; | ||
export function resolveValue(value: any, ...valueArgs: any[]): Promise<any>; | ||
export function resolveValueRaw(value: any, ...valueArgs: any[]): any; | ||
export function resolveValueWithThis(value: any, thisContext: any, ...valueArgs: any[]): Promise<any>; | ||
/** | ||
* Resolves a value in a way so that it can be set either statically, dynamically or even asyncronously | ||
* | ||
* @deprecated Use resolveValue() instead | ||
* @type {import('./advanced-types').ResolveValue} | ||
*/ | ||
export const resolveNonObjectValue: import('./advanced-types').ResolveValue; | ||
/** | ||
* Resolves a value in a way so that it can be set either statically or dynamically | ||
* | ||
* @deprecated Use resolveValueRaw() instead | ||
* @type {import('./advanced-types').ResolveValueRaw} | ||
*/ | ||
export const resolveNonObjectValueRaw: import('./advanced-types').ResolveValueRaw; | ||
/** | ||
* Resolves a value in a way so that it can be set either statically, dynamically or even asyncronously | ||
* | ||
* @deprecated Use resolveValueWithThis() instead | ||
* @type {import('./advanced-types').ResolveValueWithThis} | ||
*/ | ||
export const resolveNonObjectValueWithThis: import('./advanced-types').ResolveValueWithThis; | ||
/** | ||
* @template T | ||
* @typedef {import("./types").MaybePromised<T>} MaybePromised | ||
*/ | ||
/** @typedef {import("./types").NonObject} NonObject */ | ||
/** | ||
* Resolves a value in a way so that it can be set either statically, dynamically or even asyncronously | ||
* | ||
* Either a value, a function returning a value, a Promise resolving to a value or a function returning a Promise resolving to a value | ||
* | ||
* @type {import('./advanced-types').ResolveValue} | ||
*/ | ||
export const resolveValue: import('./advanced-types').ResolveValue; | ||
/** | ||
* Resolves a value in a way so that it can be set either statically or dynamically | ||
* | ||
* @type {import('./advanced-types').ResolveValueRaw} | ||
*/ | ||
export const resolveValueRaw: import('./advanced-types').ResolveValueRaw; | ||
/** | ||
* Resolves a value in a way so that it can be set either statically or dynamically | ||
* | ||
* @type {import('./advanced-types').ResolveValueWithThis} | ||
*/ | ||
export const resolveValueWithThis: import('./advanced-types').ResolveValueWithThis; |
@@ -18,5 +18,3 @@ // @ts-check | ||
* | ||
* @param {any} value | ||
* @param {any[]} valueArgs | ||
* @returns {Promise<any>} | ||
* @type {import('./advanced-types').ResolveValue} | ||
*/ | ||
@@ -34,5 +32,3 @@ const resolveValue = async function (value, ...valueArgs) { | ||
* | ||
* @param {any} value Either a value or a function returning a value | ||
* @param {any[]} valueArgs | ||
* @returns {any} | ||
* @type {import('./advanced-types').ResolveValueRaw} | ||
*/ | ||
@@ -50,6 +46,3 @@ const resolveValueRaw = function (value, ...valueArgs) { | ||
* | ||
* @param {any} value Either a value or a function returning a value | ||
* @param {any} thisContext | ||
* @param {any[]} valueArgs | ||
* @returns {Promise<any>} | ||
* @type {import('./advanced-types').ResolveValueWithThis} | ||
*/ | ||
@@ -67,7 +60,4 @@ const resolveValueWithThis = async function (value, thisContext, ...valueArgs) { | ||
* | ||
* @template {NonObject} T | ||
* @template {any[]} P | ||
* @param {((...params: P) => MaybePromised<T>)|MaybePromised<T>} value | ||
* @param {P} valueArgs | ||
* @returns {Promise<T>} | ||
* @deprecated Use resolveValue() instead | ||
* @type {import('./advanced-types').ResolveValue} | ||
*/ | ||
@@ -79,7 +69,4 @@ const resolveNonObjectValue = (value, ...valueArgs) => resolveValue(value, ...valueArgs); | ||
* | ||
* @template {NonObject} T | ||
* @template {any[]} P | ||
* @param {((...params: P) => T)|T} value | ||
* @param {P} valueArgs | ||
* @returns {T} | ||
* @deprecated Use resolveValueRaw() instead | ||
* @type {import('./advanced-types').ResolveValueRaw} | ||
*/ | ||
@@ -91,8 +78,4 @@ const resolveNonObjectValueRaw = (value, ...valueArgs) => resolveValueRaw(value, ...valueArgs); | ||
* | ||
* @template {NonObject} T | ||
* @template {any[]} P | ||
* @param {((...params: P) => MaybePromised<T>)|MaybePromised<T>} value | ||
* @param {any} thisContext | ||
* @param {P} valueArgs | ||
* @returns {Promise<T>} | ||
* @deprecated Use resolveValueWithThis() instead | ||
* @type {import('./advanced-types').ResolveValueWithThis} | ||
*/ | ||
@@ -99,0 +82,0 @@ const resolveNonObjectValueWithThis = (value, thisContext, ...valueArgs) => resolveValueWithThis(value, thisContext, ...valueArgs); |
{ | ||
"name": "@hdsydsvenskan/utils", | ||
"version": "4.19.0", | ||
"version": "4.20.0", | ||
"license": "UNLICENSED", | ||
@@ -55,7 +55,7 @@ "description": "Misc utility methods that's useful for our sites", | ||
"@types/mocha": "^7.0.2", | ||
"@types/node": "^10.17.6", | ||
"@types/sinon": "^7.5.1", | ||
"@types/node": "^10.17.19", | ||
"@types/sinon": "^9.0.0", | ||
"@types/sinon-chai": "^3.2.3", | ||
"@typescript-eslint/eslint-plugin": "^2.25.0", | ||
"@typescript-eslint/parser": "^2.24.0", | ||
"@typescript-eslint/eslint-plugin": "^2.28.0", | ||
"@typescript-eslint/parser": "^2.28.0", | ||
"chai": "^4.1.2", | ||
@@ -76,3 +76,3 @@ "chai-as-promised": "^7.1.1", | ||
"eslint-plugin-unicorn": "^17.2.0", | ||
"husky": "^4.0.0", | ||
"husky": "^4.2.5", | ||
"installed-check": "^3.0.0", | ||
@@ -82,3 +82,3 @@ "mocha": "^7.0.0", | ||
"nyc": "^15.0.0", | ||
"sinon": "^9.0.0", | ||
"sinon": "^9.0.2", | ||
"sinon-chai": "^3.2.0", | ||
@@ -93,5 +93,5 @@ "tsd": "^0.11.0", | ||
"hashlru": "^2.1.0", | ||
"type-fest": "^0.12.0", | ||
"type-fest": "^0.15.0", | ||
"verror": "^1.10.0" | ||
} | ||
} |
@@ -93,2 +93,3 @@ # Utils | ||
* `deprecate(name, [message])` – logs a `console.trace()` the very first time it's called with a new `name`, thus avoiding spamming the output with deprecation errors. Tracks state globally. Does not output logs in production. | ||
* `ExtendableError` – an extendable helper subclass of `Error`, which aids in setting things up correctly. | ||
* `findCauseByError(err, FooError)` – like `VError.findCauseByName(err, 'FooError')` but when it returns an error it actually is an error of the `FooError` type | ||
@@ -95,0 +96,0 @@ * `HdsUtilsFetchError(res, parsed)` – fetch related `Error` class, can be used wherever a fetch related error happens |
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
108857
2589
120
+ Addedtype-fest@0.15.1(transitive)
- Removedtype-fest@0.12.0(transitive)
Updatedtype-fest@^0.15.0