angular2-uuid
Advanced tools
Comparing version 1.0.2 to 1.0.4
78
index.js
@@ -1,46 +0,38 @@ | ||
(function (factory) { | ||
if (typeof module === 'object' && typeof module.exports === 'object') { | ||
var v = factory(require, exports); if (v !== undefined) module.exports = v; | ||
/*jshint bitwise: false*/ | ||
"use strict"; | ||
var UUID = (function () { | ||
function UUID() { | ||
// no-op | ||
} | ||
else if (typeof define === 'function' && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
/*jshint bitwise: false*/ | ||
"use strict"; | ||
var UUID = (function () { | ||
function UUID() { | ||
// no-op | ||
UUID.UUID = function () { | ||
if (typeof (window.crypto) !== "undefined" && typeof (window.crypto.getRandomValues) !== "undefined") { | ||
// If we have a cryptographically secure PRNG, use that | ||
// http://stackoverflow.com/questions/6906916/collisions-when-generating-uuids-in-javascript | ||
var buf = new Uint16Array(8); | ||
window.crypto.getRandomValues(buf); | ||
var S4 = function (num) { | ||
var ret = num.toString(16); | ||
while (ret.length < 4) { | ||
ret = "0" + ret; | ||
} | ||
return ret; | ||
}; | ||
return (S4(buf[0]) + S4(buf[1]) + "-" + S4(buf[2]) + "-" + S4(buf[3]) + "-" + S4(buf[4]) + "-" + S4(buf[5]) + S4(buf[6]) + S4(buf[7])); | ||
} | ||
UUID.UUID = function () { | ||
if (typeof (window.crypto) !== "undefined" && typeof (window.crypto.getRandomValues) !== "undefined") { | ||
// If we have a cryptographically secure PRNG, use that | ||
// http://stackoverflow.com/questions/6906916/collisions-when-generating-uuids-in-javascript | ||
var buf = new Uint16Array(8); | ||
window.crypto.getRandomValues(buf); | ||
var S4 = function (num) { | ||
var ret = num.toString(16); | ||
while (ret.length < 4) { | ||
ret = "0" + ret; | ||
} | ||
return ret; | ||
}; | ||
return (S4(buf[0]) + S4(buf[1]) + "-" + S4(buf[2]) + "-" + S4(buf[3]) + "-" + S4(buf[4]) + "-" + S4(buf[5]) + S4(buf[6]) + S4(buf[7])); | ||
else { | ||
// Otherwise, just use Math.random | ||
// https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript | ||
// https://stackoverflow.com/questions/11605068/why-does-jshint-argue-against-bitwise-operators-how-should-i-express-this-code | ||
function s4() { | ||
return Math.floor((1 + Math.random()) * 0x10000) | ||
.toString(16) | ||
.substring(1); | ||
} | ||
else { | ||
// Otherwise, just use Math.random | ||
// https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript | ||
// https://stackoverflow.com/questions/11605068/why-does-jshint-argue-against-bitwise-operators-how-should-i-express-this-code | ||
function s4() { | ||
return Math.floor((1 + Math.random()) * 0x10000) | ||
.toString(16) | ||
.substring(1); | ||
} | ||
return s4() + s4() + "-" + s4() + "-" + s4() + "-" + | ||
s4() + "-" + s4() + s4() + s4(); | ||
} | ||
}; | ||
return UUID; | ||
})(); | ||
exports.UUID = UUID; | ||
}); | ||
return s4() + s4() + "-" + s4() + "-" + s4() + "-" + | ||
s4() + "-" + s4() + s4() + s4(); | ||
} | ||
}; | ||
return UUID; | ||
})(); | ||
exports.UUID = UUID; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "angular2-uuid", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "Angular 2 / TypeScript crypto-secure UUID generator", | ||
"main": "index.ts", | ||
"main": "index.js", | ||
"typings": "./index.d.ts", | ||
"scripts": { | ||
"prepublish": "tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -8,0 +10,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
8337
9
175