Skip to main content

Function memoization with strong types.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
3 months ago (0.1.0)
function smartValueSerializer
smartValueSerializer<T>(): ValueSerializer<T>

Initializes a smart serializer/deserializer for memoization caches that need to serialize values.

Uses JSON.stringify and JSON.parse with custom support for common types. Supports BigInt, Uint8Array, ArrayBuffer, Map, and Set.

Note that Date is already supported by JSON, but it always serializes to a string and can't be deserialized back to a Date.

Type Parameters

Return Type

Add Package

deno add jsr:@mega/memoize

Import symbol

import { smartValueSerializer } from "@mega/memoize/utils/valueSerializer";

---- OR ----

Import directly with a jsr specifier

import { smartValueSerializer } from "jsr:@mega/memoize/utils/valueSerializer";

Add Package

npx jsr add @mega/memoize

Import symbol

import { smartValueSerializer } from "@mega/memoize/utils/valueSerializer";

Add Package

yarn dlx jsr add @mega/memoize

Import symbol

import { smartValueSerializer } from "@mega/memoize/utils/valueSerializer";

Add Package

pnpm dlx jsr add @mega/memoize

Import symbol

import { smartValueSerializer } from "@mega/memoize/utils/valueSerializer";

Add Package

bunx jsr add @mega/memoize

Import symbol

import { smartValueSerializer } from "@mega/memoize/utils/valueSerializer";