Test if values have no duplication
assertUnique(3, 'a', 3, 3, true, 'a'); // Error: 3 and "a" are duplicated.
npm install assert-unique
bower install assert-unique
var assertUnique = require('shinnn/assert-unique');
Directly download the script file and its dependencies.
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
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT License.