Comparing version 5.0.1 to 6.0.0
@@ -1,11 +0,9 @@ | ||
declare const uuidv4: { | ||
(): string; | ||
regex: { | ||
v4: RegExp; | ||
v5: RegExp; | ||
}; | ||
is(value: string): boolean; | ||
empty(): string; | ||
fromString(text: string): string; | ||
declare const uuidv4: () => string; | ||
declare const regex: { | ||
v4: RegExp; | ||
v5: RegExp; | ||
}; | ||
export default uuidv4; | ||
declare const isUuid: (value: string) => boolean; | ||
declare const empty: () => string; | ||
declare const fromString: (text: string) => string; | ||
export { uuidv4 as uuid, regex, isUuid, empty, fromString }; |
@@ -11,13 +11,17 @@ "use strict"; | ||
}; | ||
uuidv4.regex = { | ||
exports.uuid = uuidv4; | ||
const regex = { | ||
v4: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u, | ||
v5: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-5[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u | ||
}; | ||
uuidv4.is = function (value) { | ||
return uuidv4.regex.v4.test(value) || uuidv4.regex.v5.test(value); | ||
exports.regex = regex; | ||
const isUuid = function (value) { | ||
return regex.v4.test(value) || regex.v5.test(value); | ||
}; | ||
uuidv4.empty = function () { | ||
exports.isUuid = isUuid; | ||
const empty = function () { | ||
return '00000000-0000-0000-0000-000000000000'; | ||
}; | ||
uuidv4.fromString = function (text) { | ||
exports.empty = empty; | ||
const fromString = function (text) { | ||
const namespace = 'bb5d0ffa-9a4c-4d7c-8fc2-0a7d2220ba45'; | ||
@@ -27,2 +31,2 @@ const uuidFromString = v5_1.default(text, namespace); | ||
}; | ||
exports.default = uuidv4; | ||
exports.fromString = fromString; |
@@ -8,3 +8,3 @@ import v4 from 'uuid/v4'; | ||
uuidv4.regex = { | ||
const regex = { | ||
v4: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u, | ||
@@ -14,11 +14,11 @@ v5: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-5[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u | ||
uuidv4.is = function (value: string): boolean { | ||
return uuidv4.regex.v4.test(value) || uuidv4.regex.v5.test(value); | ||
const isUuid = function (value: string): boolean { | ||
return regex.v4.test(value) || regex.v5.test(value); | ||
}; | ||
uuidv4.empty = function (): string { | ||
const empty = function (): string { | ||
return '00000000-0000-0000-0000-000000000000'; | ||
}; | ||
uuidv4.fromString = function (text: string): string { | ||
const fromString = function (text: string): string { | ||
const namespace = 'bb5d0ffa-9a4c-4d7c-8fc2-0a7d2220ba45'; | ||
@@ -31,2 +31,8 @@ | ||
export default uuidv4; | ||
export { | ||
uuidv4 as uuid, | ||
regex, | ||
isUuid, | ||
empty, | ||
fromString | ||
}; |
{ | ||
"name": "uuidv4", | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"description": "uuid creates UUIDs.", | ||
@@ -33,5 +33,5 @@ "contributors": [ | ||
"devDependencies": { | ||
"@types/uuid": "3.4.5", | ||
"assertthat": "4.0.1", | ||
"roboter": "7.1.5" | ||
"@types/uuid": "3.4.6", | ||
"assertthat": "5.0.1", | ||
"roboter": "9.2.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "repository": { |
@@ -26,3 +26,3 @@ # uuid | ||
```javascript | ||
const uuid = require('uuidv4').default; | ||
const { uuid } = require('uuidv4'); | ||
``` | ||
@@ -33,3 +33,3 @@ | ||
```typescript | ||
import uuid from 'uuidv4'; | ||
import { uuid } from 'uuidv4'; | ||
``` | ||
@@ -46,10 +46,12 @@ | ||
To verify whether a given value is a UUID, use the `is` function: | ||
To verify whether a given value is a UUID, use the `isUuid` function: | ||
```javascript | ||
console.log(uuid.is('75442486-0878-440c-9db1-a7006c25a39f')); | ||
import { isUuid } from 'uuidv4'; | ||
console.log(isUuid('75442486-0878-440c-9db1-a7006c25a39f')); | ||
// => true | ||
``` | ||
_Please note that the `is` function returns `true` for both, `v4` and `v5` UUIDs. In addition, `is` returns `true` for `uuid.empty()`._ | ||
_Please note that the `isUuid` function returns `true` for both, `v4` and `v5` UUIDs. In addition, `isUuid` returns `true` for `empty()`._ | ||
@@ -59,7 +61,9 @@ If you want to perform the verification on your own, use the `regex` property, and access its `v4` or `v5` property, depending on what you need: | ||
```javascript | ||
console.log(uuid.regex.v4); | ||
console.log(uuid.regex.v5); | ||
import { regex } from 'uuidv4'; | ||
console.log(regex.v4); | ||
console.log(regex.v5); | ||
``` | ||
_Please note that the regular expressions also consider `uuid.empty()` to be a valid UUID._ | ||
_Please note that the regular expressions also consider `empty()` to be a valid UUID._ | ||
@@ -71,3 +75,5 @@ ### Getting a UUID from a string | ||
```javascript | ||
console.log(uuid.fromString('the native web')); | ||
import { fromString } from 'uuidv4'; | ||
console.log(fromString('the native web')); | ||
// => 'cdb63720-9628-5ef6-bbca-2e5ce6094f3c' | ||
@@ -81,3 +87,5 @@ ``` | ||
```javascript | ||
console.log(uuid.empty()); | ||
import { empty } from 'uuidv4'; | ||
console.log(empty()); | ||
// => '00000000-0000-0000-0000-000000000000' | ||
@@ -84,0 +92,0 @@ ``` |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7547
82
95
0