* 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)
| 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? |
nothing calls this directly
no test coverage detected