Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]
});
uuid.v4({
// Fake random number generator
rng: () => Buffer.alloc(16)
});
// $ExpectError
uuid.v4({
rng: () => 'bla'
});
// $ExpectError
uuid.parse([23]);
const buffer1 = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10');
uuid.unparse(buffer1);
0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36
]
});
uuid.v4({
// Fake random number generator
rng: () => Buffer.alloc(16)
});
// $ExpectError
uuid.v4({
rng: () => 'bla'
});
// $ExpectError
uuid.parse([23]);
const buffer1 = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10');
uuid.unparse(buffer1);
exports.encode = function(uuid_) {
var bytes = uuid.parse(uuid_);
var base64 = (new Buffer(bytes)).toString('base64');
var slug = base64
.replace(/\+/g, '-') // Replace + with - (see RFC 4648, sec. 5)
.replace(/\//g, '_') // Replace / with _ (see RFC 4648, sec. 5)
.substring(0, 22); // Drop '==' padding
return slug;
};
Grain.prototype.uuidToBuffer = function (id) {
try {
if (id === undefined || id === null) {
return undefined;
}
if (typeof id === 'string') {
let b = Buffer.allocUnsafe(16);
uuid.parse(id, b);
return b;
}
if (Buffer.isBuffer(id)) {
return id.slice(0, 16);
}
}
catch (e) {
console.log(e);
return undefined;
}
console.log('Could not parse value \'' + id + '\' to a UUID.');
return undefined;
};
function grainMaker(rateNumerator, rateDenominator, flowID, sourceID) {
var start = Date.now() / 1000|0;
var baseNanos = 0;
var count = 0;
function diffTime() {
return nanoTime() - baseNanos;
}
console.log(flowID, sourceID);
if (!Buffer.isBuffer(flowID))
flowID = new Buffer(uuid.parse(flowID));
if (!Buffer.isBuffer(sourceID))
sourceID = new Buffer(uuid.parse(sourceID))
console.log(flowID, sourceID);
var timecode = new Buffer(8).fill(0);
var duration = new Buffer(8);
duration.writeUInt32BE(rateNumerator, 0);
duration.writeUInt32BE(rateDenominator, 4);
var grainGenerator = function (push, next) {
var increment = baseNanos + count * rateDenominator * 1e9 / rateNumerator;
var ptp = ptpToBuffer(start + increment/1e9|0, increment % 1e9);
var g = new Grain([], ptp, ptp, timecode, flowID, sourceID, duration);
push(null, g)
next();
count++;
}
return H(grainGenerator);
function grainMaker(rateNumerator, rateDenominator, flowID, sourceID) {
var start = Date.now() / 1000|0;
var baseNanos = 0;
var count = 0;
function diffTime() {
return nanoTime() - baseNanos;
}
console.log(flowID, sourceID);
if (!Buffer.isBuffer(flowID))
flowID = new Buffer(uuid.parse(flowID));
if (!Buffer.isBuffer(sourceID))
sourceID = new Buffer(uuid.parse(sourceID))
console.log(flowID, sourceID);
var timecode = new Buffer(8).fill(0);
var duration = new Buffer(8);
duration.writeUInt32BE(rateNumerator, 0);
duration.writeUInt32BE(rateDenominator, 4);
var grainGenerator = function (push, next) {
var increment = baseNanos + count * rateDenominator * 1e9 / rateNumerator;
var ptp = ptpToBuffer(start + increment/1e9|0, increment % 1e9);
var g = new Grain([], ptp, ptp, timecode, flowID, sourceID, duration);
push(null, g)
next();
count++;
}
Grain.prototype.uuidToBuffer = function (id) {
try {
if (id === undefined || id === null) {
return undefined;
}
if (typeof id === 'string') {
var b = new Buffer(16);
uuid.parse(id, b);
return b;
}
if (Buffer.isBuffer(id)) {
return id.slice(0, 16);
}
}
catch (e) {
console.log(e);
return undefined;
}
console.log("Could not parse value '" + id + "' to a UUID.");
return undefined;
}
static writeUUID(uuid) {
return require('uuid').parse(uuid);
}
encoder: function(val, bufb) { bufb.appendBuffer(new Buffer(uuid.parse(val))); },
decoder: function(buf) { return uuid.unparse(buf); }