How to use array-uniq - 9 common examples

To help you get started, we’ve selected a few array-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 flow-typed / flow-typed / definitions / npm / array-uniq_v1.x.x / test_array-uniq_v1.x.x.js View on Github external
import arrayUniq from 'array-uniq';

const a: Array = arrayUniq([1, 1, 2, 3, 3]);
//=> [1, 2, 3]

const b: Array = arrayUniq(['foo', 'foo', 'bar', 'foo']);
//=> ['foo', 'bar']

// $ExpectError
const c: Array = arrayUniq([1, 2, 3]);
github flow-typed / flow-typed / definitions / npm / array-uniq_v1.x.x / test_array-uniq_v1.x.x.js View on Github external
import arrayUniq from 'array-uniq';

const a: Array = arrayUniq([1, 1, 2, 3, 3]);
//=> [1, 2, 3]

const b: Array = arrayUniq(['foo', 'foo', 'bar', 'foo']);
//=> ['foo', 'bar']

// $ExpectError
const c: Array = arrayUniq([1, 2, 3]);
github sindresorhus / pageres / lib / index.js View on Github external
await Promise.all(this.src().map(src => { // eslint-disable-line array-callback-return
			const options = {...this.options, ...src.options};
			const sizes = arrayUniq(src.sizes.filter(/./.test, /^\d{2,4}x\d{2,4}$/i));
			const keywords = arrayDiffer(src.sizes, sizes);

			if (!src.url) {
				throw new Error('URL required');
			}

			this.urls.push(src.url);

			if (sizes.length === 0 && keywords.indexOf('w3counter') !== -1) {
				return this.resolution(src.url, options);
			}

			if (keywords.length > 0) {
				return this.viewport({url: src.url, sizes, keywords}, options);
			}
github Vestride / Shuffle / src / shuffle.es6.js View on Github external
remove(collection) {
    collection = arrayUnique(collection);

    let items = collection
      .map(element => this.getItemByElement(element))
      .filter(item => !!item);

    if (!collection.length) {
      return;
    }

    let handleLayout = () => {
      this.element.removeEventListener(Shuffle.EventType.LAYOUT, handleLayout);
      this._disposeItems(items);

      // Remove the collection in the callback
      collection.forEach((element) => {
        element.parentNode.removeChild(element);
github sindresorhus / pageres / lib / index.js View on Github external
if (sizes.length === 0 && keywords.indexOf('w3counter') !== -1) {
				return this.resolution(src.url, options);
			}

			if (keywords.length > 0) {
				return this.viewport({url: src.url, sizes, keywords}, options);
			}

			for (const size of sizes) {
				this.sizes.push(size);
				this.items.push(this.create(src.url, size, options));
			}
		}));

		this.stats.urls = arrayUniq(this.urls).length;
		this.stats.sizes = arrayUniq(this.sizes).length;
		this.stats.screenshots = this.items.length;

		if (!this.dest()) {
			return this.items;
		}

		await this.save(this.items);

		return this.items;
	}
github sindresorhus / pageres / lib / index.js View on Github external
if (sizes.length === 0 && keywords.indexOf('w3counter') !== -1) {
				return this.resolution(src.url, options);
			}

			if (keywords.length > 0) {
				return this.viewport({url: src.url, sizes, keywords}, options);
			}

			for (const size of sizes) {
				this.sizes.push(size);
				this.items.push(this.create(src.url, size, options));
			}
		}));

		this.stats.urls = arrayUniq(this.urls).length;
		this.stats.sizes = arrayUniq(this.sizes).length;
		this.stats.screenshots = this.items.length;

		if (!this.dest()) {
			return this.items;
		}

		await this.save(this.items);

		return this.items;
	}
github viewstools / morph / morph / react-dom / properties-style.js View on Github external
let getUniqueNames = node => {
  let names = [
    ...new Set(getAllAnimatedProps(node, false).map(prop => prop.name)),
  ]
  return uniq(names.map(name => ensurePropName(name))).join(', ')
}
github sindresorhus / pageres / lib / index.js View on Github external
async viewport(obj: Viewport, options: Options) {
		for (const item of await viewportListMem(obj.keywords)) {
			this.sizes.push(item.size);
			obj.sizes.push(item.size);
		}

		for (const size of arrayUniq(obj.sizes)) {
			this.items.push(this.create(obj.url, size, options));
		}
	}
github finnfiddle / potion / src / mixins / AnimatedElement.js View on Github external
constructor(props) {
    super(props);
    this.displayName = 'AnimatedElement';
    this.attrNames = this.getAttrNames();
    this.derivedAttrNames = this.getDerivedAttrNames();
    this.derivedAttrDefaults = this.getDerivedAttrDefaults();
    this.derivedAttrInputNames = this.getDerivedAttrInputNames();
    this.privatePropNames = this.getPrivatePropNames().concat(PRIVATE_PROP_NAMES);
    this.allAttrInputNames = this.attrNames.concat(
      Object.keys(this.derivedAttrInputNames).reduce((acc, key) =>
        acc.concat(this.derivedAttrInputNames[key])
      , [])
    );
    this.allDerivedAttrInputNames = uniq(
      Object.keys(this.derivedAttrInputNames)
        .reduce((acc, key) =>
          acc.concat(this.derivedAttrInputNames[key])
        , [])
    );
    this.propsToCheckForChanges = ['datum'].concat(this.props.propsToCheckForChanges);
    this.attrs = this.getAttrs(this.props);
    this.state = this.getState();
  }

array-uniq

Create an array without duplicates

MIT
Latest version published 4 years ago

Package Health Score

70 / 100
Full package analysis

Popular array-uniq functions