assert-unique

1.0.0 • Public • Published

assert-unique

Build Status Build status Coverage Status Dependency Status devDependency Status

Test if values have no duplication

assertUnique(3, 'a', 3, 3, true, 'a'); // Error: 3 and "a" are duplicated. 

Installation

Package managers

npm NPM version

npm install assert-unique

bower Bower version

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.

Package Sidebar

Install

npm i assert-unique

Weekly Downloads

9

Version

1.0.0

License

none

Last publish

Collaborators

  • shinnn