diff --git a/snippets/distinctValuesOfArray.md b/snippets/distinctValuesOfArray.md deleted file mode 100644 index 652c1f458..000000000 --- a/snippets/distinctValuesOfArray.md +++ /dev/null @@ -1,13 +0,0 @@ -### distinctValuesOfArray - -Returns all the distinct values of an array. - -Use ES6 `Set` and the `...rest` operator to discard all duplicated values. - -```js -const distinctValuesOfArray = arr => [...new Set(arr)]; -``` - -```js -distinctValuesOfArray([1, 2, 2, 3, 4, 4, 5]); // [1,2,3,4,5] -``` diff --git a/snippets/uniqueElements.md b/snippets/uniqueElements.md new file mode 100644 index 000000000..59648c06a --- /dev/null +++ b/snippets/uniqueElements.md @@ -0,0 +1,13 @@ +### uniqueElements + +Returns all unique values of an array. + +Use ES6 `Set` and the `...rest` operator to discard all duplicated values. + +```js +const uniqueElements = arr => [...new Set(arr)]; +``` + +```js +uniqueElements([1, 2, 2, 3, 4, 4, 5]); // [1,2,3,4,5] +``` diff --git a/tag_database b/tag_database index 84a3b4dfa..c0b80e5cb 100644 --- a/tag_database +++ b/tag_database @@ -33,7 +33,6 @@ difference:array,math differenceWith:array,function digitize:math,array distance:math -distinctValuesOfArray:array dropElements:array,function dropRight:array elementIsVisibleInViewport:browser @@ -203,6 +202,7 @@ truncateString:string truthCheckCollection:object,logic,array unescapeHTML:string,browser union:array,math +uniqueElements:array untildify:node,string URLJoin:string,utility,regexp UUIDGeneratorBrowser:browser,utility,random diff --git a/test/distinctValuesOfArray/distinctValuesOfArray.js b/test/distinctValuesOfArray/distinctValuesOfArray.js deleted file mode 100644 index d5b18bd39..000000000 --- a/test/distinctValuesOfArray/distinctValuesOfArray.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = distinctValuesOfArray = arr => [...new Set(arr)]; \ No newline at end of file diff --git a/test/distinctValuesOfArray/distinctValuesOfArray.test.js b/test/distinctValuesOfArray/distinctValuesOfArray.test.js deleted file mode 100644 index 43da61c80..000000000 --- a/test/distinctValuesOfArray/distinctValuesOfArray.test.js +++ /dev/null @@ -1,14 +0,0 @@ -const test = require('tape'); -const distinctValuesOfArray = require('./distinctValuesOfArray.js'); - -test('Testing distinctValuesOfArray', (t) => { - //For more information on all the methods supported by tape - //Please go to https://github.com/substack/tape - t.true(typeof distinctValuesOfArray === 'function', 'distinctValuesOfArray is a Function'); - t.deepEqual(distinctValuesOfArray([1, 2, 2, 3, 4, 4, 5]), [1,2,3,4,5], "Returns all the distinct values of an array"); - //t.deepEqual(distinctValuesOfArray(args..), 'Expected'); - //t.equal(distinctValuesOfArray(args..), 'Expected'); - //t.false(distinctValuesOfArray(args..), 'Expected'); - //t.throws(distinctValuesOfArray(args..), 'Expected'); - t.end(); -}); \ No newline at end of file diff --git a/test/uniqueElements/uniqueElements.js b/test/uniqueElements/uniqueElements.js new file mode 100644 index 000000000..3ef175c0b --- /dev/null +++ b/test/uniqueElements/uniqueElements.js @@ -0,0 +1 @@ +module.exports = uniqueElements = arr => [...new Set(arr)]; \ No newline at end of file diff --git a/test/uniqueElements/uniqueElements.test.js b/test/uniqueElements/uniqueElements.test.js new file mode 100644 index 000000000..d2e30f925 --- /dev/null +++ b/test/uniqueElements/uniqueElements.test.js @@ -0,0 +1,14 @@ +const test = require('tape'); +const uniqueElements = require('./uniqueElements.js'); + +test('Testing uniqueElements', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof uniqueElements === 'function', 'uniqueElements is a Function'); + t.deepEqual(uniqueElements([1, 2, 2, 3, 4, 4, 5]), [1,2,3,4,5], "Returns all unique values of an array"); + //t.deepEqual(uniqueElements(args..), 'Expected'); + //t.equal(uniqueElements(args..), 'Expected'); + //t.false(uniqueElements(args..), 'Expected'); + //t.throws(uniqueElements(args..), 'Expected'); + t.end(); +}); \ No newline at end of file