MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / constructor

Method constructor

projects/JavaScript/proto/uuid.js:31–43  ·  view source on GitHub ↗

* Initialize a new UUID instance from the provided source or create nil UUID if the source is not provided * @param {string|Uint8Array|UUID} value Source value * @constructor

(value = undefined)

Source from the content-addressed store, hash-verified

29 * @constructor
30 */
31 constructor (value = undefined) {
32 if (value == null) {
33 this.data = new Uint8Array(16)
34 } else if ((value instanceof Array) || (value instanceof Uint8Array)) {
35 this.data = UUID.fromBytes(value).data.slice()
36 } else if ((typeof value === 'string') || (value instanceof String)) {
37 this.data = UUID.fromString(value).data.slice()
38 } else if (value instanceof UUID) {
39 this.data = value.data.slice()
40 } else {
41 throw new Error('Unsupported UUID base type ' + (typeof value))
42 }
43 }
44
45 /**
46 * Is the specified object UUID?

Callers

nothing calls this directly

Calls 2

fromBytesMethod · 0.45
fromStringMethod · 0.45

Tested by

no test coverage detected