4.0.1 • Published 7 years ago

resin-settings-storage v4.0.1

Weekly downloads
139
License
Apache-2.0
Repository
github
Last release
7 years ago

resin-settings-storage

npm version dependencies Build Status Build status

Join our online chat at Gitter chat

Resin.io settings storage utilities.

Role

The intention of this module is to provide low level access to how a Resin.io persists settings in both the filesystem and the browser.

THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY.

Unless you know what you're doing, use the Resin SDK instead.

Installation

Install resin-settings-storage by running:

$ npm install --save resin-settings-storage

Documentation

storage.getStorage(options) ⇒ storage

Kind: static method of storage
Summary: Get an instance of storage module
Access: public

ParamTypeDescription
optionsObjectoptions
options.dataDirectorystringthe directory to use for storage in Node.js. Ignored in the browser.

Example

const storage = require('resin-settings-storage')({
	dataDirectory: '/opt/cache/resin'
})

getStorage~set(name, value) ⇒ Promise

Kind: inner method of getStorage
Summary: Set a value
Access: public

ParamTypeDescription
nameStringname
value*value

Example

storage.set('token', '1234')

getStorage~get(name) ⇒ Promise.<*>

Kind: inner method of getStorage
Summary: Get a value
Returns: Promise.<*> - value or undefined
Access: public

ParamTypeDescription
nameStringname

Example

storage.get('token').then((token) => {
	console.log(token)
});

getStorage~has(name) ⇒ Promise.<Boolean>

Kind: inner method of getStorage
Summary: Check if the value exists
Returns: Promise.<Boolean> - has value
Access: public

ParamTypeDescription
nameStringname

Example

storage.has('token').then((hasToken) => {
	if (hasToken) {
		console.log('Yes')
	} else {
		console.log('No')
});

getStorage~remove(name) ⇒ Promise

Kind: inner method of getStorage
Summary: Remove a value
Access: public

ParamTypeDescription
nameStringname

Example

storage.remove('token')

getStorage~clear() ⇒ Promise

Kind: inner method of getStorage
Summary: Remove all values
Access: public
Example

storage.clear()

Support

If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.

Tests

Run the test suite by doing:

$ npm test

Contribute

Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:

$ npm run lint

License

The project is licensed under the Apache 2.0 license.

4.0.1

7 years ago

4.0.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.0

8 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago