UNPKG

uuid-stream

Version:

A Transform stream that generates RFC-compliant UUID v5.

25 lines (24 loc) 760 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.URL = exports.DNS = void 0; const stream_1 = require("stream"); const uuid_hash_1 = require("uuid-hash"); exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; class UuidStream extends stream_1.Transform { hash; constructor(namespace = exports.URL, version = 0x50) { super(); this.hash = (0, uuid_hash_1.createHash)(namespace, version); } _write(chunk, _encoding, callback) { this.hash.update(chunk); this.push(chunk); callback(); } _flush(callback) { this.emit('uuid', this.hash.digest()); callback(); } } exports.default = UuidStream;