npm
npm install @qiqingfu/curry
yarn
yarn add @qiqingfu/curry
import curry from "@qiqingfu/curry"
const add = (x, y, z) => {
return x + y + z
}
const addCurry = curry(add)
const result = addCurry(1)(2)(3) // 6
Specify default parameters when creating a granular function.
import curry from "@qiqingfu/curry"
const add = (x, y, z) => {
return x + y + z
}
const addCurry = curry(add, 1, 2)
const result = addCurry(3) // 6
A function will be executed immediately without parameters
import curry from "@qiqingfu/curry"
const add = () => {
return 'hi'
}
const addCurry = curry(add)
const result = addCurry() // 'hi'
This tool library is still being improved using TypeScript, and a complete type system and code quality optimization will be added in the future.