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

auto-curry

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

auto-curry - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

.jshintrc

2

index.js
module.exports = function cu(fn) {
'use strict';
var args = [].slice.call(arguments);
if ('function' !== typeof fn) throw new Error('auto-curry: Invalid parameter. First parameter should be a function.');

@@ -4,0 +6,0 @@ if ('function' === typeof fn && !fn.length) return fn;

13

package.json
{
"name": "auto-curry",
"version": "0.1.1",
"version": "0.2.0",
"description": "Supercharge your functions by giving them the ability to auto-curry",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [

@@ -25,3 +22,9 @@ "curry",

},
"homepage": "https://github.com/zeusdeux/auto-curry"
"homepage": "https://github.com/zeusdeux/auto-curry",
"devDependencies": {
"browserify": "^6.0.2",
"jshint": "^2.5.6",
"mocha": "^1.21.4",
"uglify-js": "^2.4.15"
}
}

@@ -14,2 +14,11 @@ auto-curry

In `node`, you can just `require('auto-curry')`.
In the browser, you can use `build/auto-curry.min.js`
- with `require.js`, `browserify` etc
- directly by using `window.autoCurry`
##Node
```javascript

@@ -20,16 +29,51 @@ var cu = require('auto-curry');

});
var map = cu(function map(list, fn) {
var messWithThis = cu(function(v){
this.a.push(v);
return ++v;
});
var map = cu(function map(fn, list) {
var self = arguments[2] ? arguments[2] : this;
try {
return list.map(fn);
return list.map(fn, self);
}
catch (e) {
return [].map.call(list, fn);
return [].map.call(list, fn, self);
}
});
var x = {a: []};
console.log(map([1, 2, 3], add(1))); //[2, 3, 4]
console.log(map(add(1), [1, 2, 3])); //[2, 3, 4]
console.log(map(messWithThis, [1,2,3], x)); //[2, 3, 4]
console.log(x.a); //[1, 2, 3]
```
##Browser
```javascript
var cu = window.autoCurry; //using it off the global
var add = cu(function (a, b) {
return a + b;
});
var messWithThis = cu(function(v){
this.a.push(v);
return ++v;
});
var map = cu(function map(fn, list) {
console.log(arguments[2]);
var self = arguments[2] ? arguments[2] : this;
try {
return list.map(fn, self);
}
catch (e) {
return [].map.call(list, fn, self);
}
});
var x = {a: []};
console.log(map(add(1), [1, 2, 3])); //[2, 3, 4]
console.log(map(messWithThis, [1,2,3], x)); //[2, 3, 4]
console.log(x.a); //[1, 2, 3]
```
#License
[MIT](https://github.com/zeusdeux/auto-curry/blob/master/LICENSE)
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