Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _writeChunk(type: number, /*nullable*/data: Uint8Array) {
var {length: len} = data !== null ? data : { length: 0 };
var buf = new Uint8Array(len + 12);
PngWriter._writeAsBigEndian(buf, len, 0);
PngWriter._writeAsBigEndian(buf, type, 4);
if (data !== null) {
PngWriter.copy(data, buf, 8);
}
var partWithoutLen = buf.slice(4, buf.length - 4);
PngWriter._writeAsBigEndian(buf, crc32.default(0, partWithoutLen, partWithoutLen.length, 0), buf.length - 4);
return buf;
};