Skip to content
/ curry Public

A tool for creating granular JavaScript functions

License

Notifications You must be signed in to change notification settings

qiqingfu/curry

Repository files navigation

curry

Install

npm

npm install @qiqingfu/curry

yarn

yarn add @qiqingfu/curry

Usage

Basic example

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

Special example

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'

End

This tool library is still being improved using TypeScript, and a complete type system and code quality optimization will be added in the future.

About

A tool for creating granular JavaScript functions

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published