0.5.0 • Published 3 years ago

@directdb/json-handler v0.5.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

@directdb/json-handler

NPM GitHub Workflow Status Node.js Versions

JSON file handler for DirectDB.

Install

npm i @directdb/json-handler
# OR
yarn add @directdb/json-handler

Usage

The main package directdb already includes @directdb/json-handler.

If you want to create your own variant of DirectDB with this handler, you can compose one with @directdb/core:

import directdb from '@directdb/core'
import jsonHandler from '@directdb/json-handler'

const db = await directdb('.', { fileHandlers: [jsonHandler] })

Options

The handler accepts the following options:

const options = {
  replacer: null,
  reviver: undefined,
  space: 2,
}

Refer to the MDN docs for the JavaScript JSON object's replacer, reviver, and space arguments for more information.

Customize your file handler options like so:

import directdb from 'directdb'
import jsonHandler from '@directdb/json-handler'

jsonHandler.options = {
  space: '\t', // use tabs instead of spaces
}

const db = await directdb({ fileHandlers: [jsonHandler] })

Options Type Definition

The package exports the TypeScript type interface of this options object. In .ts files you can import this type as a helper for constructing the options object:

import * as JsonHandler from '@directdb/json-handler'

const options: JsonHandler.Options = {
  /* options*/
}
0.5.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago