Skip to main content
Home

Built and signed on GitHub Actions

Common types and utilities for Pluggable Storage Modules

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
100%
Published
a month ago (0.8.0)

Common types and utilities for Pluggable Storage Modules

See @storage/main for the bigger picture.

This package provides the storage module interface definition and some reusable utility function for use by implementations.

StorageModule

If you need to reference the interface for a storage module:

import type { StorageModule } from "jsr:@storage/common/types";

Test Utils

If you want to implement your own storage modules the test utils can help you get started with some standard tests...

Example test case

import {
  open,
  testClearItems,
  testGetItem,
  testHasItem,
  testIsWriteable,
  testListItems,
  testOrdering,
  testRemoveItem,
  testSetItem,
  testUrl,
} from "@storage/common/test-storage-module";

// This is your custom storage module
import * as store from "./mod.ts";

Deno.test("store-my-custom-storage", async (t) => {
  try {
    await open(t, store);
    await testUrl(t, store, "store-my-custom-storage");
    await testIsWriteable(t, store);
    await testSetItem(t, store);
    await testHasItem(t, store);
    await testGetItem(t, store);
    await testListItems(t, store);
    await testRemoveItem(t, store);
    await testClearItems(t, store);
    await testOrdering(t, store);
  } finally {
    await store.close();
  }
});
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.