Skip to content
UniKVS
Esc
↑↓navigate↵open⌘Jpreview
On this page

@unikvs/null

Usage of Null in @unikvs/null, a test storage that discards writes.

Overview

@unikvs/null Usage of Null in @unikvs/null, a test storage that discards writes.

  • name is Null.
  • isOpen is always true.
  • No open or close.

Install with:

npm install @unikvs/null
pnpm add @unikvs/null
yarn add @unikvs/null
bun add @unikvs/null
nub add @unikvs/null
aube add @unikvs/null

Usage

Null implements IStorage. Pass it to UniKvs with persist().

import { Null } from "@unikvs/null";

The following example confirms writes are discarded.

import { Null } from "@unikvs/null";
import * as unikvs from "unikvs";

const kvs = new unikvs.Builder<{
  greeting: unikvs.PlainValue<string>;
}>()
  .persist(new Null())
  .build();

await kvs.open();
await kvs.set("greeting", "hello");

console.log(await kvs.has("greeting")); // false

await kvs.close();

Data types

Operation Supported data type
write / read Arbitrary values (never stored)
getWritable / getReadable chunks Arbitrary values (never stored)
  • Discards every written value.
  • read, delete, and getReadable always throw KeyNotFoundError.
  • exists always returns false.
  • clear does nothing.
  • getWritable discards all written chunks.

Errors

This package has no package-specific errors. Failed reads throw KeyNotFoundError, the shared error from @unikvs/core.

Was this page helpful?