forked from enviPath/enviPy
Current Dev State
This commit is contained in:
61
static/js/ketcher2/node_modules/ap/README.markdown
generated
vendored
Normal file
61
static/js/ketcher2/node_modules/ap/README.markdown
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
ap
|
||||
==
|
||||
|
||||
`Function.prototype.bind` sets `this` which is super annoying if you just want
|
||||
to do currying over arguments while passing `this` through.
|
||||
|
||||
Instead you can do:
|
||||
|
||||
``` js
|
||||
var ap = require('ap');
|
||||
var z = ap([3], function (x, y) {
|
||||
return this.z * (x * 2 + y);
|
||||
}).call({ z : 10 }, 4);
|
||||
console.log(z);
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
```
|
||||
100
|
||||
```
|
||||
|
||||
methods
|
||||
=======
|
||||
|
||||
``` js
|
||||
var ap = require('ap')
|
||||
```
|
||||
|
||||
## ap(args, fn)
|
||||
|
||||
Fill in the arguments `args` at the beginning of `fn`'s arguments list.
|
||||
|
||||
## ap.pa(args, fn)
|
||||
|
||||
Fill in the arguments `args` at the end of `fn`'s arguments list.
|
||||
|
||||
## ap.apa(left, right, fn)
|
||||
|
||||
Fill in `left` arguments starting from the beginning of `fn`'s argument list and
|
||||
`right` arguments starting from the end.
|
||||
|
||||
## ap.partial(fn, args...)
|
||||
|
||||
Fill in `fn`'s arguments with `args...` from the beginning of `fn`'s arguments
|
||||
list.
|
||||
|
||||
## ap.partialRight(fn, args...)
|
||||
|
||||
Fill in `fn`'s arguments with `args...` starting from the end of `fn`'s
|
||||
arguments list.
|
||||
|
||||
## ap.curry(fn, args...)
|
||||
|
||||
Curry `fn`, returning a new function with `args...` partially applied from the
|
||||
beginning of `fn`'s arguments list.
|
||||
|
||||
## ap.curryRight(fn, args...)
|
||||
|
||||
Curry `fn` returning a new function with `args...` partially applied from the
|
||||
end of `fn`'s arguments list.
|
||||
5
static/js/ketcher2/node_modules/ap/examples/z.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/ap/examples/z.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
var ap = require('../');
|
||||
var z = ap([3], function (x, y) {
|
||||
return this.z * (x * 2 + y);
|
||||
}).call({ z : 10 }, 4);
|
||||
console.log(z);
|
||||
48
static/js/ketcher2/node_modules/ap/index.js
generated
vendored
Normal file
48
static/js/ketcher2/node_modules/ap/index.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
exports = module.exports = ap;
|
||||
function ap (args, fn) {
|
||||
return function () {
|
||||
var rest = [].slice.call(arguments)
|
||||
, first = args.slice()
|
||||
first.push.apply(first, rest)
|
||||
return fn.apply(this, first);
|
||||
};
|
||||
}
|
||||
|
||||
exports.pa = pa;
|
||||
function pa (args, fn) {
|
||||
return function () {
|
||||
var rest = [].slice.call(arguments)
|
||||
rest.push.apply(rest, args)
|
||||
return fn.apply(this, rest);
|
||||
};
|
||||
}
|
||||
|
||||
exports.apa = apa;
|
||||
function apa (left, right, fn) {
|
||||
return function () {
|
||||
return fn.apply(this,
|
||||
left.concat.apply(left, arguments).concat(right)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
exports.partial = partial;
|
||||
function partial (fn) {
|
||||
var args = [].slice.call(arguments, 1);
|
||||
return ap(args, fn);
|
||||
}
|
||||
|
||||
exports.partialRight = partialRight;
|
||||
function partialRight (fn) {
|
||||
var args = [].slice.call(arguments, 1);
|
||||
return pa(args, fn);
|
||||
}
|
||||
|
||||
exports.curry = curry;
|
||||
function curry (fn) {
|
||||
return partial(partial, fn);
|
||||
}
|
||||
|
||||
exports.curryRight = function curryRight (fn) {
|
||||
return partial(partialRight, fn);
|
||||
}
|
||||
65
static/js/ketcher2/node_modules/ap/package.json
generated
vendored
Normal file
65
static/js/ketcher2/node_modules/ap/package.json
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
"_from": "ap@~0.2.0",
|
||||
"_id": "ap@0.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-rglCYAspkS8NKxTsYMRejzMLYRA=",
|
||||
"_location": "/ap",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "ap@~0.2.0",
|
||||
"name": "ap",
|
||||
"escapedName": "ap",
|
||||
"rawSpec": "~0.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~0.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/accessory"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ap/-/ap-0.2.0.tgz",
|
||||
"_shasum": "ae0942600b29912f0d2b14ec60c45e8f330b6110",
|
||||
"_spec": "ap@~0.2.0",
|
||||
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/accessory",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/node-ap/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Currying in javascript. Like .bind() without also setting `this`.",
|
||||
"devDependencies": {
|
||||
"tap": "0.2.5"
|
||||
},
|
||||
"directories": {
|
||||
"example": "./examples"
|
||||
},
|
||||
"engine": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
"homepage": "https://github.com/substack/node-ap#readme",
|
||||
"keywords": [
|
||||
"curry",
|
||||
"apply",
|
||||
"ap",
|
||||
"bind",
|
||||
"function",
|
||||
"functional"
|
||||
],
|
||||
"license": "MIT/X11",
|
||||
"main": "./index.js",
|
||||
"name": "ap",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/substack/node-ap.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap ./test"
|
||||
},
|
||||
"version": "0.2.0"
|
||||
}
|
||||
137
static/js/ketcher2/node_modules/ap/test/curry.js
generated
vendored
Normal file
137
static/js/ketcher2/node_modules/ap/test/curry.js
generated
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
var test = require("tap").test;
|
||||
|
||||
var ap = require('../');
|
||||
var pa = ap.pa;
|
||||
var apa = ap.apa;
|
||||
var partial = ap.partial;
|
||||
var partialRight = ap.partialRight;
|
||||
var curry = ap.curry;
|
||||
var curryRight = ap.curryRight;
|
||||
|
||||
function one(x, y) {
|
||||
return x * 2 + y
|
||||
}
|
||||
|
||||
function two(x, y, z, w) {
|
||||
return x * 2 + (y + z) * w
|
||||
}
|
||||
|
||||
function three(x, y) {
|
||||
return this.z * (x * 2 + y)
|
||||
}
|
||||
|
||||
var z = {
|
||||
z: 10
|
||||
};
|
||||
|
||||
test("ap function", function (t) {
|
||||
var apOne = ap([3], one);
|
||||
t.equal(apOne(4),
|
||||
3 * 2 + 4);
|
||||
|
||||
var apTwo = ap([3,4], two);
|
||||
t.equal(apTwo(5, 6),
|
||||
3 * 2 + (4 + 5) * 6);
|
||||
|
||||
var apThree = ap([3], three);
|
||||
t.equal(apThree.call(z, 4),
|
||||
10 * (3 * 2 + 4));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("pa function", function (t) {
|
||||
var paOne = pa([3], one);
|
||||
t.equal(paOne(4),
|
||||
4 * 2 + 3);
|
||||
|
||||
var paTwo = pa([3,4], two);
|
||||
t.equal(paTwo(5, 6),
|
||||
5 * 2 + (6 + 3) * 4);
|
||||
|
||||
var paThree = pa([3], three);
|
||||
t.equal(paThree.call(z, 4),
|
||||
10 * (4 * 2 + 3));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("apa function", function (t) {
|
||||
var apaOne = apa([3], [4], one);
|
||||
t.equal(apaOne(),
|
||||
3 * 2 + 4);
|
||||
|
||||
var apaTwo = apa([3], [4], two);
|
||||
t.equal(apaTwo(5, 6),
|
||||
3 * 2 + (5 + 6) * 4);
|
||||
|
||||
var apaThree = apa([3], [4], three);
|
||||
t.equal(apaThree.call(z),
|
||||
10 * (3 * 2 + 4));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("partial function", function (t) {
|
||||
var apOne = partial(one, 3);
|
||||
t.equal(apOne(4),
|
||||
3 * 2 + 4);
|
||||
|
||||
var apTwo = partial(two, 3, 4);
|
||||
t.equal(apTwo(5, 6),
|
||||
3 * 2 + (4 + 5) * 6);
|
||||
|
||||
var apThree = partial(three, 3);
|
||||
t.equal(apThree.call(z, 4),
|
||||
10 * (3 * 2 + 4));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("partialRight function", function (t) {
|
||||
var paOne = partialRight(one, 3);
|
||||
t.equal(paOne(4),
|
||||
4 * 2 + 3);
|
||||
|
||||
var paTwo = partialRight(two, 3, 4);
|
||||
t.equal(paTwo(5, 6),
|
||||
5 * 2 + (6 + 3) * 4);
|
||||
|
||||
var paThree = partialRight(three, 3);
|
||||
t.equal(paThree.call(z, 4),
|
||||
10 * (4 * 2 + 3));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("curry function", function (t) {
|
||||
var apOne = curry(one)(3);
|
||||
t.equal(apOne(4),
|
||||
3 * 2 + 4, "curry one");
|
||||
|
||||
var apTwo = curry(two)(3, 4);
|
||||
t.equal(apTwo(5, 6),
|
||||
3 * 2 + (4 + 5) * 6, "curry two");
|
||||
|
||||
var apThree = curry(three)(3);
|
||||
t.equal(apThree.call(z, 4),
|
||||
10 * (3 * 2 + 4), "curry three");
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("curryRight function", function (t) {
|
||||
var paOne = curryRight(one)(3);
|
||||
t.equal(paOne(4),
|
||||
4 * 2 + 3);
|
||||
|
||||
var paTwo = curryRight(two)(3, 4);
|
||||
t.equal(paTwo(5, 6),
|
||||
5 * 2 + (6 + 3) * 4);
|
||||
|
||||
var paThree = curryRight(three)(3);
|
||||
t.equal(paThree.call(z, 4),
|
||||
10 * (4 * 2 + 3));
|
||||
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user