1.0.2 • Published 5 years ago

jsafe v1.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

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.

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

ParamTypeDescription
jsonPathstringThe path of json file.
jsonDataobjectJSON 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.

ParamTypeDescription
jsonPathstringThe path of json file.
defaultJsonDataobjectJSON 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.