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 - npm Package Compare versions

Comparing version

to
0.0.2

13

functional.js

@@ -30,3 +30,16 @@ var λ = (function () {

λ.map = λ.curry(function (iterator, items) {
var mapped = [],
mapEach;
if (!items || typeof (iterator) !== "function") {
return;
}
mapEach = λ.each(function () {
mapped.push(iterator.apply(null, arguments));
});
mapEach(items);
return mapped;
});
return λ;
})();

2

package.json
{
"author": "Lee Crossley <leee@hotmail.co.uk> (http://ilee.co.uk)",
"name": "functional.js",
"version": "0.0.1",
"version": "0.0.2",
"scripts": {

@@ -6,0 +6,0 @@ "preinstall": "npm install -g grunt-cli; npm install -g jasmine-node",

# functional.js (λ)
functional.js is (go on, guess) a functional js library. It facilitates [currying](http://en.wikipedia.org/wiki/Currying) and [point-free / tacit](http://en.wikipedia.org/wiki/Tacit_programming) programming in JavaScript.
[![Build Status](https://travis-ci.org/leecrossley/functional-js.png?branch=master)](https://travis-ci.org/leecrossley/functional-js)
functional.js is (go on, guess) a functional js library. It facilitates [currying](http://en.wikipedia.org/wiki/Currying) and [point-free / tacit](http://en.wikipedia.org/wiki/Tacit_programming) programming in JavaScript.
### Basic λ.curry example
### λ.curry example
```javascript

@@ -35,2 +35,18 @@ var concatenate = λ.curry(function(word1, word2) {

expect(result).toEqual(["f", "u", "n", "c"]);
```
### Curried λ.map example
```javascript
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]);
```

@@ -80,2 +80,28 @@ describe("functional", function() {

});
it("should be able to double numbers in an array using λ.map", function() {
var items = [1, 2, 3];
var doubleUp = function (number) {
return number * 2;
};
var result = λ.map(doubleUp, items);
expect(result).toEqual([2, 4, 6]);
});
it("should be able to λ.curry λ.map", function() {
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]);
});
});