Nodejs Array Unique uniqueNonEmpty()

Here you can find the source of uniqueNonEmpty()

Method Source Code

Array.prototype.uniqueNonEmpty = function () {
   //from  w w w. j  a v  a2  s .c  om
   var noempties = true;
   var hash = {};
   for (var i=0 ; i<this.length ; i++) {
      if (!this[i] || this[i]=="") {
         noempties = false;
      } else {
         hash[this[i]] = "1";
      }
   }
   var hashlength=0;
   for (i in hash) {hashlength++};
   return (this.length===hashlength && noempties);
}

Related

  1. unique5()
    Array.prototype.unique5 = function() {
        var res = [], hash = {};
        for(var i=0, elem; (elem = this[i]) != null; i++)  {
            if (!hash[elem])
                res.push(elem);
                hash[elem] = true;
        return res;
    
  2. uniqueArray_unique()
    "use strict";
    Array.prototype.unique = function Array_unique() {
        var unique = [];
        for (var i = 0; i < this.length; i++) {
            if (unique.indexOf(this[i]) === -1) {
                unique.push(this[i]);
        return unique;
    ...
    
  3. uniqueByKey(array, key)
    function getGmtOffset() {
      var d = new Date();
      var gmtOffset = d.getTimezoneOffset() * 60;  
      return gmtOffset;
    function getUnixTime(strDate) {
      var d = new Date(strDate);
      var unixTime = (d.getTime() / 1000);
      return unixTime;
    ...
    
  4. uniqueCounter()
    Array.prototype.uniqueCounter = function () {
        "use strict";
      var counter = 0, l = this.length, i, j;
        for (i = 0; i < l; i += 1) {
        for (j = i + 1; j < l; j += 1) {
          if (this[i] === this[j]) {
            j = i =+ 1;
        counter += 1;
        return counter;
    };
    
  5. uniqueDates()
    Array.prototype.uniqueDates = function() {
      var u = [];
      for (k=0; k<this.length; k++) {
        var currentDate = new Date(this[k].annum);
        if (u.map(Number).indexOf(+currentDate) < 0) {
          u.push(currentDate);
      return u;
    ...
    
  6. uniqueObjects(props)
    Array.prototype.uniqueObjects = function (props) {
        function compare(a, b) {
            var prop;
            if (props) {
                for (var j = 0; j < props.length; j++) {
                    prop = props[j];
                    if (a[prop] != b[prop]) {
                        return false;
            } else {
                for (prop in a) {
                    if (a[prop] != b[prop]) {
                        return false;
            return true;
        return this.filter(function (item, index, list) {
            for (var i = 0; i < index; i++) {
                if (compare(item, list[i])) {
                    return false;
            return true;
        });
    };
    
  7. uniquelize()
    Array.prototype.uniquelize = function() {
      var array = new Array();
      var length = this.length;
      for (var i = 0; i < length; i++) {
        if (!array.inArray(this[i])) {
          array.push(this[i]);
      return array;
    ...
    
  8. uniquelize()
    Array.prototype.uniquelize = function(){
         var ra = new Array();
         for(var i = 0; i < this.length; i ++){
             if(!ra.contains(this[i])){
                ra.push(this[i]);
         return ra;
    };
    ...
    
  9. uniquelize()
    Array.prototype.uniquelize = function () {
        var tmp = {},
            ret = [];
        for (var i = 0, j = this.length; i < j; i++) {
            if (!tmp[this[i]]) {
                tmp[this[i]] = 1;
                ret.push(this[i]);
        return ret;