@hal313/settings-manager

1.1.2 • Public • Published

settings-manager

A facade for user settings repositories.

Build Status NPM version Dependency Status

Introduction

This is intended as a generic interface to an asynchronous setting API. Using this library allows for abstraction of the underlying settings. This package was inspired by Chrome plugin and Firebase development.

See an example.

Using

API

new SettingsManager([backing_store])

Creates a new SettingsManager instance. The optional backing store should implement the same API as SettingsManager, or have an adapter provided. With no backing store specified, an in-memory store will be used.

load([success[, error]])

Loads the settings. Takes a success callback and an error callback. The value passed into the settings callback represents the value from the backing store.

save(settings[, success[, error]])

Saves the settings. Requires the settings to save and takes an optional callback for the success or error status.

clear([success[, error]])

Clears the settings. Takes an optional callback for the success or error status.

Importing

Depending on your environment, you may incorporate the SettingsManager:

Style File Import Statement Instantiate
ES5 SettingsManager.js <script src="SettingsManager.js"></script> var settingsManager = new SettingsManager.SettingsManager();
CJS SettingsManager.js <script src="SettingsManager.js"></script> var settingsManager = new SettingsManager.SettingsManager();
AMD SettingsManager.js <script src="SettingsManager.js"></script> var settingsManager = new SettingsManager.SettingsManager();
ES6 SettingsManager.es6.js import { SettingsManager } from 'SettingsManager.js'; let sm = new SettingsManager();
Node N/A let SettingsManager = require('@hal313/settings-manager'); let sm = new SettingsManager.SettingsManager();

Examples

The GitHub Pages documentation illustrates several examples.

Developing

Setup

npm install

Building

A build will check the source code and place code in the dist directory.

npm run build

To run a build on source code changes:

npm run watch:build

To build distributable artifacts (which includes a minimized version):

npm run dist

Running Tests

To run tests against the source code and dist folder (including coverage):

npm test

To run tests against the source code and dist folder (including coverage), with reload:

npm run test:watch

Build a Release

This is a basic script which can be used to build and deploy (to NPM) the project.

npm run release

Releases to the NPM registry are handled by Travis CI. Pushing master to GitHub will trigger a build and deploy to the NPM registry. The release script will NOT push to the repository. When pushing, tags should be included:

git push --all && git push --tags

Package Sidebar

Install

npm i @hal313/settings-manager

Weekly Downloads

1

Version

1.1.2

License

MIT

Unpacked Size

155 kB

Total Files

39

Last publish

Collaborators

  • hal313