0.1.2 • Published 6 years ago

syncfig v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Syncfig

This Package is in early development. Please report any bugs. Thanks! 💜

Usage:

const { SyncedConfig } = require("syncfig");

// Create a new SyncedConfig class with the path to your (JSON) config File
const syncedConfig = new SyncedConfig("./test.json");

await syncedConfig.listen();

// test.json currently contains: '{}'

syncedConfig.getConfig(); // {}

syncedConfig.setConfig({
  foo: "bar"
});

/* test.json now contains:
 * {
 *  "foo": "bar"
 * }
 */

syncedConfig.getConfig(); // { foo: 'bar' }

Reacting to events regarding the file:

 ...

function callBack() {
 console.log('The File has been changed. YAAY!');
}

syncedConfig.on('change', callBack);

Event Overview

Will results in these event (chronological order)

When the local file updates
EventnameDescriptions
beforeChangeEmitted when the local file changes.
afterChangeEmitted after the config object has been updated

When the config object is updated
EventnameDescriptions
beforeSetEmitted before the the config object has been changed programmaticaly
afterSetEmitted after the the config object has been changed programmaticaly, but wasnt saved to a file yet
beforeWriteEmitted before the the config object changes are written to the file
afterWriteEmitted after the the config object changes are written to the file
afterSetEmitted after the the config object has been changed programmaticaly and all changes are written to the file

Misc

Stop Watching the file (can not be restarted)
const syncedConfig = new SyncedConfig("./test.json");

syncedConfig.stopWatching();
0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago