Nodejs Function Call times(handler)

Here you can find the source of times(handler)

Method Source Code

/**/*from w  w w. j a v a  2s.c  o m*/
 *  Number#times(iterator) -> Number
 *  - iterator (Function): The function to use as a iterator.
**/
Number.prototype.times = function(handler) {
  var index = 0;
  while(index < this) handler(index++);
  return this
};

Related

  1. times(f, context)
    Number.prototype.times = function(f, context) {
      var n = Number(this);
      for(var i = 0; i < n; i++) f.call(context, i);
    };
    String.prototype.trim = String.prototype.trim || function() {
      if (!this) return this; 
      return this.replace(/^\s+|\s+$/g, ""); 
    };
    Function.prototype.getName = function() {
    ...
    
  2. times(fn)
    'use strict';
    Number.prototype.times = function(fn) {
      if (this.valueOf()) {
        for (var i = 0; i < this.valueOf(); i++) {
          fn(i);
    };
    function repeat(n, fn) {
    ...
    
  3. times(func)
    var i = 0;
    Number.prototype.times = function(func) {
      let n = Math.round(this);  
      if (n <= 0) return null;
      func();
      return (n - 1).times(func);
    console.log(i);
    
  4. times(func)
    Number.prototype.times = function (func) {
      var i;
      for (i = 0; i < this; i += 1) {
        func();
    };
    function random(min, max) {
        var floor = +min,
            ceil = +max;
    ...
    
  5. times(func, scope)
    Number.prototype.times = function(func, scope) {
      var i, v, _results;
      v = this.valueOf();
      i = 0;
      _results = [];
      while (i < v) {
        func.call(scope || window, i);
        _results.push(i++);
      return _results;
    };
    
  6. times(iterator)
    Number.prototype.times = function(iterator) {
      var index = 0;
      while(index < this) iterator(index++);
      return this
    };
    
  7. times(iterator)
    Number.prototype.times = function (iterator) {
      for (var i = 0; i < this; i++) {
        iterator(i);
    };
    
  8. times(iterator, context)
    Number.prototype.times = function(iterator, context) {
      for (var i = 0; i < this; i++) iterator.call(context, i);
    };
    Number.prototype.seconds = function() { return this * 1000; };
    Number.prototype.minutes = function() { return this * 1000 * 60; };
    Number.prototype.hours   = function() { return this * 1000 * 3600; };
    Number.prototype.days    = function() { return this * 1000 * 3600 * 24; };
    
  9. times(iterator, context)
    Number.prototype.times = function(iterator, context) {
      for(var i = 0; i < this; i++) {
        iterator.call(context, i);
      return i;
    };