@actually_connor/uuid
Advanced tools
Comparing version 0.3.11 to 0.3.12
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.Uuid = void 0; | ||
var Uuid_1 = require("./Uuid"); | ||
Object.defineProperty(exports, "Uuid", { | ||
@@ -12,0 +10,0 @@ enumerable: true, |
@@ -7,9 +7,6 @@ "use strict"; | ||
exports.fromBufferToString = exports.fromStringToBuffer = exports.strcmp = void 0; | ||
const strcmp = (string1, string2) => { | ||
return (string1 ?? 0).toString().localeCompare((string2 ?? 0).toString()); | ||
}; | ||
exports.strcmp = strcmp; | ||
function fromStringToBuffer(uuid) { | ||
@@ -24,13 +21,9 @@ if (!uuid) { | ||
} | ||
exports.fromStringToBuffer = fromStringToBuffer; | ||
function fromBufferToString(buffer) { | ||
if (buffer.length != 16) throw new Error(`Invalid buffer length for uuid: ${buffer.length}`); | ||
if (buffer.equals(Buffer.alloc(16))) return null; // If buffer is all zeros, return null | ||
const str = buffer.toString('hex'); | ||
return `${str.slice(0, 8)}-${str.slice(8, 12)}-${str.slice(12, 16)}-${str.slice(16, 20)}-${str.slice(20)}`; | ||
} | ||
exports.fromBufferToString = fromBufferToString; |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.Uuid = void 0; | ||
const uuid_1 = require("uuid"); | ||
const util_1 = require("./util"); | ||
@@ -15,4 +13,2 @@ /** | ||
*/ | ||
class Uuid { | ||
@@ -38,4 +34,2 @@ /** | ||
*/ | ||
getUuid() { | ||
@@ -51,4 +45,2 @@ return this.uuid; | ||
*/ | ||
static fromString(uuid) { | ||
@@ -62,4 +54,2 @@ return new Uuid((0, uuid_1.parse)(uuid)); | ||
*/ | ||
toString() { | ||
@@ -73,4 +63,2 @@ return (0, uuid_1.stringify)(this.uuid); | ||
*/ | ||
getHex() { | ||
@@ -86,10 +74,6 @@ return (0, uuid_1.stringify)(this.uuid).replace(/-/g, '').toUpperCase(); | ||
*/ | ||
static fromBytes(bytes) { | ||
let result = ''; | ||
for (let i = 0; i < bytes.length; i++) { | ||
result += bytes.charCodeAt(i).toString(16); | ||
switch (i) { | ||
@@ -104,3 +88,2 @@ case 3: | ||
} | ||
return new Uuid((0, uuid_1.parse)(result)); | ||
@@ -113,11 +96,7 @@ } | ||
*/ | ||
getBytes() { | ||
let bytes = ''; | ||
for (let i = 0; i < this.uuid.length; i++) { | ||
bytes += String.fromCharCode(this.uuid[i]); | ||
} | ||
return bytes.replace(' ', ''); | ||
@@ -132,4 +111,2 @@ } | ||
*/ | ||
static fromBuffer(buffer) { | ||
@@ -143,4 +120,2 @@ return new Uuid((0, uuid_1.parse)((0, util_1.fromBufferToString)(buffer))); | ||
*/ | ||
getBuffer() { | ||
@@ -154,4 +129,2 @@ return (0, util_1.fromStringToBuffer)((0, uuid_1.stringify)(this.uuid)); | ||
*/ | ||
static uuid4() { | ||
@@ -167,4 +140,2 @@ return new Uuid((0, uuid_1.parse)((0, uuid_1.v4)())); | ||
*/ | ||
static isValid(uuid) { | ||
@@ -183,4 +154,2 @@ return (0, uuid_1.validate)(uuid); | ||
*/ | ||
equals(other) { | ||
@@ -190,3 +159,2 @@ if (!(other instanceof Uuid)) { | ||
} | ||
return this.compareTo(other) === 0; | ||
@@ -206,20 +174,13 @@ } | ||
*/ | ||
compareTo(other) { | ||
const compare = (0, util_1.strcmp)(this.toString(), other.toString()); | ||
if (compare < 0) { | ||
return -1; | ||
} | ||
if (compare > 0) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
} | ||
exports.Uuid = Uuid; |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.Uuid = void 0; | ||
var Uuid_1 = require("./Uuid"); | ||
Object.defineProperty(exports, "Uuid", { | ||
@@ -12,0 +10,0 @@ enumerable: true, |
@@ -7,9 +7,6 @@ "use strict"; | ||
exports.fromBufferToString = exports.fromStringToBuffer = exports.strcmp = void 0; | ||
const strcmp = (string1, string2) => { | ||
return (string1 ?? 0).toString().localeCompare((string2 ?? 0).toString()); | ||
}; | ||
exports.strcmp = strcmp; | ||
function fromStringToBuffer(uuid) { | ||
@@ -24,13 +21,9 @@ if (!uuid) { | ||
} | ||
exports.fromStringToBuffer = fromStringToBuffer; | ||
function fromBufferToString(buffer) { | ||
if (buffer.length != 16) throw new Error(`Invalid buffer length for uuid: ${buffer.length}`); | ||
if (buffer.equals(Buffer.alloc(16))) return null; // If buffer is all zeros, return null | ||
const str = buffer.toString('hex'); | ||
return `${str.slice(0, 8)}-${str.slice(8, 12)}-${str.slice(12, 16)}-${str.slice(16, 20)}-${str.slice(20)}`; | ||
} | ||
exports.fromBufferToString = fromBufferToString; |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.Uuid = void 0; | ||
const uuid_1 = require("uuid"); | ||
const util_1 = require("./util"); | ||
@@ -15,4 +13,2 @@ /** | ||
*/ | ||
class Uuid { | ||
@@ -38,4 +34,2 @@ /** | ||
*/ | ||
getUuid() { | ||
@@ -51,4 +45,2 @@ return this.uuid; | ||
*/ | ||
static fromString(uuid) { | ||
@@ -62,4 +54,2 @@ return new Uuid((0, uuid_1.parse)(uuid)); | ||
*/ | ||
toString() { | ||
@@ -73,4 +63,2 @@ return (0, uuid_1.stringify)(this.uuid); | ||
*/ | ||
getHex() { | ||
@@ -86,10 +74,6 @@ return (0, uuid_1.stringify)(this.uuid).replace(/-/g, '').toUpperCase(); | ||
*/ | ||
static fromBytes(bytes) { | ||
let result = ''; | ||
for (let i = 0; i < bytes.length; i++) { | ||
result += bytes.charCodeAt(i).toString(16); | ||
switch (i) { | ||
@@ -104,3 +88,2 @@ case 3: | ||
} | ||
return new Uuid((0, uuid_1.parse)(result)); | ||
@@ -113,11 +96,7 @@ } | ||
*/ | ||
getBytes() { | ||
let bytes = ''; | ||
for (let i = 0; i < this.uuid.length; i++) { | ||
bytes += String.fromCharCode(this.uuid[i]); | ||
} | ||
return bytes.replace(' ', ''); | ||
@@ -132,4 +111,2 @@ } | ||
*/ | ||
static fromBuffer(buffer) { | ||
@@ -143,4 +120,2 @@ return new Uuid((0, uuid_1.parse)((0, util_1.fromBufferToString)(buffer))); | ||
*/ | ||
getBuffer() { | ||
@@ -154,4 +129,2 @@ return (0, util_1.fromStringToBuffer)((0, uuid_1.stringify)(this.uuid)); | ||
*/ | ||
static uuid4() { | ||
@@ -167,4 +140,2 @@ return new Uuid((0, uuid_1.parse)((0, uuid_1.v4)())); | ||
*/ | ||
static isValid(uuid) { | ||
@@ -183,4 +154,2 @@ return (0, uuid_1.validate)(uuid); | ||
*/ | ||
equals(other) { | ||
@@ -190,3 +159,2 @@ if (!(other instanceof Uuid)) { | ||
} | ||
return this.compareTo(other) === 0; | ||
@@ -206,20 +174,13 @@ } | ||
*/ | ||
compareTo(other) { | ||
const compare = (0, util_1.strcmp)(this.toString(), other.toString()); | ||
if (compare < 0) { | ||
return -1; | ||
} | ||
if (compare > 0) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
} | ||
exports.Uuid = Uuid; |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.Uuid = void 0; | ||
var Uuid_1 = require("./Uuid"); | ||
Object.defineProperty(exports, "Uuid", { | ||
@@ -12,0 +10,0 @@ enumerable: true, |
@@ -7,9 +7,6 @@ "use strict"; | ||
exports.fromBufferToString = exports.fromStringToBuffer = exports.strcmp = void 0; | ||
const strcmp = (string1, string2) => { | ||
return (string1 ?? 0).toString().localeCompare((string2 ?? 0).toString()); | ||
}; | ||
exports.strcmp = strcmp; | ||
function fromStringToBuffer(uuid) { | ||
@@ -24,13 +21,9 @@ if (!uuid) { | ||
} | ||
exports.fromStringToBuffer = fromStringToBuffer; | ||
function fromBufferToString(buffer) { | ||
if (buffer.length != 16) throw new Error(`Invalid buffer length for uuid: ${buffer.length}`); | ||
if (buffer.equals(Buffer.alloc(16))) return null; // If buffer is all zeros, return null | ||
const str = buffer.toString('hex'); | ||
return `${str.slice(0, 8)}-${str.slice(8, 12)}-${str.slice(12, 16)}-${str.slice(16, 20)}-${str.slice(20)}`; | ||
} | ||
exports.fromBufferToString = fromBufferToString; |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.Uuid = void 0; | ||
const uuid_1 = require("uuid"); | ||
const util_1 = require("./util"); | ||
@@ -15,4 +13,2 @@ /** | ||
*/ | ||
class Uuid { | ||
@@ -38,4 +34,2 @@ /** | ||
*/ | ||
getUuid() { | ||
@@ -51,4 +45,2 @@ return this.uuid; | ||
*/ | ||
static fromString(uuid) { | ||
@@ -62,4 +54,2 @@ return new Uuid((0, uuid_1.parse)(uuid)); | ||
*/ | ||
toString() { | ||
@@ -73,4 +63,2 @@ return (0, uuid_1.stringify)(this.uuid); | ||
*/ | ||
getHex() { | ||
@@ -86,10 +74,6 @@ return (0, uuid_1.stringify)(this.uuid).replace(/-/g, '').toUpperCase(); | ||
*/ | ||
static fromBytes(bytes) { | ||
let result = ''; | ||
for (let i = 0; i < bytes.length; i++) { | ||
result += bytes.charCodeAt(i).toString(16); | ||
switch (i) { | ||
@@ -104,3 +88,2 @@ case 3: | ||
} | ||
return new Uuid((0, uuid_1.parse)(result)); | ||
@@ -113,11 +96,7 @@ } | ||
*/ | ||
getBytes() { | ||
let bytes = ''; | ||
for (let i = 0; i < this.uuid.length; i++) { | ||
bytes += String.fromCharCode(this.uuid[i]); | ||
} | ||
return bytes.replace(' ', ''); | ||
@@ -132,4 +111,2 @@ } | ||
*/ | ||
static fromBuffer(buffer) { | ||
@@ -143,4 +120,2 @@ return new Uuid((0, uuid_1.parse)((0, util_1.fromBufferToString)(buffer))); | ||
*/ | ||
getBuffer() { | ||
@@ -154,4 +129,2 @@ return (0, util_1.fromStringToBuffer)((0, uuid_1.stringify)(this.uuid)); | ||
*/ | ||
static uuid4() { | ||
@@ -167,4 +140,2 @@ return new Uuid((0, uuid_1.parse)((0, uuid_1.v4)())); | ||
*/ | ||
static isValid(uuid) { | ||
@@ -183,4 +154,2 @@ return (0, uuid_1.validate)(uuid); | ||
*/ | ||
equals(other) { | ||
@@ -190,3 +159,2 @@ if (!(other instanceof Uuid)) { | ||
} | ||
return this.compareTo(other) === 0; | ||
@@ -206,20 +174,13 @@ } | ||
*/ | ||
compareTo(other) { | ||
const compare = (0, util_1.strcmp)(this.toString(), other.toString()); | ||
if (compare < 0) { | ||
return -1; | ||
} | ||
if (compare > 0) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
} | ||
exports.Uuid = Uuid; |
{ | ||
"name": "@actually_connor/uuid", | ||
"version": "0.3.11", | ||
"version": "0.3.12", | ||
"description": "A JavaScript library that provides a 'ramsey/uuid'-like interface for the uuid package", | ||
@@ -45,18 +45,18 @@ "keywords": [ | ||
"dependencies": { | ||
"uuid": "^8.3.2" | ||
"uuid": "^9.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.18.6", | ||
"@types/jest": "^28.1.4", | ||
"@types/node": "^18.0.3", | ||
"@babel/cli": "^7.19.3", | ||
"@types/jest": "^28.1.8", | ||
"@types/node": "^18.11.9", | ||
"@types/uuid": "^8.3.4", | ||
"@typescript-eslint/eslint-plugin": "^5.30.5", | ||
"@typescript-eslint/parser": "^5.30.5", | ||
"@typescript-eslint/eslint-plugin": "^5.42.0", | ||
"@typescript-eslint/parser": "^5.42.0", | ||
"docdash": "^1.2.0", | ||
"eslint": "^8.19.0", | ||
"eslint": "^8.26.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"husky": "^8.0.1", | ||
"jest": "^28.1.2", | ||
"ts-jest": "^28.0.5", | ||
"ts-node": "^10.8.2" | ||
"jest": "^28.1.3", | ||
"ts-jest": "^28.0.8", | ||
"ts-node": "^10.9.1" | ||
}, | ||
@@ -63,0 +63,0 @@ "bugs": { |
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
36515
+ Addeduuid@9.0.1(transitive)
- Removeduuid@8.3.2(transitive)
Updateduuid@^9.0.0