1.2.1 • Published 2 years ago

easy-curry v1.2.1

Weekly downloads
10
License
MIT
Repository
github
Last release
2 years ago

Easy curry. Just what you need.

Only small and simple curry functions. Nothing extra

What is currying?

Quick guide here: https://medium.com/@ivankorolenko/how-to-quickly-understand-currying-in-javascript-7a3875f3fde6

Why easy-curry?

✔️ Code is easy to read. You can easily understand what you're using

✔️ Multiple types of currying: classic, to fixed arity, variadic

✔️ Can be used in a TypeScript project (.d.ts file included)

✔️ Size: 275 bytes (minified and gzipped)

✔️ No dependencies

Getting Started

NPM

Add this library to your project using NPM

npm i easy-curry

import what you need

import { curry } from 'easy-curry';

and use it

const add = (a, b) => a + b;
curry(add)(2)(2);

CDN

Add this code to your HTML

<script src="https://cdn.jsdelivr.net/npm/easy-curry/curry.min.js"></script>

and use it

<script>
    const add = (a, b) => a + b;
    curry(add)(2)(2);
</script>

Manually

Download curry.min.js from this repository to your project's folder and use it

<script src="./curry.min.js"></script>
<script>
    const add = (a, b) => a + b;
    curry(add)(2)(2);
</script>

How to use

You can import any function you need separately.

import { curry, curryN, curryV } from 'easy-curry'

This library has no default export. Why it's a good thing

curry - classic currying. Creates a sequence of functions that corresponds to passed function's arity

curryN - curries a function to fixed arity

curryV - variadic currying. Enhanced version of classic currying. Curried function supports termination (early value return), meaning it can be called before receiving the full set of arguments using empty argument call.

Examples:

  • curry(someFunction)(1)(2)(3)
  • curry(someFunction)(1, 2, 3)
  • curry(someFunction)(1, 2)(3)
  • curry(someFunction)(1)(2)
  • curryN(1, someFunction)(1)
  • curryV(someFunction)(1)(2)()
1.2.0

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.2.1

2 years ago

1.1.16

2 years ago

1.0.15

2 years ago

1.1.15

2 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

5 years ago

1.0.2

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago