You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

functional.js

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

functional.js

functional.js is (go on, guess) a functional js library. It facilitates currying and point-free / tacit programming in JavaScript. Minified version here: http://bit.ly/funcmin

0.0.4
Source
npmnpm
Version published
Weekly downloads
9.9K
1.92%
Maintainers
1
Weekly downloads
 
Created
Source

functional.js (λ)

functional.js is (go on, guess) a functional js library. It facilitates currying and point-free / tacit programming in JavaScript.

Build Status

Grab the minified version here.

Basic λ.curry example

var concatenate = λ.curry(function(word1, word2) {
    return word1 + " " + word2;
});

var concatenateHello = concatenate("Hello");
var result = concatenateHello("World");

expect(result).toEqual("Hello World");

Another λ.curry example

var add = λ.curry(function(arg1, arg2, arg3) {
    return arg1 + arg2 + arg3;
}); 

var add3 = add(3),
    add5 = add3(2);

expect(add(3)(2)(1)).toEqual(6);
expect(add3(2, 1)).toEqual(6);
expect(add3(2)(1)).toEqual(6);
expect(add5(1)).toEqual(6);

Curried λ.each example

var result = [],
    items = ["f", "u", "n", "c"];

var addTo = function (item) {
    return result.push(item);
};

var addToResult = λ.each(addTo);
expect(typeof (addToResult)).toEqual("function");

addToResult(items);
expect(result).toEqual(["f", "u", "n", "c"]);

Curried λ.map example

var items = [1, 2, 3];

var doubleUp = function (number) {
    return number * 2;
};

var doubleMap = λ.map(doubleUp);
expect(typeof (doubleMap)).toEqual("function");

var result = doubleMap(items);
expect(result).toEqual([2, 4, 6]);

Curried λ.reduce example

var items = [1, 2, 3];

var multiply = function (arg1, arg2) {
    return arg1 * arg2;
};

var multiplyReduceFrom1 = λ.reduce(multiply, 1);
expect(typeof (multiplyReduceFrom1)).toEqual("function");

var result = multiplyReduceFrom1(items);
expect(result).toEqual(6);

Keywords

functional

FAQs

Package last updated on 10 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts