Skip to main content

Built and signed on GitHub Actions

Library to write out the contents of a JavaScript object structure to the file system in a granular directory structure.

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
4 months ago (0.1.4)
interface ValueStorageHandler

Interface implemented by objects that can store values to files or directories.

Value storage handlers, as opposed to writers, encapsulate reading serialization and writing of a value to the file system (or wherever the underlying writer persists to). They also encapsulate the evaluation whether they can handle the value, so that the overall storage orchestration can query value storage handlers in order until one matches.

This library only contains value storage handlers for plain text, binary data and JSON files, plus directories of files/directories. Consumers can create their own handlers for additional formats.

Properties

readonly
name: string

The name of the storer. For runtime debugging purposes.

Methods

canStoreValue(
pathInSource: string,
destinationUrl: URL,
value: unknown,
): boolean

Check whether this file value storer is able to store this value.

storeValue(
pathInSource: string,
destinationUrl: URL,
value: unknown,
options?: Readonly<ValueStorageHandlerOptions>,
): Promise<void>

Asynchronously store (serialize and write) the contents to the file system at the specified URL. The exact serialization format depends on the implementation.

If the ValueStorageHandler is associated with a specific file extension, it will add the extension as it writes the file.

Add Package

deno add jsr:@scroogieboy/object-to-directory

Import symbol

import { type ValueStorageHandler } from "@scroogieboy/object-to-directory/interfaces";

---- OR ----

Import directly with a jsr specifier

import { type ValueStorageHandler } from "jsr:@scroogieboy/object-to-directory/interfaces";

Add Package

npx jsr add @scroogieboy/object-to-directory

Import symbol

import { type ValueStorageHandler } from "@scroogieboy/object-to-directory/interfaces";

Add Package

yarn dlx jsr add @scroogieboy/object-to-directory

Import symbol

import { type ValueStorageHandler } from "@scroogieboy/object-to-directory/interfaces";

Add Package

pnpm dlx jsr add @scroogieboy/object-to-directory

Import symbol

import { type ValueStorageHandler } from "@scroogieboy/object-to-directory/interfaces";

Add Package

bunx jsr add @scroogieboy/object-to-directory

Import symbol

import { type ValueStorageHandler } from "@scroogieboy/object-to-directory/interfaces";