assert-unique
v1.0.0
Published
Test if values have no duplication
Downloads
35
Maintainers
Readme
assert-unique
Test if values have no duplication
assertUnique(3, 'a', 3, 3, true, 'a'); // Error: 3 and "a" are duplicated.
Installation
Package managers
npm
npm install assert-unique
bower
bower install assert-unique
Duo
var assertUnique = require('shinnn/assert-unique');
Standalone
Directly download the script file and its dependencies.
Dependencies
API
assertUnique([val0, val1, val2, ...])
val0, val1, val2, ...: any types
It throws an error when the arguments include duplicated values. Otherwise it doesn't throw any errors.
assertUnique(1, '1',); // doesn't throw error
assertUnique(); // doesn't throw error
assertUnique('h', 'e', 'l', 'l', 'o'); // Error: "l" is duplicated.
assertUnique(parseInt, parseInt); // Error: [Function: parseInt] is duplicated.
Note that it doesn't check deep equality.
var obj = {};
assertUnique(obj, obj); // Error: {} is duplicated.
assertUnique({}, {}); // doesn't throw error
License
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT License.