Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
buf[p++] = 0x50;
buf[p++] = 0x45;
buf[p++] = 0x32;
buf[p++] = 0x2e;
buf[p++] = 0x30;
// Sub-block
buf[p++] = 0x03;
buf[p++] = 0x01;
buf[p++] = loop_count & 0xff;
buf[p++] = loop_count >> 8 & 0xff;
buf[p++] = 0x00; // Terminator.
}
var self = this;
var reader = rs.getReader();
return new ReadableStream({
start: function start(controller) {
controller.enqueue(new Uint8Array(buf));
},
pull: function pull(controller) {
return reader.read().then(function (_ref2) {
var done = _ref2.done,
value = _ref2.value;
if (done) {
controller.enqueue(new Uint8Array([0x3b]));
controller.close();
return;
}
self.addFrame.apply(self, [controller].concat(value));
});
getStream(frames, ctx) {
var options = this.options;
var width = options.gifWidth;
var height = options.gifHeight;
var totalImages = frames.length;
var processedImages = 0;
var self = this;
var rs = new ReadableStream({
pull: function pull(controller) {
var frame = frames.shift();
if (!frame) controller.close();
var imgData, rgbComponents, paletteRGB, nq, paletteArray, numberPixels, pixels;
var r, g, b;
var k = 0;
var delay = (frame.delay) ? frame.delay / 10 : 100;
processedImages++;
delay = (processedImages === totalImages && options.extraLastFrameDelay) ? delay + (options.extraLastFrameDelay / 10) : delay;// Add an extra
ctx = self.addFrameDetails(ctx, frame);
imgData = ctx.getImageData(0, 0, width, height);
rgbComponents = dataToRGB(imgData.data, imgData.width, imgData.height);
nq = new NeuQuant(rgbComponents, rgbComponents.length, 15);
paletteRGB = nq.process();
paletteArray = new Uint32Array(componentizedPaletteToArray(paletteRGB));
numberPixels = imgData.height * imgData.width;
function emptyStream() {
return new ReadableStream({
start(controller) {
controller.close()
}
})
}
}
function streamFromString(str) {
return new ReadableStream({
start(controller) {
controller.enqueue(str)
controller.close()
},
cancel() { },
pull() { }
})
}
function _read(ref) {
let closed = false
return new ReadableStream({
start(controller) {
dispatcher.dispatch("readProxyStream",
ref,
new ivm.Reference((name, ...args) => {
if (name === "close" || name === "end") {
if (!closed) {
closed = true
controller.close()
}
} else if (name === "error") {
controller.error(new Error(args[0]))
} else if (name === "data") {
controller.enqueue(args[0])
} else
logger.debug("unhandled event", name)
})