Skip to content

Gabryk/json-event-emitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-event-emitter

A watcher for JSON files handler by EventEmitter

Tech

This module is base in others modules (fs, events)

Installation

$ npm install -s json-event-emitter

Creating instance from file path

Our test.json file

{
    "hello": "This is a test",
    "deepHello": {
        "hello": "Hello from deep"
    }
}

Create instance

const path = require('path');
const JsonEventEmitter = require('json-event-emitter');

var someJson = new JsonEventEmitter({
	path: path.resolve(__dirname, 'test.json')
});
//  Get the data as JS Object
console.log(someJson.getValue())

Updating changes

Modify a specific property change on the JSON file.

someJSON.update({
	deepHello:{
		hello: 'This is unfair'
	}
});

Listening events change

Register a function that is executed when a change is made.

someJson.on('change', (changes, value)=>{
	console.log("This changes where apply", changes);
})

About

A watcher for JSON files handler by EventEmitter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published