@react-pdf/fns
Advanced tools
Comparing version
@@ -11,2 +11,11 @@ /** | ||
type Fn$1 = (arg: any, ...args: any[]) => Promise<any> | any; | ||
type FirstFnParameterType$1<T extends Fn$1[]> = T extends [ | ||
...any, | ||
(arg: infer A, ...args: any[]) => Promise<any> | any | ||
] ? A : never; | ||
type LastFnReturnType$1<T extends Fn$1[]> = T extends [ | ||
(arg: any, ...args: any[]) => Promise<infer R> | infer R, | ||
...any | ||
] ? R : never; | ||
/** | ||
@@ -18,3 +27,3 @@ * Performs right-to-left function composition with async functions support | ||
*/ | ||
declare const asyncCompose: (...fns: any[]) => (value: any, ...args: any[]) => Promise<any>; | ||
declare const asyncCompose: <T extends Fn$1[]>(...fns: T) => (value: FirstFnParameterType$1<T>, ...args: Parameters<T[0]> extends [any, ...infer Rest] ? Rest : []) => Promise<LastFnReturnType$1<T>>; | ||
@@ -24,6 +33,6 @@ /** | ||
* | ||
* @param value = Any string | ||
* @param value - Any string | ||
* @returns Capitalized string | ||
*/ | ||
declare const capitalize: (value?: string | null) => string; | ||
declare const capitalize: (value?: string | null) => string | null | undefined; | ||
@@ -65,3 +74,2 @@ /** | ||
type Transformation = Record<string, (value: any) => any>; | ||
/** | ||
@@ -75,3 +83,5 @@ * Applies a set of transformations to an object and returns a new object with the transformed values. | ||
*/ | ||
declare const evolve: (transformations: Transformation, object: Record<string, any>) => Record<string, any>; | ||
declare function evolve<T extends Record<string, any>>(transformations: Partial<{ | ||
[K in keyof T]: (value: T[K]) => T[K]; | ||
}>, object: T): T; | ||
@@ -95,3 +105,3 @@ /** | ||
*/ | ||
declare const isNil: <T = any>(value: T) => boolean; | ||
declare const isNil: (value: unknown) => value is null | undefined; | ||
@@ -183,2 +193,10 @@ /** | ||
export { adjust, asyncCompose, capitalize, castArray, compose, dropLast, evolve, get, isNil, last, mapValues, matchPercent, omit, pick, repeat, reverse, upperFirst, without }; | ||
/** | ||
* Parse a string or number to a float | ||
* | ||
* @param value - String or number | ||
* @returns Parsed float | ||
*/ | ||
declare const parseFloat: (value: string | number) => number; | ||
export { adjust, asyncCompose, capitalize, castArray, compose, dropLast, evolve, get, isNil, last, mapValues, matchPercent, omit, parseFloat, pick, repeat, reverse, upperFirst, without }; |
@@ -18,11 +18,2 @@ /** | ||
/** | ||
* Reverses the list | ||
* | ||
* @template T | ||
* @param list - List to be reversed | ||
* @returns Reversed list | ||
*/ | ||
const reverse = (list) => Array.prototype.slice.call(list, 0).reverse(); | ||
/* eslint-disable no-await-in-loop */ | ||
@@ -37,3 +28,3 @@ /** | ||
let result = value; | ||
const reversedFns = reverse(fns); | ||
const reversedFns = fns.slice().reverse(); | ||
for (let i = 0; i < reversedFns.length; i += 1) { | ||
@@ -49,3 +40,3 @@ const fn = reversedFns[i]; | ||
* | ||
* @param value = Any string | ||
* @param value - Any string | ||
* @returns Capitalized string | ||
@@ -103,3 +94,3 @@ */ | ||
*/ | ||
const evolve = (transformations, object) => { | ||
function evolve(transformations, object) { | ||
const result = {}; | ||
@@ -110,4 +101,3 @@ const keys = Object.keys(object); | ||
const transformation = transformations[key]; | ||
const type = typeof transformation; | ||
if (type === 'function') { | ||
if (typeof transformation === 'function') { | ||
result[key] = transformation(object[key]); | ||
@@ -120,3 +110,3 @@ } | ||
return result; | ||
}; | ||
} | ||
@@ -240,2 +230,11 @@ /** | ||
/** | ||
* Reverses the list | ||
* | ||
* @template T | ||
* @param list - List to be reversed | ||
* @returns Reversed list | ||
*/ | ||
const reverse = (list) => Array.prototype.slice.call(list, 0).reverse(); | ||
/** | ||
* Capitalize first letter of string | ||
@@ -269,2 +268,12 @@ * | ||
export { adjust, asyncCompose, capitalize, castArray, compose, dropLast, evolve, get, isNil, last, mapValues, matchPercent, omit, pick, repeat, reverse, upperFirst, without }; | ||
/** | ||
* Parse a string or number to a float | ||
* | ||
* @param value - String or number | ||
* @returns Parsed float | ||
*/ | ||
const parseFloat$1 = (value) => { | ||
return typeof value === 'string' ? Number.parseFloat(value) : value; | ||
}; | ||
export { adjust, asyncCompose, capitalize, castArray, compose, dropLast, evolve, get, isNil, last, mapValues, matchPercent, omit, parseFloat$1 as parseFloat, pick, repeat, reverse, upperFirst, without }; |
{ | ||
"name": "@react-pdf/fns", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"license": "MIT", | ||
@@ -19,3 +19,4 @@ "description": "React-pdf helper functions", | ||
"build": "rollup -c", | ||
"watch": "rollup -c -w" | ||
"watch": "rollup -c -w", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
@@ -22,0 +23,0 @@ "files": [ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
14497
6.71%428
6.2%0
-100%