All Downloads are FREE. Search and download functionalities are using the official Maven repository.

www.js.plugins.arrayExtensions.js Maven / Gradle / Ivy

// Generated by CoffeeScript 1.5.0
(function() {

  if (!Array.prototype.filter) {
    Array.prototype.filter = function(callback) {
      var element, _i, _len, _results;
      _results = [];
      for (_i = 0, _len = this.length; _i < _len; _i++) {
        element = this[_i];
        if (callback(element)) {
          _results.push(element);
        }
      }
      return _results;
    };
  }

  if (!Array.prototype.sum) {
    Array.prototype.sum = function() {
      var i, result, _i, _ref;
      result = 0;
      for (i = _i = 0, _ref = this.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
        result += this[i];
      }
      return result;
    };
  }

  if (!Array.prototype.swap) {
    Array.prototype.swap = function(idxA, idxB) {
      var itemA;
      itemA = this[idxA];
      this[idxA] = this[idxB];
      return this[idxB] = itemA;
    };
  }

  if (!Array.prototype.move) {
    Array.prototype.move = function(fromIdx, toIdx) {
      return this.splice(toIdx, 0, this.splice(fromIdx, 1)[0]);
    };
  }

}).call(this);




© 2015 - 2025 Weber Informatics LLC | Privacy Policy