@hal313/settings-manager-chrome-extension-adapter

1.1.3 • Public • Published

settings-manager-chrome-extension-adapter

A wrapper to adapt Chrome storage storage API (for extensions) to settings-manager.

Build Status NPM version Dependency Status

Introduction

A wrapper to adapt the Chrome storage API (for extensions) to the settings-manager API.

See an example of the SettingsManager API with promises.

Using

API

new SettingsManagerChromeExtensionAdapter([useSync][, path])

Creates a new ChromeExtensionSettingsManager instance. If useSync is falsey, then local storage will be used; otherwise, sync storage is used. The path string specifies the key within storage.

load()

Loads the settings. Returns a promise which resolves with the settings or rejects on failure.

save(settings)

Saves the settings. Requires the settings to save and returns a promise which resolves on success or rejects on failure.

clear()

Clears the settings. Returns a promise which resolves on success or rejects on failure.

Importing

Depending on your environment, you may incorporate the SettingsManager:

Style File Import Statement Instantiate
ES5 SettingsManagerChromeExtensionAdapter.js <script src="SettingsManagerChromeExtensionAdapter.js"></script> var settingsManagerChromeExtensionAdapter = new SettingsManagerChromeExtensionAdapter.SettingsManagerChromeExtensionAdapter();
CJS SettingsManagerChromeExtensionAdapter.js <script src="SettingsManagerChromeExtensionAdapter.js"></script> var settingsManagerChromeExtensionAdapter = new SettingsManagerChromeExtensionAdapter.SettingsManager(ChromeExtensionAdapter);
AMD SettingsManagerChromeExtensionAdapter.js <script src="SettingsManagerChromeExtensionAdapter.js"></script> var settingsManagerChromeExtensionAdapter = new SettingsManagerChromeExtensionAdapter.SettingsManagerChromeExtensionAdapter();
ES6 SettingsManagerChromeExtensionAdapter.es6.js import { SettingsManagerChromeExtensionAdapter } from 'SettingsManagerChromeExtensionAdapter.js'; let settingsManagerChromeExtensionAdapter = new SettingsManagerChromeExtensionAdapter();

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-chrome-extension-adapter

Weekly Downloads

4

Version

1.1.3

License

MIT

Unpacked Size

119 kB

Total Files

35

Last publish

Collaborators

  • hal313