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)

The interfaces that underlie this library.

The value storage handler interface that consumers generally work with is FluentHandler, which enhances the core ValueStorageHandler interface with fluent methods to build variations with additional constraints.

The options passed to functions in the library are also described as interfaces. The most frequently used is ValueStorageHandlerOptions, which are the options passed to the ValueStorageHandler.storeValue method to control the storage behavior (e.g., to map property names to file names, etc.).

The FileWriter and DirectoryCreator interfaces are the low-level abstractions over the underlying runtime platform. Deno and Node.js/Bun have implementations built into the library, but it is possible to write additional implementations over other file system-like media and use them with the library.

Interfaces

I
ArrayToDirectoryHandlerOptions

Options that apply specifically to the array to directory builder method: HandlerBuilder.arrayToDirectory.

I
DirectoryCreator

Interface of a directory creator, that can asynchronously create a new directory.

I
FileValueHandlerOptions

The common options passed to the file handler builder methods on interface HandlerBuilder.

I
FileWriter

Interface of a writer that can write text files from strings and Uint8Arrays to the file system.

I
HandlerBuilder

A fluent builder interface for creating value storage handlers handlers.

I
JsonFileValueHandlerOptions

The specific options for the HandlerBuilder.jsonFile method.

I
ValueStorageHandler

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

I
ValueStorageHandlerOptions

Options passed to the ValueStorageHandler storeValueToFile method.

I
WithOptionalSignal

Our own equivalent to the Node.js Abortable interface. Unfortunately, the Deno and Node.js AbortSignal types aren't completely identical, so using Abortable directly causes type checking issues.

I
WriteTextToFileOptions

Options passed to the FileWriter writeTextToFile method.

Type Aliases

T
CanStoreValueFunc

The signature expected of the custom canStoreValue implementation passed to the HandlerBuilder.customFile method.

T
StringifyFunc

The signature expected of serializer functions passed to the HandlerBuilder.customFile method.

Add Package

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

Import symbol

import * as mod from "@scroogieboy/object-to-directory/interfaces";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@scroogieboy/object-to-directory/interfaces";

Add Package

npx jsr add @scroogieboy/object-to-directory

Import symbol

import * as mod from "@scroogieboy/object-to-directory/interfaces";

Add Package

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

Import symbol

import * as mod from "@scroogieboy/object-to-directory/interfaces";

Add Package

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

Import symbol

import * as mod from "@scroogieboy/object-to-directory/interfaces";

Add Package

bunx jsr add @scroogieboy/object-to-directory

Import symbol

import * as mod from "@scroogieboy/object-to-directory/interfaces";