mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(bower) currify v2.0.2
This commit is contained in:
parent
32371bf2a7
commit
40b2265cdc
12 changed files with 165 additions and 109 deletions
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"name": "currify",
|
||||
"version": "1.0.0",
|
||||
"description": "translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments",
|
||||
"homepage": "https://github.com/coderaiser/currify",
|
||||
"authors": [
|
||||
|
|
@ -18,19 +17,17 @@
|
|||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
"test"
|
||||
],
|
||||
"_release": "1.0.0",
|
||||
"version": "2.0.2",
|
||||
"_release": "2.0.2",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.0",
|
||||
"commit": "aeb6b45ce3b87d9982680945e829fab92c80b767"
|
||||
"tag": "v2.0.2",
|
||||
"commit": "c12ef5cc8caacd81d9a3aebd5b3fb3ba18a53878"
|
||||
},
|
||||
"_source": "https://github.com/coderaiser/currify.git",
|
||||
"_target": "^1.0.0",
|
||||
"_target": "^2.0.2",
|
||||
"_originalSource": "currify",
|
||||
"_direct": true
|
||||
}
|
||||
28
modules/currify/ChangeLog
Normal file
28
modules/currify/ChangeLog
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
2016.11.23, v2.0.2
|
||||
|
||||
fix:
|
||||
- (currify) when to much function.length use default
|
||||
|
||||
|
||||
2016.11.23, v2.0.1
|
||||
|
||||
fix:
|
||||
- (currify) add support of 4 and 5 arguments
|
||||
|
||||
|
||||
2016.11.23, v2.0.0
|
||||
|
||||
feature:
|
||||
- (travis) node_js: v6, v7
|
||||
- (currify) fn.length in curried functions
|
||||
- (package) scripts: coverage
|
||||
- (gitignore) *.swp
|
||||
- (currify) es2015-ify
|
||||
- (package) redrun v5.0.0
|
||||
- (package) redrun v4.0.0
|
||||
- (package) npm-run-all -> redrun
|
||||
- (package) jscs v3.0.3
|
||||
- (license) add
|
||||
- (gitignore) npm-debug.log -> npm-debug.log*
|
||||
- (package) browserify v13.0.0
|
||||
|
||||
21
modules/currify/LICENSE
Normal file
21
modules/currify/LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) coderaiser
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -11,17 +11,29 @@ npm i currify --save
|
|||
## How to use?
|
||||
|
||||
```js
|
||||
let currify = require('currify');
|
||||
const currify = require('currify');
|
||||
|
||||
let mean = (a, b, c) => (a + b) / c;
|
||||
let mean1 = currify(mean, 1);
|
||||
let mean2 = mean1(2);
|
||||
let result = mean2(2);
|
||||
const mean = (a, b, c) => (a + b) / c;
|
||||
const mean1 = currify(mean, 1);
|
||||
const mean2 = mean1(2);
|
||||
|
||||
mean2(2);
|
||||
// returns
|
||||
1.5
|
||||
```
|
||||
|
||||
## Environments
|
||||
|
||||
In old `node.js` environments that not fully supports `es2015`, `currify` could be used with:
|
||||
|
||||
```js
|
||||
var currify = require('currify/legacy');
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [zames](https://github.com/coderaiser/zames "zames") - converts callback-based functions to Promises and apply currying to arguments
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"name": "currify",
|
||||
"version": "1.0.0",
|
||||
"description": "translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments",
|
||||
"homepage": "https://github.com/coderaiser/currify",
|
||||
"authors": [
|
||||
|
|
@ -18,9 +17,6 @@
|
|||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
"test"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
27
modules/currify/dist/currify.es6.js
vendored
27
modules/currify/dist/currify.es6.js
vendored
|
|
@ -1,27 +0,0 @@
|
|||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.currify = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"currify":[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
module.exports = currify;
|
||||
|
||||
let tail = list => [].slice.call(list, 1);
|
||||
|
||||
function currify(fn) {
|
||||
check(fn);
|
||||
|
||||
let args = tail(arguments);
|
||||
|
||||
if (args.length >= fn.length)
|
||||
return fn(...args);
|
||||
else
|
||||
return function() {
|
||||
return currify(...[fn, ...args, ...arguments]);
|
||||
};
|
||||
}
|
||||
|
||||
function check(fn) {
|
||||
if (typeof fn !== 'function')
|
||||
throw Error('fn should be function!');
|
||||
}
|
||||
|
||||
},{}]},{},["currify"])("currify")
|
||||
});
|
||||
50
modules/currify/dist/currify.js
vendored
50
modules/currify/dist/currify.js
vendored
|
|
@ -1,26 +1,48 @@
|
|||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.currify = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"currify":[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
|
||||
const tail = list => [].slice.call(list, 1);
|
||||
const f = (fn) => [
|
||||
function(a) {
|
||||
return fn(...arguments);
|
||||
},
|
||||
function(a, b) {
|
||||
return fn(...arguments);
|
||||
},
|
||||
function(a, b, c) {
|
||||
return fn(...arguments);
|
||||
},
|
||||
function(a, b, c, d) {
|
||||
return fn(...arguments);
|
||||
},
|
||||
function(a, b, c, d, e) {
|
||||
return fn(...arguments);
|
||||
}
|
||||
];
|
||||
|
||||
module.exports = currify;
|
||||
|
||||
var tail = function tail(list) {
|
||||
return [].slice.call(list, 1);
|
||||
};
|
||||
|
||||
function currify(fn) {
|
||||
module.exports = function currify(fn) {
|
||||
check(fn);
|
||||
|
||||
var args = tail(arguments);
|
||||
|
||||
if (args.length >= fn.length) return fn.apply(undefined, _toConsumableArray(args));else return function () {
|
||||
return currify.apply(undefined, [fn].concat(_toConsumableArray(args), Array.prototype.slice.call(arguments)));
|
||||
|
||||
const args = tail(arguments);
|
||||
|
||||
if (args.length >= fn.length)
|
||||
return fn(...args);
|
||||
|
||||
const again = function() {
|
||||
return currify(...[fn, ...args, ...arguments]);
|
||||
};
|
||||
|
||||
const count = fn.length - arguments.length;
|
||||
const func = f(again)[count];
|
||||
|
||||
return func || again;
|
||||
}
|
||||
|
||||
function check(fn) {
|
||||
if (typeof fn !== 'function') throw Error('fn should be function!');
|
||||
if (typeof fn !== 'function')
|
||||
throw Error('fn should be function!');
|
||||
}
|
||||
|
||||
|
||||
},{}]},{},["currify"])("currify")
|
||||
});
|
||||
1
modules/currify/dist/currify.min.js
vendored
1
modules/currify/dist/currify.min.js
vendored
|
|
@ -1 +0,0 @@
|
|||
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.currify=r()}}(function(){return function r(e,n,t){function o(i,u){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!u&&c)return c(i,!0);if(f)return f(i,!0);var l=new Error("Cannot find module '"+i+"'");throw l.code="MODULE_NOT_FOUND",l}var a=n[i]={exports:{}};e[i][0].call(a.exports,function(r){var n=e[i][1][r];return o(n?n:r)},a,a.exports,r,e,n,t)}return n[i].exports}for(var f="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({currify:[function(r,e){"use strict";function n(r){if(Array.isArray(r)){for(var e=0,n=Array(r.length);e<r.length;e++)n[e]=r[e];return n}return Array.from(r)}function t(r){o(r);var e=f(arguments);return e.length>=r.length?r.apply(void 0,n(e)):function(){return t.apply(void 0,[r].concat(n(e),Array.prototype.slice.call(arguments)))}}function o(r){if("function"!=typeof r)throw Error("fn should be function!")}e.exports=t;var f=function(r){return[].slice.call(r,1)}},{}]},{},["currify"])("currify")});
|
||||
|
|
@ -1,23 +1,44 @@
|
|||
'use strict';
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
|
||||
const tail = list => [].slice.call(list, 1);
|
||||
const f = (fn) => [
|
||||
function(a) {
|
||||
return fn(...arguments);
|
||||
},
|
||||
function(a, b) {
|
||||
return fn(...arguments);
|
||||
},
|
||||
function(a, b, c) {
|
||||
return fn(...arguments);
|
||||
},
|
||||
function(a, b, c, d) {
|
||||
return fn(...arguments);
|
||||
},
|
||||
function(a, b, c, d, e) {
|
||||
return fn(...arguments);
|
||||
}
|
||||
];
|
||||
|
||||
module.exports = currify;
|
||||
|
||||
var tail = function tail(list) {
|
||||
return [].slice.call(list, 1);
|
||||
};
|
||||
|
||||
function currify(fn) {
|
||||
module.exports = function currify(fn) {
|
||||
check(fn);
|
||||
|
||||
var args = tail(arguments);
|
||||
|
||||
if (args.length >= fn.length) return fn.apply(undefined, _toConsumableArray(args));else return function () {
|
||||
return currify.apply(undefined, [fn].concat(_toConsumableArray(args), Array.prototype.slice.call(arguments)));
|
||||
|
||||
const args = tail(arguments);
|
||||
|
||||
if (args.length >= fn.length)
|
||||
return fn(...args);
|
||||
|
||||
const again = function() {
|
||||
return currify(...[fn, ...args, ...arguments]);
|
||||
};
|
||||
|
||||
const count = fn.length - arguments.length;
|
||||
const func = f(again)[count];
|
||||
|
||||
return func || again;
|
||||
}
|
||||
|
||||
function check(fn) {
|
||||
if (typeof fn !== 'function') throw Error('fn should be function!');
|
||||
}
|
||||
if (typeof fn !== 'function')
|
||||
throw Error('fn should be function!');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,27 @@
|
|||
{
|
||||
"name": "currify",
|
||||
"version": "1.0.0",
|
||||
"version": "2.0.2",
|
||||
"description": "translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments",
|
||||
"main": "lib/currify.js",
|
||||
"scripts": {
|
||||
"test": "tape test/*.js",
|
||||
"build": "npm-run-all clean 6to5 bundle bundle:es6 minify",
|
||||
"coverage": "nyc npm test",
|
||||
"lint": "eslint lib test",
|
||||
"build": "redrun clean 6to5 legacy:* bundle bundle minify",
|
||||
"minify": "minify dist/currify.js > dist/currify.min.js",
|
||||
"6to5": "babel -d lib src",
|
||||
"6to5": "babel -d legacy/lib lib",
|
||||
"wisdom": "npm run build",
|
||||
"jscs-fix": "jscs --esnext test src --fix",
|
||||
"clean": "rimraf lib/* dist/*",
|
||||
"clean": "rimraf dist/* legacy/*",
|
||||
"bundle:base": "browserify -s currify --ng false",
|
||||
"bundle": "npm run bundle:base -- -r ./lib/currify.js:currify ./lib/currify.js -o dist/currify.js",
|
||||
"bundle:es6:base": "npm run bundle:base -- -r ./src/currify.js:currify ./src/currify.js",
|
||||
"bundle:es6": "npm run bundle:es6:base -- -o dist/currify.es6.js"
|
||||
"watcher": "nodemon -w test -w lib --exec",
|
||||
"watch:test": "npm run watcher -- npm test",
|
||||
"watch:lint": "npm run watcher -- 'npm run lint'",
|
||||
"watch:tape": "nodemon -w test -w lib --exec tape",
|
||||
"watch:coverage:base": "npm run watcher -- nyc npm test",
|
||||
"watch:coverage:tape": "npm run watcher -- nyc tape",
|
||||
"watch:coverage": "bin/redrun.js watch:coverage:base",
|
||||
"legacy:index": "echo \"module.exports = require('./lib/currify');\" > legacy/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
@ -35,8 +42,11 @@
|
|||
"babel-cli": "^6.1.1",
|
||||
"babel-preset-es2015": "^6.0.15",
|
||||
"browserify": "^13.0.0",
|
||||
"jscs": "^3.0.7",
|
||||
"npm-run-all": "^3.1.1",
|
||||
"eslint": "^3.10.2",
|
||||
"minify": "^2.0.13",
|
||||
"nodemon": "^1.11.0",
|
||||
"nyc": "^10.0.0",
|
||||
"redrun": "^5.0.1",
|
||||
"rimraf": "^2.4.3",
|
||||
"tape": "^4.2.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = currify;
|
||||
|
||||
let tail = list => [].slice.call(list, 1);
|
||||
|
||||
function currify(fn) {
|
||||
check(fn);
|
||||
|
||||
let args = tail(arguments);
|
||||
|
||||
if (args.length >= fn.length)
|
||||
return fn(...args);
|
||||
else
|
||||
return function() {
|
||||
return currify(...[fn, ...args, ...arguments]);
|
||||
};
|
||||
}
|
||||
|
||||
function check(fn) {
|
||||
if (typeof fn !== 'function')
|
||||
throw Error('fn should be function!');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue