Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decurry

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decurry - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

4

build/code/decurry.js
/**
* decurry http://github.com/anodynos/decurry/
*
* Decurry is 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.0 - Compiled on 2016-11-24 00:16:10
* 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
* Repository git://github.com/anodynos/decurry

@@ -7,0 +7,0 @@ * Copyright(c) 2016 Angelos Pikoulas <agelos.pikoulas@gmail.com>

{
"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.0",
"version": "1.0.1",
"homepage": "http://github.com/anodynos/decurry/",

@@ -6,0 +6,0 @@ "author": {

@@ -1,9 +0,23 @@

# decurry v1.0.0
# decurry v1.0.1
Decurry is like the the 'reverse' of curry.
[![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`.
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.
eg `fn(arg1)(arg2)(arg3)` or `fn(arg1, arg2, arg3)` or `fn(arg1)(arg2, arg3)` or `fn(arg1, arg2)(arg3)` or `fn(arg1)(arg2)(arg3)` etc
Usage:

@@ -16,3 +30,3 @@

username: 'Michael', title: 'Curry stray functions',
complete: true, effort: 'low', priority: 'low'
complete: true, effort: 'low', priority: 'high'
},

@@ -27,8 +41,8 @@ {

project(['title', 'dueDate'])(tasks);
project(['title', 'priority'])(tasks);
// works fine, as its called with (arg1)(arg2) and it returns
// [ { title: 'Curry stray functions' },
// { title: 'Add `fork` function' } ]
// [ { title: 'Curry stray functions', priority: 'high' },
// { title: 'Add `fork` function', priority: 'low' } ]
project(['title', 'dueDate'], tasks);
project(['title', 'priority'], tasks);
// doesn't work, `tasks` is completely ignored and it returns a function that is waiting for `tasks` to yield results

@@ -38,4 +52,4 @@

decurriedProject(['title', 'dueDate'], tasks); // works fine
decurriedProject(['title', 'dueDate'])(tasks); // works fine also
decurriedProject(['title', 'priority'], tasks); // works fine
decurriedProject(['title', 'priority'])(tasks); // works fine also

@@ -42,0 +56,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc