bosom
bosom
is a Node.JS package which can read and write JSON files easily. It can be used to record and update configurations as serialised JSON data.
yarn add bosom
API
The package is available by importing its default function:
async bosom(
path: string,
data=: Object,
options=: Options,
): string|void
The function which can be used for both reading and writing of data. When only a single argument is passed, the read mode is assumed. To write data, it should be passed as the second argument, with an optional config.
bosom
will read the file when only a path is passed.
/* eslint-disable no-console */ async { try const p = const res = await console catch err console }
t hello: 'world' foo: true bar: -1
When data is passed, bosom
will write into that file the serialised version of the object. An optional configuration can be passed along to the JSON.stringify
method.
_bosom.Options
: Options for writing.
Name | Type & Description |
---|---|
space | number |
How many spaces to use for indentation. | |
replacer | !Function |
The replacer function used when serializing data (see JSON.stringify documentation). |
/* eslint-disable no-console */ async { try const p = await // test the written value const actual = console catch err console }
t 'my-data': true bar: 'foo'