User Defaults
Persistent data store for node apps.
Getting Started
The goal of this library is to provide a very straighforward way to write persistent data to disk. This can be useful when working with small amounts of data, like a simple configuration of an application or to store some preferences of a user. All data is stored in JSON format.
# Add the lib to your project and you are good to go. $ yarn add node-user-defaults # Not in a hurry? Use npm. $ npm install --save node-user-defaults
Sample Code
; // OPTIONAL: Choose an output location for the JSON file.// If this one is not provided, a random one will be created.// You can always check the location via Store.getLocation().Store; // Storing variables is very easy and straighforward.// You can store any type that is supported by JSON.Store; // Reading data is easy too. It's also possible to provide// a default value in case the variable is not in the store.const darkTheme = Store;const name = Store; // You can also write multiple variables at once by storing// a plan JSON object. Easy huh?Store; // It is also possible to overwrite the whole configuration.// So all previously stored variables will be removed.Store; // Last but not least, you can query all the variables at once.const data = Store;
Running the tests
$ git clone https://github.com/Jense5/node-user-defaults
$ cd node-user-defaults
$ yarn install
$ yarn test
Credits
- Jensen Bernard - Initial work & maintenance - Jense5
This project is licensed under the MIT License - see the license file for details.