Socket
Socket
Sign inDemoInstall

wrap-fn

Package Overview
Dependencies
75
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

2

component.json
{
"name": "wrap-fn",
"version": "0.1.1",
"version": "0.1.2",
"description": "support sync, async, and generator functions",

@@ -5,0 +5,0 @@ "dependencies": {

0.1.2 / 2015-01-16
==================
* catch uncaught synchronous errors in async functions
0.1.1 / 2014-09-24
==================
* Add "scripts" field in `component.json`
0.1.0 / 2014-09-17

@@ -3,0 +13,0 @@ ==================

@@ -5,5 +5,4 @@ /**

var slice = [].slice;
var noop = function(){};
var co = require('co');
var noop = function(){};

@@ -27,6 +26,11 @@ /**

function wrap(fn, done) {
done = done || noop;
done = once(done || noop);
return function() {
var args = slice.call(arguments);
// prevents arguments leakage
// see https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
var i = arguments.length;
var args = new Array(i);
while (i--) args[i] = arguments[i];
var ctx = this;

@@ -41,3 +45,8 @@

if (fn.length > args.length) {
return fn.apply(ctx, args.concat(done));
// NOTE: this only handles uncaught synchronous errors
try {
fn.apply(ctx, args.concat(done));
} catch (e) {
done(e);
}
}

@@ -108,1 +117,13 @@

}
/**
* Once
*/
function once(fn) {
return function() {
var ret = fn.apply(this, arguments);
fn = noop;
return ret;
};
}
{
"name": "wrap-fn",
"version": "0.1.1",
"version": "0.1.2",
"description": "support sync, async, and generator functions",

@@ -5,0 +5,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc