@hal313/settings-manager-chrome-extension-adapter v1.1.3
settings-manager-chrome-extension-adapter
A wrapper to adapt Chrome storage storage API (for extensions) to settings-manager.
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)
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 installBuilding
A build will check the source code and place code in the dist directory.
npm run buildTo run a build on source code changes:
npm run watch:buildTo build distributable artifacts (which includes a minimized version):
npm run distRunning Tests
To run tests against the source code and dist folder (including coverage):
npm testTo run tests against the source code and dist folder (including coverage), with reload:
npm run test:watchBuild a Release
This is a basic script which can be used to build and deploy (to NPM) the project.
npm run releaseReleases 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