New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

json-persistent-object

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-persistent-object

object that will be written to a json file as soon as its properties changed

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

json-persistent-object

An object that is based on a json file and is written back if any changes made to it. Its value stays consist even if the app is reloaded.

var JSONPO = require('json-persistent-object')

//create an object with data from config.json file
var config = new JSONPO('config.json');

//From now any update to "config" will be written back to the "config.json" immediately 

//add name if it doesn't exist
if (!config.name) config.name = 'testing';

//every time the app is restarted, this config.count will be increased by 1
config.count = config.count? config.count+1 : 0;

if (!config.controller) {
  //initialize default configuration
  config.controller = { timeout: 1, pinMaps: [10, 13] };
}
//...
//later in your code, these changes below will be immediately written back to config.json file
config.controller.pinMaps[1]=12;
config.controller.pinMaps.push(13);

//the content of config.json should be the same as printed by console.log
console.log(config); 

Installation

$ npm install json-persistent-object

Keywords

persistent

FAQs

Package last updated on 14 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts