function memoizedCreateCrc32
memoizedCreateCrc32(polynomial: number): (data: Uint8Array) => number

Memoized version of createCrc32.

Calling with the same polynomial returns the cached function.

Examples

Example 1

import { assertEquals } from "@std/assert";
import { memoizedCreateCrc32, CRC32_POLYNOMIAL } from "@hertzg/crc/crc32";

const crc32 = memoizedCreateCrc32(CRC32_POLYNOMIAL);

assertEquals(crc32(new TextEncoder().encode("123456789")), 0xcbf43926);

Parameters

polynomial: number

The CRC32 polynomial to use

Return Type

(data: Uint8Array) => number

A function that calculates CRC32 for given data

Usage

import { memoizedCreateCrc32 } from "crc32.ts";