How to use uniq - 6 common examples

To help you get started, we’ve selected a few uniq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github postcss / postcss-selector-parser / src / parser.js View on Github external
let next = this.nextToken;
                if (next && next[TOKEN.TYPE] === tokens.space) {
                    word += this.requiredSpace(this.content(next));
                    this.position ++;
                }
            }
            nextToken = this.nextToken;
        }
        const hasClass = indexesOf(word, '.').filter(i => word[i - 1] !== '\\');
        let hasId = indexesOf(word, '#').filter(i => word[i - 1] !== '\\');
        // Eliminate Sass interpolations from the list of id indexes
        const interpolations = indexesOf(word, '#{');
        if (interpolations.length) {
            hasId = hasId.filter(hashIndex => !~interpolations.indexOf(hashIndex));
        }
        let indices = sortAsc(uniq([0, ...hasClass, ...hasId]));
        indices.forEach((ind, i) => {
            const index = indices[i + 1] || word.length;
            const value = word.slice(ind, index);
            if (i === 0 && firstCallback) {
                return firstCallback.call(this, value, indices.length);
            }
            let node;
            const current = this.currToken;
            const sourceIndex = current[TOKEN.START_POS] + indices[i];
            const source = getSource(
                current[1],
                current[2] + ind,
                current[3],
                current[2] + (index - 1)
            );
            if (~hasClass.indexOf(ind)) {
github flux-capacitor / flux-capacitor / packages / flux-capacitor-cli / src / commands / init.js View on Github external
async function assertFilesCanBeCopied (destPath, filePaths) {
  const topLevelFileDirNames = uniq(filePaths
    .map((filePath) => filePath.split(path.sep).shift())
  )

  await Promise.all(
    topLevelFileDirNames
      .map((fileName) => path.join(destPath, fileName))
      .map((filePath) => assertExistsNot(filePath))
  )
}
github kristianmandrup / schema-to-yup / src / types / mixed / mixed.js View on Github external
get $typeExtends() {
    if (!Array.isArray(this.typeConfig.extends)) return;
    return uniq([...this.typeConfig.extends, ...this.typeEnabled]);
  }
github w3reality / three-geo / src / index.js View on Github external
static getEleList(geojson) {
        return uniq(geojson.features.map(feat => feat.properties.ele))
            .sort((a, b) => a - b);
    }
    static addBottomEle(geojson, bottomTiles, eleList) {
github w3reality / three-laser-pointer / examples / demo-path / src / index.js View on Github external
const getEleList = (geojson) => {
        let mapper = (feature) => { return feature.properties.ele; };
        return uniq(geojson.features.map(mapper))
            .sort((a,b) => { return a-b; });
    };
    const addBottomEle = (geojson, bottomTiles, eleList) => {
github jsonmvc / jsonmvc / packages / jsonmvc-datastore / src / fn / pathTriggers.js View on Github external
if (x.search(reg) !== -1) {
      trigger.push(db.updates.triggers[x])
    }
  })

  let dep = db.dynamic.inverseDeps[path]

  if (dep) {
    trigger = trigger.concat(dep)
  }

  trigger = flatten(trigger)

  trigger.push(path)

  trigger = uniq(trigger)

  return trigger
}

uniq

Removes duplicates from a sorted array in place

MIT
Latest version published 10 years ago

Package Health Score

67 / 100
Full package analysis

Popular uniq functions