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

curry-d

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curry-d - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

43

dist/curry-d.js
/*global exports:true,define:false*/
/*jshint maxstatements:20*/
//noinspection ThisExpressionReferencesGlobalObjectJS

@@ -17,3 +18,3 @@ (function (root, factory) {

var slice = Array.prototype.slice;
var RIGHT = 'unshift';
var RIGHT = 'right';

@@ -31,25 +32,26 @@ var makeCurry = function (adder) {

* @param {boolean} [seal=true] Whether to prevent args beyond the len.
* @param {Array.<*>} [held=[]]
* @param {Array.<*>} [held=[]] Arguments fro a previous call.
* @return {function} A function that executes fn once it's been passed all its arguments.
*/
return function currier(fn, len, forceOne, seal, held) {
len = !!len ? len : fn.length;
forceOne = !!forceOne;
seal = seal !== false;
len = !!len ? len : fn.length;
held = held || [];
var position = held.length;
var captured = function curried(args) {
var next = null;
var old = held.slice();
args = slice.call(arguments);
var oldPosition = position;
var nextHeld = held.slice();
if (forceOne) {
held[adder](args[0]);
nextHeld[position++] = args;
}
else {
// If multiple we should reverse the args when right.
held[adder].apply(held, reverse ? args.reverse() : args);
nextHeld = nextHeld.concat(slice.call(arguments));
}
if (held.length < len) {
next = currier(fn, len, !!forceOne, !!seal, held);
held = old;
var next = null;
var nextLen = nextHeld.length;
if (nextLen < len) {
next = currier(fn, len, forceOne, seal, nextHeld);
position = oldPosition;
return next;

@@ -59,5 +61,14 @@ } else {

// Clear off the beginning if it's a right
held = !reverse ? held.slice(0, len) : held.slice(held.length - len);
if (reverse) {
nextHeld.reverse().splice(0, nextLen - len);
return fn.apply(this, nextHeld);
}
// Clear extras.
else {
return fn.apply(this, nextHeld.slice(0, len));
}
}
return fn.apply(this, held);
else {
return fn.apply(this, reverse ? nextHeld.reverse() : nextHeld);
}
}

@@ -70,3 +81,3 @@ };

exports.curry = makeCurry('push');
exports.curry = makeCurry();
exports.curryRight = exports.curry.r = makeCurry(RIGHT);

@@ -73,0 +84,0 @@ exports.uncurry = exports.curry.un = function (curried) {

/**
* @license
* curry-d 0.4.0 https://github.com/jnewman/curry-d/blob/master/LICENSE.txt
* Build time: 2013-07-13P17:07:47
* curry-d 0.5.0 https://github.com/jnewman/curry-d/blob/master/LICENSE.txt
* Build time: 2013-07-13P18:07:54
*/
;!function(a,b){"function"==typeof define&&define.amd?define(["exports"],b):"object"==typeof exports?b(exports):b(a)}(this,function(a){"use strict";var b=Array.prototype.slice,c="unshift",d=function(a){var d=a===c;return function e(c,f,g,h,i){h=h!==!1,f=f?f:c.length,i=i||[];var j=function(j){var k=null,l=i.slice();return j=b.call(arguments),g?i[a](j[0]):i[a].apply(i,d?j.reverse():j),i.length<f?(k=e(c,f,!!g,!!h,i),i=l,k):(h&&(i=d?i.slice(i.length-f):i.slice(0,f)),c.apply(this,i))};return j._fn=c,j}};a.curry=d("push"),a.curryRight=a.curry.r=d(c),a.uncurry=a.curry.un=function(a){return a._fn||a}});
;!function(a,b){"function"==typeof define&&define.amd?define(["exports"],b):"object"==typeof exports?b(exports):b(a)}(this,function(a){"use strict";var b=Array.prototype.slice,c="right",d=function(a){var d=a===c;return function e(a,c,f,g,h){c=c?c:a.length,f=!!f,g=g!==!1,h=h||[];var i=h.length,j=function(j){var k=i,l=h.slice();f?l[i++]=j:l=l.concat(b.call(arguments));var m=null,n=l.length;return c>n?(m=e(a,c,f,g,l),i=k,m):g?d?(l.reverse().splice(0,n-c),a.apply(this,l)):a.apply(this,l.slice(0,c)):a.apply(this,d?l.reverse():l)};return j._fn=a,j}};a.curry=d(),a.curryRight=a.curry.r=d(c),a.uncurry=a.curry.un=function(a){return a._fn||a}});
{
"name": "curry-d",
"version": "0.4.0",
"version": "0.5.0",
"description": "Curry and curry right at arbitrary depth, then uncurry, if you want.",

@@ -5,0 +5,0 @@ "author": "Joshua Newman <joshua.l.newman@gmail.com>",

# curry-d
An implementation of curry that uses a dispatcher to achieve arbitrary curry length. This micro library trades the
ability to check arity for [~2x](/perf/samples.csv) perf on high arity function and increased
flexibility.
ability to check arity for [~2.2x](./perf/samples.csv) perf on high arity functions and 1.2x on <=
10 and increased flexibility (decide if there should be only one arg and allow extra args).

@@ -7,0 +7,0 @@ [![Build Status](https://api.travis-ci.org/jnewman/curry-d.png?branch=master)](https://travis-ci.org/jnewman/curry-d)

/*global exports:true,define:false*/
/*jshint maxstatements:20*/
//noinspection ThisExpressionReferencesGlobalObjectJS

@@ -17,3 +18,3 @@ (function (root, factory) {

var slice = Array.prototype.slice;
var RIGHT = 'unshift';
var RIGHT = 'right';

@@ -31,25 +32,26 @@ var makeCurry = function (adder) {

* @param {boolean} [seal=true] Whether to prevent args beyond the len.
* @param {Array.<*>} [held=[]]
* @param {Array.<*>} [held=[]] Arguments fro a previous call.
* @return {function} A function that executes fn once it's been passed all its arguments.
*/
return function currier(fn, len, forceOne, seal, held) {
len = !!len ? len : fn.length;
forceOne = !!forceOne;
seal = seal !== false;
len = !!len ? len : fn.length;
held = held || [];
var position = held.length;
var captured = function curried(args) {
var next = null;
var old = held.slice();
args = slice.call(arguments);
var oldPosition = position;
var nextHeld = held.slice();
if (forceOne) {
held[adder](args[0]);
nextHeld[position++] = args;
}
else {
// If multiple we should reverse the args when right.
held[adder].apply(held, reverse ? args.reverse() : args);
nextHeld = nextHeld.concat(slice.call(arguments));
}
if (held.length < len) {
next = currier(fn, len, !!forceOne, !!seal, held);
held = old;
var next = null;
var nextLen = nextHeld.length;
if (nextLen < len) {
next = currier(fn, len, forceOne, seal, nextHeld);
position = oldPosition;
return next;

@@ -59,5 +61,14 @@ } else {

// Clear off the beginning if it's a right
held = !reverse ? held.slice(0, len) : held.slice(held.length - len);
if (reverse) {
nextHeld.reverse().splice(0, nextLen - len);
return fn.apply(this, nextHeld);
}
// Clear extras.
else {
return fn.apply(this, nextHeld.slice(0, len));
}
}
return fn.apply(this, held);
else {
return fn.apply(this, reverse ? nextHeld.reverse() : nextHeld);
}
}

@@ -70,3 +81,3 @@ };

exports.curry = makeCurry('push');
exports.curry = makeCurry();
exports.curryRight = exports.curry.r = makeCurry(RIGHT);

@@ -73,0 +84,0 @@ exports.uncurry = exports.curry.un = function (curried) {

Sorry, the diff of this file is not supported yet

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