Comparing version 1.0.1 to 2.0.0
/** | ||
* decurry http://github.com/anodynos/decurry/ | ||
* | ||
* Decurry is the kinda the 'reverse' of curry: given a composed function `fn(arg1)(arg2)(arg3)` it gives a function that can be called as `fn(arg1, arg2, arg3)` or `fn(arg1, arg2)(arg3) etc.` | ||
* Version 1.0.1 - Compiled on 2016-11-24 01:16:26 | ||
* decurry is the 'reverse' of curry: given a composed function `fn(arg1)(arg2)(arg3)` it returns a function that can be called as `fn(arg1, arg2, arg3)` or `fn(arg1, arg2)(arg3) etc.` | ||
* Version 2.0.0 - Compiled on 2016-12-10 17:45:07 | ||
* Repository git://github.com/anodynos/decurry | ||
@@ -14,19 +14,19 @@ * Copyright(c) 2016 Angelos Pikoulas <agelos.pikoulas@gmail.com> | ||
var decurry, __slice = [].slice; | ||
decurry = function (curriedFunction, maxArguments) { | ||
if (maxArguments == null) { | ||
maxArguments = Infinity; | ||
var decurry, slice = [].slice; | ||
module.exports = decurry = function (arity, curriedFunction) { | ||
if (typeof arity !== "number") { | ||
throw new Error("decurry(arity, curriedFunction): arity was not a number"); | ||
} | ||
return function () { | ||
var arg, args, i, result, _i, _len; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
var arg, args, i, j, len, result; | ||
args = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
result = curriedFunction; | ||
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) { | ||
for (i = j = 0, len = args.length; j < len; i = ++j) { | ||
arg = args[i]; | ||
if (i < maxArguments) { | ||
if (i < arity) { | ||
result = result(arg); | ||
} | ||
} | ||
if (args.length < maxArguments) { | ||
result = decurry(result, maxArguments - args.length); | ||
if (args.length < arity) { | ||
result = decurry(arity - args.length, result); | ||
} | ||
@@ -36,4 +36,3 @@ return result; | ||
}; | ||
module.exports = decurry; | ||
; |
{ | ||
"name": "decurry", | ||
"description": "Decurry is the kinda the 'reverse' of curry: given a composed function `fn(arg1)(arg2)(arg3)` it gives a function that can be called as `fn(arg1, arg2, arg3)` or `fn(arg1, arg2)(arg3) etc.`", | ||
"version": "1.0.1", | ||
"description": "decurry is the 'reverse' of curry: given a composed function `fn(arg1)(arg2)(arg3)` it returns a function that can be called as `fn(arg1, arg2, arg3)` or `fn(arg1, arg2)(arg3) etc.`", | ||
"version": "2.0.0", | ||
"homepage": "http://github.com/anodynos/decurry/", | ||
@@ -13,8 +13,14 @@ "author": { | ||
"curry", | ||
"combose", | ||
"compose", | ||
"reverse", | ||
"decurry", | ||
"uncurry", | ||
"variadic", | ||
"partial", | ||
"function", | ||
"functions", | ||
"functional", | ||
"ramda", | ||
"lodash", | ||
"lodash/fp", | ||
"flowRight", | ||
@@ -45,2 +51,3 @@ "flow" | ||
"chai": "3.5.x", | ||
"coffee-script": "1.12.1", | ||
"grunt": "0.4.5", | ||
@@ -50,2 +57,3 @@ "grunt-contrib-watch": "0.6.x", | ||
"mocha": "2.4.x", | ||
"ramda": "^0.22.1", | ||
"urequire": "0.7.0-beta.29", | ||
@@ -52,0 +60,0 @@ "urequire-ab-specrunner": "^0.2.5" |
@@ -1,11 +0,9 @@ | ||
# decurry v1.0.1 | ||
# decurry v2.0.0 | ||
[![Build Status](https://travis-ci.org/anodynos/decurry.svg?branch=master)](https://travis-ci.org/anodynos/decurry) | ||
The `decurry` higher order function, is like the the _reverse_ of `curry`. | ||
The `decurry` higher order function, is like the the _reverse_ of `curry`. It works exactly the same as [Ramda's `uncurryN`](http://ramdajs.com/docs/#uncurryN). | ||
Given a composed "curried" function, that due to composition (eg with lodash's [flowRight](https://lodash.com/docs/4.17.2#flowRight) ) has to be called strictly as `fn(arg1)(arg2)(arg3)` to yield its final result, `decurry` gives a "decurried" function that can be called both as the original one, but also in any combination of arguments arrangements: | ||
Given a composed "curried" function, that due to composition (eg with lodash's [flowRight](https://lodash.com/docs/4.17.2#flowRight) ) has to be called strictly as `fn(arg1)(arg2)(arg3)` to yield its final result, `decurry` gives a "decurried" function that can be called both as the original one, but also in any combination of arguments arrangements, for example: | ||
For example | ||
`fn(arg1)(arg2)(arg3)` | ||
@@ -48,3 +46,3 @@ | ||
decurriedProject = decurry(project, 2); | ||
decurriedProject = decurry(2, project); | ||
@@ -55,3 +53,3 @@ decurriedProject(['title', 'priority'], tasks); // works fine | ||
Copyright(c) 2016 Agelos Pikoulas (agelos.pikoulas@gmail.com) | ||
Copyright(c) 2016 Angelos Pikoulas (agelos.pikoulas@gmail.com) | ||
@@ -58,0 +56,0 @@ Permission is hereby granted, free of charge, to any person |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7558
9
31
74