Comparing version 0.4.1 to 0.5.0
@@ -19,2 +19,10 @@ 'use strict'; | ||
uuidv4.is = function (value) { | ||
if (!value) { | ||
throw new Error('Value is missing.'); | ||
} | ||
return uuidv4.regex.test(value); | ||
}; | ||
uuidv4.empty = function () { | ||
@@ -21,0 +29,0 @@ return '00000000-0000-0000-0000-000000000000'; |
@@ -22,2 +22,10 @@ 'use strict'; | ||
uuidv4.is = function (value) { | ||
if (!value) { | ||
throw new Error('Value is missing.'); | ||
} | ||
return uuidv4.regex.test(value); | ||
}; | ||
uuidv4.empty = function () { | ||
@@ -24,0 +32,0 @@ return '00000000-0000-0000-0000-000000000000'; |
{ | ||
"name": "uuidv4", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "uuid creates UUIDs.", | ||
@@ -20,5 +20,5 @@ "contributors": [ | ||
"devDependencies": { | ||
"assertthat": "0.8.3", | ||
"roboter": "0.14.6", | ||
"roboter-server": "0.14.6" | ||
"assertthat": "0.8.5", | ||
"roboter": "0.15.1", | ||
"roboter-server": "0.15.1" | ||
}, | ||
@@ -25,0 +25,0 @@ "repository": { |
@@ -26,2 +26,17 @@ # uuid | ||
### Verifying a UUID | ||
To verify whether a given value is a UUID, use the `is` function. | ||
```javascript | ||
console.log(uuid.is('75442486-0878-440c-9db1-a7006c25a39f')); | ||
// => true | ||
``` | ||
If you want to perform the verification on your own, use the `regex` property. | ||
```javascript | ||
console.log(uuid.regex); | ||
``` | ||
### Getting a UUID from a string | ||
@@ -56,3 +71,3 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2014-2016 the native web. | ||
Copyright (c) 2014-2017 the native web. | ||
@@ -59,0 +74,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
@@ -36,2 +36,21 @@ 'use strict'; | ||
suite('is', () => { | ||
test('throws an error if value is missing.', done => { | ||
assert.that(() => { | ||
uuidv4.is(); | ||
}).is.throwing('Value is missing.'); | ||
done(); | ||
}); | ||
test('returns true if a v4 UUID is given.', done => { | ||
assert.that(uuidv4.is('9afb733b-5001-4275-a099-03a1d2cca51e')).is.true(); | ||
done(); | ||
}); | ||
test('returns false if no v4 UUID is given.', done => { | ||
assert.that(uuidv4.is('definitely-not-a-uuid')).is.false(); | ||
done(); | ||
}); | ||
}); | ||
suite('fromString', () => { | ||
@@ -38,0 +57,0 @@ test('is a function.', done => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9452
182
77