Use rest parameters
This commit is contained in:
		
					parent
					
						
							
								e05804848f
							
						
					
				
			
			
				commit
				
					
						8889c29866
					
				
			
		
					 14 changed files with 88 additions and 143 deletions
				
			
		| 
						 | 
				
			
			@ -1,7 +1,5 @@
 | 
			
		|||
'use strict';
 | 
			
		||||
 | 
			
		||||
var slice = [].slice;
 | 
			
		||||
 | 
			
		||||
const v8Util = process.atomBinding('v8_util');
 | 
			
		||||
 | 
			
		||||
class CallbacksRegistry {
 | 
			
		||||
| 
						 | 
				
			
			@ -46,16 +44,14 @@ class CallbacksRegistry {
 | 
			
		|||
    return (ref = this.callbacks[id]) != null ? ref : function() {};
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  call() {
 | 
			
		||||
    var args, id, ref;
 | 
			
		||||
    id = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
 | 
			
		||||
    return (ref = this.get(id)).call.apply(ref, [global].concat(slice.call(args)));
 | 
			
		||||
  call(id, ...args) {
 | 
			
		||||
    var ref;
 | 
			
		||||
    return (ref = this.get(id)).call.apply(ref, [global].concat(args));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  apply() {
 | 
			
		||||
    var args, id, ref;
 | 
			
		||||
    id = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
 | 
			
		||||
    return (ref = this.get(id)).apply.apply(ref, [global].concat(slice.call(args)));
 | 
			
		||||
  apply(id, ...args) {
 | 
			
		||||
    var ref;
 | 
			
		||||
    return (ref = this.get(id)).apply.apply(ref, [global].concat(args));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  remove(id) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue