Socket
Socket
Sign inDemoInstall

async-method

Package Overview
Dependencies
28
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 1.0.0

LICENSE

42

lib/asyncMethod.js

@@ -1,31 +0,23 @@

!function() {
'use strict';
var type = require('ee-types')
, Promise = (Promise || require('es6-promise').Promise);
const type = require('ee-types');
module.exports = function(method) {
return function(...args) {
// if the last argument is a function, we're working with callbacks
if (type.function(args[args.length -1])) {
method(...args);
} else {
return new Promise((resolve, reject) => {
args.push((err, arg) => {
if (err) reject(err);
else resolve(arg);
});
module.exports = function(method) {
return function() {
// create an array out of the arguments object
var args = Array.prototype.slice.call(arguments);
// if the last argument is a function, we're working with callbacks
if (type.function(args[args.length -1])) {
method.apply(this, args);
}
else {
return new Promise(function(resolve, reject) {
args.push(function(err, arg) {
if (err) reject(err);
else resolve(arg);
});
method.apply(this, args);
}.bind(this));
}
method(...args);
});
}
}
}();
}
{
"name" : "async-method"
, "description" : "Makes async methods work with callbacks and promises"
, "version" : "0.1.1"
, "homepage" : "https://github.com/eventEmitter/async-method"
, "author" : "Michael van der Weg <michael@joinbox.com> (http://joinbox.com/)"
, "licence" : "mit"
, "repository": {
"url" : "https://github.com/eventEmitter/async-method.git"
, "type" : "git"
"name": "async-method",
"description": "Makes async methods work with callbacks and promises",
"version": "1.0.0",
"homepage": "https://github.com/eventEmitter/async-method",
"author": "Michael van der Weg <michael@joinbox.com> (http://joinbox.com/)",
"licence": "mit",
"repository": {
"url": "https://github.com/eventEmitter/async-method.git",
"type": "git"
},
"engines": {
"node": ">=v8"
},
"bugs": {
"url": "https://github.com/eventEmitter/async-method/issues"
},
"dependencies": {
"ee-types": "2.1.4",
"ee-log": "3.0.6"
},
"devDependencies": {
"mocha": "5.x"
},
"optionalDependencies": {},
"keywords": [
"async",
"methods"
],
"scripts": {
"test": "./node_modules/mocha/bin/mocha --reporter spec"
}
, "engines": {
"node" : ">=v0.10.17"
}
, "bugs": {
"url" : "https://github.com/eventEmitter/async-method/issues"
}
, "dependencies": {
"ee-class" : "1.0.x"
, "es6-promise" : "1.0.x"
, "ee-types" : "0.1.x"
, "ee-log" : "0.3.x"
}
, "devDependencies": {
"mocha" : "1.17.x"
}
, "optionalDependencies": {}
, "keywords" : ["async", "methods"]
, "scripts": {
"test" : "./node_modules/mocha/bin/mocha --reporter spec"
}
}
}
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