How to use the pako/lib/zlib/crc32.default function in pako

To help you get started, we’ve selected a few pako examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ShyykoSerhiy / canvas-png-compression / src / PngWriter.ts View on Github external
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;
    };