uuid-tool
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -8,3 +8,3 @@ !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); | ||
*/ | ||
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}(); | ||
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(e){return"string"==typeof e&&(e=new t(e)),this.toString()===e.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}(); | ||
/** | ||
@@ -11,0 +11,0 @@ * UUID Tool |
@@ -47,6 +47,6 @@ /** | ||
* Compares this UUID with another UUID. | ||
* @param uuid Another UUID. | ||
* @param uuid Another UUID or uuid-string. | ||
* @return True if equal, otherwise false. | ||
*/ | ||
equals(uuid: UUID): boolean; | ||
equals(uuid: UUID | string): boolean; | ||
} |
{ | ||
"name": "uuid-tool", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Lightweight UUID for JavaScript. Parse and generate UUIDs. Convert between string and byte array.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -19,2 +19,4 @@ # UUID Tool | ||
[NPM Package](https://www.npmjs.com/package/uuid-tool) | ||
## Example | ||
@@ -74,5 +76,5 @@ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| uuid | string | UUID string e.g. '1FBD384C-B2A1-41C6-84AF-43CABDF44124' | | ||
| Param | Type | Description | | ||
| ----- | ------ | ------------------------------------------------------- | | ||
| uuid | string | UUID string e.g. '1FBD384C-B2A1-41C6-84AF-43CABDF44124' | | ||
@@ -87,4 +89,4 @@ **Returns** `number[]` UUID byte array (length: 16) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| Param | Type | Description | | ||
| ----- | -------- | ------------------------------------------ | | ||
| bytes | number[] | UUID Byte array (length 16 bytes of bytes) | | ||
@@ -108,5 +110,5 @@ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| uuid | string | UUID string e.g. '1FBD384C-B2A1-41C6-84AF-43CABDF44124' | | ||
| Param | Type | Description | | ||
| ----- | ------ | ------------------------------------------------------- | | ||
| uuid | string | UUID string e.g. '1FBD384C-B2A1-41C6-84AF-43CABDF44124' | | ||
@@ -121,4 +123,4 @@ **Returns** `boolean` True if valid, otherwise false. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| Param | Type | Description | | ||
| ----- | ------ | ----------- | | ||
| uuid1 | string | UUID string | | ||
@@ -145,4 +147,4 @@ | uuid2 | string | UUID string | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| Param | Type | Description | | ||
| ----- | -------- | ------------------------------------------ | | ||
| bytes | number[] | UUID Byte array (length 16 bytes of bytes) | | ||
@@ -166,5 +168,5 @@ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| uuid | string | string e.g. '1FBD384C-B2A1-41C6-84AF-43CABDF44124' | | ||
| Param | Type | Description | | ||
| ----- | ------ | -------------------------------------------------- | | ||
| uuid | string | string e.g. '1FBD384C-B2A1-41C6-84AF-43CABDF44124' | | ||
@@ -196,5 +198,5 @@ **Returns** `this` The same UUID instance. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| uuid | UUID | Another UUID instance. | | ||
| Param | Type | Description | | ||
| ----- | -------------- | ------------------------------------- | | ||
| uuid | UUID \| string | Another UUID instance or uuid-string. | | ||
@@ -201,0 +203,0 @@ **Returns** `boolean` True if equal, otherwise false. |
21696
204