Giter Club home page Giter Club logo

arr-union's Introduction

arr-union NPM version Build Status

Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.

This library is 20-30 times faster and more performant (scales better) than array-union, which just uses [].concat.apply([], arguments).

Benchmarks

See the benchmarks.

#1: five-arrays
  array-union x 243,091 ops/sec ±0.43% (100 runs sampled)
  arr-union x 7,141,833 ops/sec ±0.33% (101 runs sampled)

#2: ten-arrays
  array-union x 118,600 ops/sec ±0.38% (99 runs sampled)
  arr-union x 2,112,268 ops/sec ±0.36% (98 runs sampled)

#3: two-arrays
  array-union x 318,757 ops/sec ±0.39% (99 runs sampled)
  arr-union x 10,145,772 ops/sec ±0.23% (100 runs sampled)

Install

Install with npm

$ npm i arr-union --save

Usage

var union = require('arr-union');

union(['a'], ['b', 'c'], ['d', 'e', 'f']);
//=> ['a', 'b', 'c', 'd', 'e', 'f']

Returns only unique elements:

union(['a', 'a'], ['b', 'c']);
//=> ['a', 'b', 'c']

Other array utilities

  • arr-diff: Returns an array with only the unique values from the first array, by excluding all… more
  • arr-flatten: Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
  • arr-filter: Faster alternative to javascript's native filter method.
  • arr-map: Faster, node.js focused alternative to JavaScript's native array map.
  • arr-pluck: Retrieves the value of a specified property from all elements in the collection.
  • arr-reduce: Fast array reduce that also loops over sparse elements.
  • array-unique: Return an array free of duplicate values. Fastest ES5 implementation.

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on July 04, 2015.

arr-union's People

Contributors

jonschlinkert avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.