Comparing version 2.0.0 to 2.0.1
@@ -5,5 +5,5 @@ /** | ||
* 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 | ||
* Version 2.0.1 - Compiled on 2017-12-05 00:18:39 | ||
* Repository git://github.com/anodynos/decurry | ||
* Copyright(c) 2016 Angelos Pikoulas <agelos.pikoulas@gmail.com> | ||
* Copyright(c) 2017 Angelos Pikoulas <agelos.pikoulas@gmail.com> | ||
* License MIT | ||
@@ -10,0 +10,0 @@ */ |
{ | ||
"name": "decurry", | ||
"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", | ||
"version": "2.0.1", | ||
"homepage": "http://github.com/anodynos/decurry/", | ||
@@ -55,3 +55,3 @@ "author": { | ||
"mocha": "2.4.x", | ||
"ramda": "^0.22.1", | ||
"ramda": "^0.25", | ||
"urequire": "0.7.0-beta.29", | ||
@@ -58,0 +58,0 @@ "urequire-ab-specrunner": "^0.2.5" |
@@ -1,25 +0,33 @@ | ||
# decurry v2.0.0 | ||
# decurry v2.0.1 | ||
[![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`. It works exactly the same as [Ramda's `uncurryN`](http://ramdajs.com/docs/#uncurryN). | ||
The `decurry` higher order function, is like the the _reverse_ of `curry`. | ||
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: | ||
`fn(arg1)(arg2)(arg3)` | ||
`fn(arg1, arg2, arg3)` | ||
`fn(arg1)(arg2, arg3)` | ||
`fn(arg1, arg2)(arg3)` | ||
`fn(arg1)(arg2)(arg3)` | ||
etc, are all equivalent. | ||
## Motivation | ||
It works the same as Ramda's [`R.uncurryN`](http://ramdajs.com/docs/#uncurryN) BUT unlike it, it works ALWAYS - for both manual and `R.compose` curried functions. See the 2nd test in [decurry-spec](https://github.com/anodynos/decurry/blob/master/source/spec/decurry-spec.coffee) where `R.uncurryN` fails (as of December 2017, v0.25.0). Why, I dont know, TBO I haven't checked their code, but the documentation says "Returns a function of arity n from a (manually) curried function."! | ||
## Why do we need decurry? | ||
When we compose a 'curried' function, due to composition (eg with `R.compose` or lodash's [`flowRight`](https://lodash.com/docs/4.17.2#flowRight) ), the curried function has to be called strictly as `fn(arg1)(arg2)(arg3)` etc, to yield its final result. Each argument has to be passed one by one, which seems tedious and unnatural. | ||
With `decurry` we get back a `decurried` function that can be called as one-by-one, but also in any combination of arguments arrangements, for example: | ||
`fn(arg1)(arg2)(arg3)` | ||
`fn(arg1, arg2, arg3)` | ||
`fn(arg1)(arg2, arg3)` | ||
`fn(arg1, arg2)(arg3)` | ||
`fn(arg1)(arg2)(arg3)` | ||
etc, are all equivalent. | ||
Usage: | ||
var _f = require('lodash/fp'); | ||
var tasks = [ | ||
@@ -35,5 +43,5 @@ { | ||
]; | ||
project = _f.flowRight([_f.map, _f.pick]); | ||
project(['title', 'priority'])(tasks); | ||
@@ -43,13 +51,14 @@ // works fine, as its called with (arg1)(arg2) and it returns | ||
// { title: 'Add `fork` function', priority: 'low' } ] | ||
project(['title', 'priority'], tasks); | ||
// doesn't work, `tasks` is completely ignored and it returns a function that is waiting for `tasks` to yield results | ||
decurriedProject = decurry(2, project); | ||
decurriedProject(['title', 'priority'], tasks); // works fine | ||
decurriedProject(['title', 'priority'])(tasks); // works fine also | ||
The same goes for functions with larger arity. | ||
Copyright(c) 2016 Angelos Pikoulas (agelos.pikoulas@gmail.com) | ||
Copyright(c) 2016-2017 Angelos Pikoulas (agelos.pikoulas@gmail.com) | ||
@@ -56,0 +65,0 @@ Permission is hereby granted, free of charge, to any person |
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
83
7067
4