builder-util-runtime
Advanced tools
Comparing version 8.7.0 to 8.7.1
151
out/uuid.js
@@ -44,49 +44,59 @@ "use strict"; | ||
class UUID { | ||
constructor(uuid) { | ||
this.ascii = null; | ||
this.binary = null; | ||
const check = UUID.check(uuid); | ||
let UUID = | ||
/** @class */ | ||
(() => { | ||
class UUID { | ||
constructor(uuid) { | ||
this.ascii = null; | ||
this.binary = null; | ||
const check = UUID.check(uuid); | ||
if (!check) { | ||
throw new Error("not a UUID"); | ||
} | ||
if (!check) { | ||
throw new Error("not a UUID"); | ||
} | ||
this.version = check.version; | ||
this.version = check.version; | ||
if (check.format === "ascii") { | ||
this.ascii = uuid; | ||
} else { | ||
this.binary = uuid; | ||
if (check.format === "ascii") { | ||
this.ascii = uuid; | ||
} else { | ||
this.binary = uuid; | ||
} | ||
} | ||
} | ||
static v5(name, namespace) { | ||
return uuidNamed(name, "sha1", 0x50, namespace); | ||
} | ||
static v5(name, namespace) { | ||
return uuidNamed(name, "sha1", 0x50, namespace); | ||
} | ||
toString() { | ||
if (this.ascii == null) { | ||
this.ascii = stringify(this.binary); | ||
toString() { | ||
if (this.ascii == null) { | ||
this.ascii = stringify(this.binary); | ||
} | ||
return this.ascii; | ||
} | ||
return this.ascii; | ||
} | ||
inspect() { | ||
return `UUID v${this.version} ${this.toString()}`; | ||
} | ||
inspect() { | ||
return `UUID v${this.version} ${this.toString()}`; | ||
} | ||
static check(uuid, offset = 0) { | ||
if (typeof uuid === "string") { | ||
uuid = uuid.toLowerCase(); | ||
static check(uuid, offset = 0) { | ||
if (typeof uuid === "string") { | ||
uuid = uuid.toLowerCase(); | ||
if (!/^[a-f0-9]{8}(-[a-f0-9]{4}){3}-([a-f0-9]{12})$/.test(uuid)) { | ||
return false; | ||
} | ||
if (!/^[a-f0-9]{8}(-[a-f0-9]{4}){3}-([a-f0-9]{12})$/.test(uuid)) { | ||
return false; | ||
} | ||
if (uuid === "00000000-0000-0000-0000-000000000000") { | ||
return { | ||
version: undefined, | ||
variant: "nil", | ||
format: "ascii" | ||
}; | ||
} | ||
if (uuid === "00000000-0000-0000-0000-000000000000") { | ||
return { | ||
version: undefined, | ||
variant: "nil", | ||
version: (hex2byte[uuid[14] + uuid[15]] & 0xf0) >> 4, | ||
variant: getVariant((hex2byte[uuid[19] + uuid[20]] & 0xe0) >> 5), | ||
format: "ascii" | ||
@@ -96,26 +106,26 @@ }; | ||
return { | ||
version: (hex2byte[uuid[14] + uuid[15]] & 0xf0) >> 4, | ||
variant: getVariant((hex2byte[uuid[19] + uuid[20]] & 0xe0) >> 5), | ||
format: "ascii" | ||
}; | ||
} | ||
if (Buffer.isBuffer(uuid)) { | ||
if (uuid.length < offset + 16) { | ||
return false; | ||
} | ||
if (Buffer.isBuffer(uuid)) { | ||
if (uuid.length < offset + 16) { | ||
return false; | ||
} | ||
let i = 0; | ||
let i = 0; | ||
for (; i < 16; i++) { | ||
if (uuid[offset + i] !== 0) { | ||
break; | ||
} | ||
} | ||
for (; i < 16; i++) { | ||
if (uuid[offset + i] !== 0) { | ||
break; | ||
if (i === 16) { | ||
return { | ||
version: undefined, | ||
variant: "nil", | ||
format: "binary" | ||
}; | ||
} | ||
} | ||
if (i === 16) { | ||
return { | ||
version: undefined, | ||
variant: "nil", | ||
version: (uuid[offset + 6] & 0xf0) >> 4, | ||
variant: getVariant((uuid[offset + 8] & 0xe0) >> 5), | ||
format: "binary" | ||
@@ -125,34 +135,31 @@ }; | ||
return { | ||
version: (uuid[offset + 6] & 0xf0) >> 4, | ||
variant: getVariant((uuid[offset + 8] & 0xe0) >> 5), | ||
format: "binary" | ||
}; | ||
} | ||
throw (0, _index().newError)("Unknown type of uuid", "ERR_UNKNOWN_UUID_TYPE"); | ||
} // read stringified uuid into a Buffer | ||
throw (0, _index().newError)("Unknown type of uuid", "ERR_UNKNOWN_UUID_TYPE"); | ||
} // read stringified uuid into a Buffer | ||
static parse(input) { | ||
const buffer = Buffer.allocUnsafe(16); | ||
let j = 0; | ||
static parse(input) { | ||
const buffer = Buffer.allocUnsafe(16); | ||
let j = 0; | ||
for (let i = 0; i < 16; i++) { | ||
buffer[i] = hex2byte[input[j++] + input[j++]]; | ||
for (let i = 0; i < 16; i++) { | ||
buffer[i] = hex2byte[input[j++] + input[j++]]; | ||
if (i === 3 || i === 5 || i === 7 || i === 9) { | ||
j += 1; | ||
} | ||
} | ||
if (i === 3 || i === 5 || i === 7 || i === 9) { | ||
j += 1; | ||
} | ||
return buffer; | ||
} | ||
return buffer; | ||
} | ||
} // from rfc4122#appendix-C | ||
} // from rfc4122#appendix-C | ||
UUID.OID = UUID.parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8"); | ||
return UUID; | ||
})(); | ||
exports.UUID = UUID; | ||
UUID.OID = UUID.parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8"); // according to rfc4122#section-4.1.1 | ||
// according to rfc4122#section-4.1.1 | ||
function getVariant(bits) { | ||
@@ -159,0 +166,0 @@ switch (bits) { |
{ | ||
"name": "builder-util-runtime", | ||
"version": "8.7.0", | ||
"version": "8.7.1", | ||
"main": "out/index.js", | ||
@@ -14,6 +14,6 @@ "author": "Vladimir Krivosheev", | ||
"engines": { | ||
"node": ">=8.2.0" | ||
"node": ">=8.2.5" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.1.1", | ||
"debug": "^4.2.0", | ||
"sax": "^1.2.4" | ||
@@ -20,0 +20,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
141611
1772
Updateddebug@^4.2.0