ymodjson
v1.0.2
Published
update json
Readme
About
Update a json file, using proper-lockfile. Will create a new file if doens't exists.
let modJson = require('ymodjson')
modJson("./data.json", (data) => {
data.f1 = 11; // or f2, f3 etc.
return data;
});async function ymodjson(filePath, updater, op={mkdir:false, retries:{retry:100,factor:1,minTimeout:100}, retry, factor, minTimeout}) {}
- return: nothing
- updater: callback function where r in (r)=>{} is the original json object
- op
- mkdir: default: false, if true: create the file dir if doesn't exist
- retries: default: {retry:500, factor:1, minTimeout:100}
- retry: default: 500
- factor: default : 1 //time=retry*factor*100ms; default: 500*1*100=50000ms(50s)
- minTimeout: 100
- stale: default: 60000 //1mlet modJson = require('ymodjson')
modJson("./data.json", (data) => {
data.f1 = 11; // or f2, f3 etc.
return data;
},{retry:10});