0.5.0 • Published 3 years ago

@directdb/yaml-handler v0.5.0

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

@directdb/yaml-handler

NPM GitHub Workflow Status Node.js Versions

YAML file handler for DirectDB.

This handler uses the library yaml under the hood, because it preserves comments unlike other YAML libraries. It defaults to YAML spec 1.2.

Version 2 of the yaml library is under active development and the documentation defaults to version 2. Be sure to refer to the version 1 documentation instead.

Install

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

Usage

The main package directdb already includes @directdb/yaml-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 yamlHandler from '@directdb/yaml-handler'

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

Options

Options are directly passed to yaml's parse and stringify methods. See the yaml library docs for full options.

Customize your file handler options like so:

import directdb from 'directdb'
import yamlHandler from '@directdb/yaml-handler'

yamlHandler.options = {
  prettyErrors: true,
}

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

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 YamlHandler from '@directdb/yaml-handler'

const options: YamlHandler.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