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

chickencurry

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chickencurry - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

19

index.js

@@ -17,10 +17,21 @@ var slice = Array.prototype.slice,

function countArgs(args) {
var count = 0;
for (var i = 0; i < args.length; i++) {
if (args[i] !== __) {
count = count + 1;
}
}
return count;
}
function recurry(fn, curryArgs) {
return function() {
var args = curryArgs.concat(slice.call(arguments));
var args = slice.call(arguments),
mergedArgs = mergeArguments(args, curryArgs);
if (fn.length <= args.length) {
return fn.apply(null, args);
if (fn.length <= countArgs(mergedArgs)) {
return fn.apply(null, mergedArgs);
} else {
return recurry(fn, args);
return recurry(fn, mergedArgs);
}

@@ -27,0 +38,0 @@ }

{
"name": "chickencurry",
"version": "0.1.0",
"version": "0.2.0",
"description": "Add some chicken curry to your functions",

@@ -5,0 +5,0 @@ "main": "index.js",

Chickencurry
============
[![Build Status](https://travis-ci.org/stoeffel/chickencurry.svg)](https://travis-ci.org/stoeffel/chickencurry) [![npm version](https://badge.fury.io/js/chickencurry.svg)](http://badge.fury.io/js/chickencurry)
> Add some chickencurry to your functions

@@ -30,2 +29,19 @@

### Recurry
You can curry a function and define the arguments for the curryied functions later.
```js
function add(a, b) {
return a + b;
}
var curryiedAdd = curry(add); // no arguments passed to curry
var add1 = curryiedAdd(1);
var add2 = curryiedAdd(2);
add1(3); // => 4
add2(3); // => 5
```
### Placeholder

@@ -41,2 +57,3 @@

var __ = curry.__;
var join_ = curry(join, __, __, '_');

@@ -46,19 +63,8 @@ // or var join_ = curry(join, undefined, undefined, '_');

join_('chicken', 'curry'); // => 'chicken_curry'
```
### Recurry
You can curry a function and define the arguments for the curryied functions later.
var joinCurry = curry(join);
var joinDash = joinCurry(__, __, '-');
```js
function add(a, b) {
return a + b;
}
var curryiedAdd = curry(add); // no arguments passed to curry
var add1 = curryiedAdd(1);
var add2 = curryiedAdd(2);
add1(3); // => 4
add2(3); // => 5
joinDash('chicken', 'curry'); // => 'chicken-curry'
```

@@ -65,0 +71,0 @@

@@ -84,3 +84,7 @@ var curry = require('./index.js'),

expect(joinCurry('_', '_', 'chicken')).to.equal('_chicken_');
expect(joinCurry(curry.__,'_')('_', 'chicken')).to.equal('_chicken_');
expect(joinCurry('_', curry.__)('-', 'chicken')).to.equal('_chicken-');
expect(joinCurry('_', curry.__, 'chicken')('-')).to.equal('_chicken-');
expect(joinCurry(curry.__, '_', 'chicken')('-')).to.equal('-chicken_');
});
});
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