From 937f8f19ffaadb657b8abf8f89fd2171db71f1c6 Mon Sep 17 00:00:00 2001 From: Jared K. Smith Date: Apr 17 2017 14:59:44 +0000 Subject: Update sources to upstream 0.3.2 release --- diff --git a/.gitignore b/.gitignore index ae8080b..bd7eed4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /array-unique-0.2.1.tgz +/array-unique-0.3.2.tgz diff --git a/sources b/sources index b422aa4..da52316 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -7b3ac4760380d655957c68e59748f438 array-unique-0.2.1.tgz +SHA512 (array-unique-0.3.2.tgz) = 4a57915a387d254b9ddb01f584fb3dad9059df71fa4fd1ce88bd2ec069c6c7d16913ac0a1b27d6ba099b904388b3aa96ad9860d0b59e2f388bac4c10261b3999 diff --git a/test.js b/test.js index 9a40ce6..2a326bd 100644 --- a/test.js +++ b/test.js @@ -7,19 +7,19 @@ 'use strict'; -/* deps:mocha */ +require('mocha'); var assert = require('assert'); var should = require('should'); var unique = require('./'); -describe('unique', function () { - it('should throw an error if the value passed is not an array:', function () { - (function () { +describe('unique', function() { + it('should throw an error if the value passed is not an array:', function() { + (function() { unique('a', 'b', 'c'); }).should.throw('array-unique expects an array.'); }); - it('should return an array with unique values:', function () { + it('should return an array with unique values:', function() { unique(['a', 'b', 'c', 'a', 'b', 'd']).should.eql(['a', 'b', 'c', 'd']); unique(['a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'b', 'f', 'a', 'b']).should.eql(['a', 'b', 'c', 'f']); unique(['a', 'b', 'c', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b']).should.eql(['a', 'b', 'c', 'f', 'x', 'y', 'z']); @@ -40,3 +40,112 @@ describe('unique', function () { }); }); +describe('unique.immutable', function() { + it('should throw an error if the value passed is not an array:', function() { + (function() { + unique.immutable('a', 'b', 'c'); + }).should.throw('array-unique expects an array.'); + }); + + it('should return an array with unique values without modifying the input:', function() { + (function() { + var original = ['a', 'b', 'c', 'a', 'b', 'd']; + var before = ['a', 'b', 'c', 'a', 'b', 'd']; + var expected = ['a', 'b', 'c', 'd']; + + unique.immutable(before).should.eql(expected); + before.should.eql(original); + })(); + + (function() { + var original = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'b', 'f', 'a', 'b']; + var before = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'b', 'f', 'a', 'b']; + var expected = ['a', 'b', 'c', 'f']; + + unique.immutable(before).should.eql(expected); + before.should.eql(original); + })(); + + (function() { + var original = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b'] + var before = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b'] + var expected = ['a', 'b', 'c', 'f', 'x', 'y', 'z']; + unique.immutable(before).should.eql(expected); + before.should.eql(original); + })(); + + (function() { + var original = [ + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/a.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/b.js', + 'foo/bar/baz/quux/fez/test/fixtures/b.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/a.js', + 'foo/bar/baz/quux/fez/test/fixtures/j.js', + 'foo/bar/baz/quux/fez/test/fixtures/z.js', + 'foo/bar/baz/quux/fez/test/fixtures/c.js', + 'foo/bar/baz/quux/fez/test/fixtures/d.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/a.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/h.js', + 'foo/bar/baz/quux/fez/test/fixtures/i.js', + 'foo/bar/baz/quux/fez/test/fixtures/j.js', + 'foo/bar/baz/quux/fez/test/fixtures/k.js', + 'foo/bar/baz/quux/fez/test/fixtures/l.js', + 'foo/bar/baz/quux/fez/test/fixtures/m.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/a.js' + ]; + var before = [ + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/a.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/b.js', + 'foo/bar/baz/quux/fez/test/fixtures/b.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/a.js', + 'foo/bar/baz/quux/fez/test/fixtures/j.js', + 'foo/bar/baz/quux/fez/test/fixtures/z.js', + 'foo/bar/baz/quux/fez/test/fixtures/c.js', + 'foo/bar/baz/quux/fez/test/fixtures/d.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/a.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/h.js', + 'foo/bar/baz/quux/fez/test/fixtures/i.js', + 'foo/bar/baz/quux/fez/test/fixtures/j.js', + 'foo/bar/baz/quux/fez/test/fixtures/k.js', + 'foo/bar/baz/quux/fez/test/fixtures/l.js', + 'foo/bar/baz/quux/fez/test/fixtures/m.js', + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/a.js' + ]; + var expected = [ + 'foo/bar/baz/quux/fez/test/fixtures', + 'foo/bar/baz/quux/fez/test/fixtures/a.js', + 'foo/bar/baz/quux/fez/test/fixtures/b.js', + 'foo/bar/baz/quux/fez/test/fixtures/j.js', + 'foo/bar/baz/quux/fez/test/fixtures/z.js', + 'foo/bar/baz/quux/fez/test/fixtures/c.js', + 'foo/bar/baz/quux/fez/test/fixtures/d.js', + 'foo/bar/baz/quux/fez/test/fixtures/h.js', + 'foo/bar/baz/quux/fez/test/fixtures/i.js', + 'foo/bar/baz/quux/fez/test/fixtures/k.js', + 'foo/bar/baz/quux/fez/test/fixtures/l.js', + 'foo/bar/baz/quux/fez/test/fixtures/m.js' + ]; + + unique.immutable(before).should.eql(expected); + before.should.eql(original); + })(); + }); +});