Nodejs Array Push Unique pushUniquely(e)

Here you can find the source of pushUniquely(e)

Method Source Code

Array.prototype.pushUniquely = function(e){
  for(var i=0;i<this.length;i++){
    var ae = this[i];
    if(ae instanceof Array && e instanceof Array){
      if(ae.isEqual(e)) return i;
    }else{/*from  ww  w .j  a v  a2s  .  c o  m*/
      if(ae==e) return i;
    }
  }
  return this.push(e)-1;
}

Related

  1. pushUnique(item,unique)
    Array.prototype.pushUnique = function(item,unique)
      if(unique === false) {
        this.push(item);
      } else {
        if(this.indexOf(item) == -1)
          this.push(item);
    };
    ...
    
  2. pushUnique(k, v)
    Array.prototype.pushUnique = function(k, v) {
      exist = false;
      for(var i = 0; i < this.length; i++) {
        if (this[i][k] == v) return this[i];
      if (!exist) {
        obj = {};
        obj[k] = v;
        this.push(obj);
    ...
    
  3. pushUnique(obj)
    Array.prototype.pushUnique=function(obj){
      if(this.containsObject(obj)){
        return;
      this.push(obj);
    
  4. pushUnique(obj, equalityFunction)
    Array.prototype.pushUnique = function (obj, equalityFunction) {
      equalityFunction  = (typeof equalityFunction === "undefined") ? function(a, b) { return a === b } : equalityFunction;
      for(var n = 0; n < this.length; n++) {
        if(equalityFunction(this[n], obj)) { 
          return false;
      this.push(obj);
      return true;
    ...
    
  5. pushUnique(value)
    Array.prototype.pushUnique = function(value) {
        if (this.include(value)) return this;
        this.push(value);
        return this;
    Array.prototype.concatUnique = function(arr) {
        for (index in arr) {
            if (typeof arr[index] != "function") this.pushUnique(arr[index]);
        return this;
    
  6. pushReplace(pattern)
    Array.prototype.pushReplace = function(pattern){
      var args = Array.prototype.slice.call(arguments, 1);
      this.push(pattern.replace(/\{(\d+)\}/g, function(pattern, index){
        return args[index].toString();
      }));
      return this;
    };
    
  7. push_unique(value)
    Array.prototype.push_unique = function (value) {
      if (!this.in_array(value)) {
          this.push(value);
    };