CasperSecurity

Current Path : /var/www/hrms.uiet.co.in/node_modules/collect.js/src/methods/
Upload File :
Current File : /var/www/hrms.uiet.co.in/node_modules/collect.js/src/methods/unique.js

'use strict';

const { isFunction } = require('../helpers/is');

module.exports = function unique(key) {
  let collection;

  if (key === undefined) {
    collection = this.items
      .filter((element, index, self) => self.indexOf(element) === index);
  } else {
    collection = [];

    const usedKeys = [];

    for (let iterator = 0, { length } = this.items;
      iterator < length; iterator += 1) {
      let uniqueKey;
      if (isFunction(key)) {
        uniqueKey = key(this.items[iterator]);
      } else {
        uniqueKey = this.items[iterator][key];
      }

      if (usedKeys.indexOf(uniqueKey) === -1) {
        collection.push(this.items[iterator]);
        usedKeys.push(uniqueKey);
      }
    }
  }

  return new this.constructor(collection);
};
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY