Use rest parameters

This commit is contained in:
Kevin Sawicki 2016-03-18 11:51:02 -07:00
parent e05804848f
commit 8889c29866
14 changed files with 88 additions and 143 deletions

View file

@ -1,8 +1,5 @@
// Deprecate a method.
var deprecate,
slice = [].slice;
deprecate = function(oldName, newName, fn) {
const deprecate = function(oldName, newName, fn) {
var warned;
warned = false;
return function() {
@ -64,10 +61,7 @@ deprecate.property = function(object, property, method) {
deprecate.event = function(emitter, oldName, newName, fn) {
var warned;
warned = false;
return emitter.on(newName, function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return emitter.on(newName, function(...args) {
// there is listeners for old API.
if (this.listenerCount(oldName) > 0) {
if (!(warned || process.noDeprecation)) {
@ -77,7 +71,7 @@ deprecate.event = function(emitter, oldName, newName, fn) {
if (fn != null) {
return fn.apply(this, arguments);
} else {
return this.emit.apply(this, [oldName].concat(slice.call(args)));
return this.emit.apply(this, [oldName].concat(args));
}
}
});