async-listener
Advanced tools
Comparing version 0.0.2 to 0.0.3
32
glue.js
@@ -9,3 +9,3 @@ 'use strict'; | ||
listener = list[i]; | ||
data[i] = listener.onAsync(); | ||
data[i] = listener.onAsync.call(this); | ||
} | ||
@@ -93,23 +93,2 @@ return data; | ||
// Shim activator for functions that have callback last | ||
function activator(fn) { | ||
return function () { | ||
var index = arguments.length - 1; | ||
if (typeof arguments[index] === "function") { | ||
arguments[index] = wrapCallback(arguments[index]); | ||
} | ||
return fn.apply(this, arguments); | ||
}; | ||
} | ||
// Shim activator for functions that have callback first | ||
function activatorFirst(fn) { | ||
return function () { | ||
if (typeof arguments[0] === "function") { | ||
arguments[0] = wrapCallback(arguments[0]); | ||
} | ||
return fn.apply(this, arguments); | ||
}; | ||
} | ||
function addAsyncListener(onAsync, callbackObject) { | ||
@@ -123,6 +102,7 @@ var listener = { | ||
return listener; | ||
return listener.onAsync; | ||
} | ||
function removeAsyncListener(onAsync) { | ||
if (!onAsync) throw new Error("must pass listener to remove"); | ||
var index = -1; | ||
@@ -143,6 +123,2 @@ for (var i = 0; i < listeners.length; i++) { | ||
module.exports = { | ||
wrapCallback : wrapCallback, | ||
activator : activator, | ||
activatorFirst : activatorFirst | ||
}; | ||
module.exports = wrapCallback; |
32
index.js
@@ -5,11 +5,29 @@ 'use strict'; | ||
var shimmer = require('shimmer') | ||
, wrap = shimmer.wrap | ||
, massWrap = shimmer.massWrap | ||
, glue = require('./glue.js') | ||
, wrapCallback = glue.wrapCallback | ||
, activator = glue.activator | ||
, activatorFirst = glue.activatorFirst | ||
var shimmer = require('shimmer') | ||
, wrap = shimmer.wrap | ||
, massWrap = shimmer.massWrap | ||
, wrapCallback = require('./glue.js') | ||
; | ||
// Shim activator for functions that have callback last | ||
function activator(fn) { | ||
return function () { | ||
var index = arguments.length - 1; | ||
if (typeof arguments[index] === "function") { | ||
arguments[index] = wrapCallback(arguments[index]); | ||
} | ||
return fn.apply(this, arguments); | ||
}; | ||
} | ||
// Shim activator for functions that have callback first | ||
function activatorFirst(fn) { | ||
return function () { | ||
if (typeof arguments[0] === "function") { | ||
arguments[0] = wrapCallback(arguments[0]); | ||
} | ||
return fn.apply(this, arguments); | ||
}; | ||
} | ||
var net = require('net'); | ||
@@ -16,0 +34,0 @@ wrap(net.Server.prototype, '_listen2', function (original) { |
{ | ||
"name": "async-listener", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Polyfill exporting trevnorris's 0.11+ process.addAsynListener API.", | ||
@@ -5,0 +5,0 @@ "author": "Forrest L Norvell <ogd@aoaioxxysz.net>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16252
7
433