Giter VIP home page Giter VIP logo

easy-curry's Introduction

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)()

easy-curry's People

Contributors

dependabot[bot] avatar ivan-korolenko avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

redjabber alleypa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.