• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    JavaScript
  • Created over 4 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Curry All Code

omg-curry

Generic badge Generic badge

Twitter Twitter

Feature Complete Curry Library

Logo

Features

  • Fixed Functions ⟢ Curry
  • Operators ⟢ Curry
  • Curry ⟢ Fixed Functions
  • Infinite Currying
  • Lazy Curry

Installation

npm install omg-curry

Usage

const curry = require('omg-curry')

Fixed Functions

Convert a function into curry

function map (fn, default, list) {}

const mapK = curry.fixed(map)
const square = a => a**2

mapK(square)(0)([1, 2, 3, 4, null])
// [1, 4, 9, 16, 0]

// or reuse

const mapSquare = mapK(square)(0)
mapSquare([1, 2, 3, 4, null])
// [1, 4, 9, 16, 0]

Operators

Create N-length Curry from an operator

const add = (a, b) => a+b
const add4 = curry.op(add, 4)

add4(1)(3)(5)(10)
add4(1)(3,5)(10)
add4(1,3,5,10)
// 19

const addInfty = curry.op(add, Infinity)

// () to end
addInfty(1)(1)(1,1)(1)(1)()
// 6

const add4Lazy = curry.op(add, 4, true)
// same as add4 buts evaluates at the end
const altSum = (a, b, i) => a + (-1)**i * b
const altSum5 = curry.op(altSum, 5)
// (a, b, c, d, e) => a - b + c - d + e

altSum5(1)(2)(3)(4,5)
// 1 - 2 + 3 - 4 + 5
// 3

DeCurry

Convert Curry to Fixed Functions

const add4Fixed = curry.deCurry(add4Curry)

WTF is Curry?

A Curry takes arguments one by one unlike functions which take all arguments at once.

// Function
add(1, 2, 3)
// 6

// Curry
add(1)(2)(3)
// 6

Support

  • Browser
  • Node

More Repositories

1

uuid-readable

Generate Easy to Remember, Readable UUIDs, that are Shakespearean and Grammatically Correct Sentences πŸ₯³
TypeScript
803
star
2

names.io

A Global Exhaustive First and Last Name Database
Shell
728
star
3

browser-extension

Browser Extension Template with ESbuild builds, support for React, Preact, Typescript, Tailwind, Manifest V3/V2 support and multi browser build including Chrome, Firefox, Safari, Edge, Brave.
TypeScript
671
star
4

react-fast-charts

Blazing Fast Charting Library in React with loading time less than 50ms
JavaScript
119
star
5

youtube-bg-react

Youtube video as background for HTML elements
TypeScript
38
star
6

url-request

The most advanced HTTP Client with Functional Chaining, Async/Await, Delay, Fork, Infinite Chaining and Repeat for building your Complex APIs easily.
JavaScript
28
star
7

hotstarlivestreamer

Download or Live Stream from Hotstar
PHP
12
star
8

golive

golive is a lightweight and improved live-server alternative written in Go
Go
7
star
9

oeis.haskell

A Collection of OEIS Sequences in Haskell
Haskell
5
star
10

vue-data-table

Vue Data Table With Filter, Sort and Complete Editability
Vue
4
star
11

newton-works

Lifetime Collection of Newton's Works
HTML
4
star
12

dl-rubiks-autodidactic-solver

Python
3
star
13

mathematics-pagerank

Python
3
star
14

absurd-sql-chrome-extension

JavaScript
3
star
15

github.zsh-theme

Github theme for Zsh
Shell
3
star
16

rational-parking-functions

Python
3
star
17

go-preact

go-preact is a template to create portable server apps with preact frontend in a single binary executable
TypeScript
2
star
18

wave-plus

An Wave Extension
JavaScript
2
star
19

some-proofs

1
star
20

vala-guide

A Guide for Vala Programming Language
TeX
1
star
21

ubuntuInit

Shell
1
star
22

first-bot

The Bot Search Engine
JavaScript
1
star
23

delhi.fm

TypeScript
1
star
24

saavn_downloader

Python
1
star
25

motion-control

Play Games Using Body Gestures
Python
1
star
26

minimal-ui

CSS
1
star
27

gn

Go
1
star
28

site-hungry

Eat 🀀, Digest 🀒 Sites and then Sleep πŸ₯±πŸ˜΄ on the Data
JavaScript
1
star
29

vue-date-picker

Vue
1
star
30

go-next

go-next is a template to create portable server apps in a single binary executable
Makefile
1
star