Comparing version 1.0.0 to 1.0.1
{ | ||
"extends": "eslint-config-es/2015/server" | ||
"extends": "es/2015/server" | ||
} |
'use strict'; | ||
var sha1 = require('sha-1'); | ||
var sha1 = require('sha-1'), | ||
uuid = require('uuid/v4'); | ||
// See http://stackoverflow.com/a/2117523/1333873 for details. | ||
var uuidv4 = function uuidv4() { | ||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (character) { | ||
/* eslint-disable no-bitwise */ | ||
var randomNumber = Math.random() * 16 | 0, | ||
result = character === 'x' ? randomNumber : randomNumber & 0x3 | 0x8; | ||
/* eslint-enable no-bitwise */ | ||
return result.toString(16); | ||
}); | ||
return uuid(); | ||
}; | ||
@@ -37,7 +30,7 @@ | ||
var hash = sha1(text), | ||
uuid = hash.substring(0, 8) + '-' + hash.substring(8, 12) + '-4' + hash.substring(13, 16) + '-8' + hash.substring(17, 20) + '-' + hash.substring(20, 32); | ||
uuidFromString = hash.substring(0, 8) + '-' + hash.substring(8, 12) + '-4' + hash.substring(13, 16) + '-8' + hash.substring(17, 20) + '-' + hash.substring(20, 32); | ||
return uuid; | ||
return uuidFromString; | ||
}; | ||
module.exports = uuidv4; |
{ | ||
"name": "uuidv4", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "uuid creates UUIDs.", | ||
@@ -21,8 +21,8 @@ "contributors": [ | ||
"dependencies": { | ||
"sha-1": "0.1.1" | ||
"sha-1": "0.1.1", | ||
"uuid": "3.2.1" | ||
}, | ||
"devDependencies": { | ||
"assertthat": "1.0.0", | ||
"roboter": "0.15.6", | ||
"roboter-server": "0.15.6" | ||
"roboter": "1.0.4" | ||
}, | ||
@@ -29,0 +29,0 @@ "repository": { |
@@ -64,3 +64,3 @@ # uuid | ||
```shell | ||
$ bot | ||
$ npx roboter | ||
``` | ||
@@ -67,0 +67,0 @@ |
@@ -5,11 +5,10 @@ 'use strict'; | ||
const uuidv4 = require('../../lib/uuidv4'); | ||
const uuidv4 = require('../../src/uuidv4'); | ||
suite('uuidv4', () => { | ||
test('is a function', done => { | ||
test('is a function', async () => { | ||
assert.that(uuidv4).is.ofType('function'); | ||
done(); | ||
}); | ||
test('returns a v4 UUID.', done => { | ||
test('returns a v4 UUID.', async () => { | ||
const uuid = uuidv4(); | ||
@@ -19,6 +18,5 @@ | ||
assert.that(uuidv4.regex.test(uuid)).is.true(); | ||
done(); | ||
}); | ||
test('returns a different v4 UUID on each call.', done => { | ||
test('returns a different v4 UUID on each call.', async () => { | ||
const uuid = uuidv4(), | ||
@@ -28,9 +26,7 @@ uuidOther = uuidv4(); | ||
assert.that(uuid).is.not.equalTo(uuidOther); | ||
done(); | ||
}); | ||
suite('regex', () => { | ||
test('is a regular expression that describes a v4 UUID.', done => { | ||
test('is a regular expression that describes a v4 UUID.', async () => { | ||
assert.that(uuidv4.regex).is.equalTo(/[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/); | ||
done(); | ||
}); | ||
@@ -40,17 +36,14 @@ }); | ||
suite('is', () => { | ||
test('throws an error if value is missing.', done => { | ||
test('throws an error if value is missing.', async () => { | ||
assert.that(() => { | ||
uuidv4.is(); | ||
}).is.throwing('Value is missing.'); | ||
done(); | ||
}); | ||
test('returns true if a v4 UUID is given.', done => { | ||
test('returns true if a v4 UUID is given.', async () => { | ||
assert.that(uuidv4.is('9afb733b-5001-4275-a099-03a1d2cca51e')).is.true(); | ||
done(); | ||
}); | ||
test('returns false if no v4 UUID is given.', done => { | ||
test('returns false if no v4 UUID is given.', async () => { | ||
assert.that(uuidv4.is('definitely-not-a-uuid')).is.false(); | ||
done(); | ||
}); | ||
@@ -60,15 +53,13 @@ }); | ||
suite('fromString', () => { | ||
test('is a function.', done => { | ||
test('is a function.', async () => { | ||
assert.that(uuidv4.fromString).is.ofType('function'); | ||
done(); | ||
}); | ||
test('throws an error if no text is given.', done => { | ||
test('throws an error if no text is given.', async () => { | ||
assert.that(() => { | ||
uuidv4.fromString(); | ||
}).is.throwing('Text is missing.'); | ||
done(); | ||
}); | ||
test('returns a v4 UUID that is derived from the SHA1 of the given text.', done => { | ||
test('returns a v4 UUID that is derived from the SHA1 of the given text.', async () => { | ||
const uuid = uuidv4.fromString('the native web'); | ||
@@ -78,3 +69,2 @@ | ||
assert.that(uuidv4.regex.test(uuid)).is.true(); | ||
done(); | ||
}); | ||
@@ -84,12 +74,10 @@ }); | ||
suite('empty', () => { | ||
test('is a function.', done => { | ||
test('is a function.', async () => { | ||
assert.that(uuidv4.empty).is.ofType('function'); | ||
done(); | ||
}); | ||
test('returns 00000000-0000-0000-0000-000000000000.', done => { | ||
test('returns 00000000-0000-0000-0000-000000000000.', async () => { | ||
assert.that(uuidv4.empty()).is.equalTo('00000000-0000-0000-0000-000000000000'); | ||
done(); | ||
}); | ||
}); | ||
}); |
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
2
0
6927
2
6
111
+ Addeduuid@3.2.1
+ Addeduuid@3.2.1(transitive)