uuid-tool
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -1,2 +0,2 @@ | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e); | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e); | ||
/** | ||
@@ -8,3 +8,3 @@ * UUID | ||
*/ | ||
var r=function(){function t(t){this.value="","string"==typeof t&&36===t.length?this.fromString(t):"object"==typeof t&&16===t.length?this.fromBytes(t):this.generate()}return t.prototype.generate=function(){var t=new Array(16).fill(0).map(function(){return 255*Math.random()&255});return t[6]=79&(64|t[6]),this.fromBytes(t),this},t.prototype.fromBytes=function(t){return this.value=t.map(function(t){return("00"+t.toString(16)).slice(-2)}).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5").toUpperCase(),this},t.prototype.toBytes=function(){return(this.value.replace(/-/g,"").match(/.{2}/g)||[]).map(function(t){return parseInt(t,16)})},t.prototype.fromString=function(t){return this.value=t,this},t.prototype.toString=function(){switch(t.stringExportFormat){default:case"uppercase":return this.value.toUpperCase();case"lowercase":return this.value.toLowerCase()}},t.prototype.isValid=function(){return"string"==typeof this.value&&36===this.value.length&&t.REGEX.UUID.test(this.value)},t.prototype.equals=function(t){return this.toString()===t.toString()},t.stringExportFormat="uppercase",t.REGEX={UUID:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i},t}(),o=function(){function t(){}return t.toBytes=function(t){return(new r).fromString(t).toBytes()},t.toString=function(t){return(new r).fromBytes(t).toString()},t.newUUID=function(){return(new r).toString()},t.isUUID=function(t){return(new r).fromString(t).isValid()},t.compare=function(t,e){return new r(t).equals(new r(e))},t}(); | ||
var n=function(){function t(t){this.value="","string"==typeof t?this.fromString(t):Array.isArray(t)?this.fromBytes(t):this.generate()}return t.prototype.generate=function(){var t=new Array(16).fill(0).map(function(){return 255*Math.random()&255});return t[6]=79&(64|t[6]),this.fromBytes(t),this},t.prototype.fromBytes=function(t){return this.value=t.map(function(t){return("00"+t.toString(16)).slice(-2)}).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5").toUpperCase(),this},t.prototype.toBytes=function(){return(this.value.replace(/-/g,"").match(/.{2}/g)||[]).map(function(t){return parseInt(t,16)})},t.prototype.fromString=function(t){return this.value=t.trim(),this},t.prototype.toString=function(){switch(t.stringExportFormat){default:case"uppercase":return this.value.toUpperCase();case"lowercase":return this.value.toLowerCase()}},t.prototype.isValid=function(){return"string"==typeof this.value&&36===this.value.length&&t.REGEX.UUID.test(this.value)},t.prototype.equals=function(t){return this.toString()===t.toString()},t.stringExportFormat="uppercase",t.REGEX={UUID:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i},t}(),o=function(){function t(){}return t.toBytes=function(t){return(new n).fromString(t).toBytes()},t.toString=function(t){return(new n).fromBytes(t).toString()},t.newUUID=function(){return(new n).toString()},t.isUUID=function(t){return(new n).fromString(t).isValid()},t.compare=function(t,e){return new n(t).equals(new n(e))},t}(); | ||
/** | ||
@@ -15,2 +15,2 @@ * UUID Tool | ||
* @license Apache-2.0 | ||
*/n.d(e,"UUIDTool",function(){return o}),n.d(e,"UUID",function(){return r})}])}); | ||
*/r.d(e,"UUIDTool",function(){return o}),r.d(e,"UUID",function(){return n})}])}); |
{ | ||
"name": "uuid-tool", | ||
"version": "1.3.0", | ||
"description": "Parse and generate UUIDs. Convert between UUID string (36 byte) to 16 byte array.", | ||
"version": "1.3.1", | ||
"description": "Lightweight UUID for JavaScript. Parse and generate UUIDs. Convert between string and byte array.", | ||
"keywords": [ | ||
@@ -9,2 +9,3 @@ "uuid", | ||
"generate", | ||
"compare", | ||
"byte", | ||
@@ -11,0 +12,0 @@ "array", |
# UUID Tool | ||
Lightweight UUID library for JavaScript. | ||
No bullshit, simple to use, easy to learn. | ||
Parse and generate UUIDs. Convert between UUID string (36 byte) to 16 byte array. | ||
@@ -23,2 +26,3 @@ Inclusive TypeScript definition file (types). | ||
let isValid = UUIDTool.isUUID(strAgain); | ||
let isEqual = UUIDTool.compare(uuid1, uuid2); | ||
``` | ||
@@ -74,3 +78,3 @@ | ||
**Returns** `number` UUID byte array (length: 16) | ||
**Returns** `number[]` UUID byte array (length: 16) | ||
@@ -77,0 +81,0 @@ --- |
21245
202