jsafe

1.0.2 • Public • Published

JSafe

Very fast queue for JSON write queries.

Install

npm install jsafe

Import

const { write, read } = require("jsafe")

Functions

write(jsonPath, jsonData)promise

Add JSON object to write or to stack.

read(jsonPath, defaultJsonData)object

Read the JSON file if it exists.

write(jsonPath, jsonData) ⇒ promise

Add JSON object to write or to stack.

Kind: global function Returns: promise - - But catch error is optional.

Param Type Description
jsonPath string The path of json file.
jsonData object JSON stringable data.
write("./file.json", json)
// Check if a writing is in progress.
// If so, overwrites the waiting stack
// with the new version of the file.

read(jsonPath, defaultJsonData) ⇒ object

Read the JSON file if it exists.

Kind: global function Returns: object - - JSON exploitable data.

Param Type Description
jsonPath string The path of json file.
defaultJsonData object JSON stringable data.
const json = read("./file.json", "Hello World")
// Require json and delete require.cache.
// To do only once in the same script.
// Returns defaultJsonData if the file is non-existent.

Package Sidebar

Install

npm i jsafe

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

4.34 kB

Total Files

3

Last publish

Collaborators

  • ghom