npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

balena-settings-storage

v8.1.0

Published

Balena settings storage utilities

Downloads

54,337

Readme

balena-settings-storage

npm version dependencies Build Status Build status

Join our online chat at Gitter chat

Balena settings storage utilities.

Role

The intention of this module is to provide low level access to how balena 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 balena SDK instead.

Installation

Install balena-settings-storage by running:

$ npm install --save balena-settings-storage

Documentation

storage.getStorage(options) ⇒ storage

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

| Param | Type | Description | | --- | --- | --- | | options | Object | options | | [options.dataDirectory] | String | False | the directory to use for storage in Node.js or false to create an isolated in memory instance. Values other than false are ignored in the browser. |

Example

// with es6 imports
import { getStorage } from 'balena-settings-storage';
// or with node require
const { getStorage } = require('balena-settings-storage');

const storage = getStorage({
	dataDirectory: '/opt/cache/balena'
});

getStorage~set(name, value) ⇒ Promise

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

| Param | Type | Description | | --- | --- | --- | | name | String | name | | 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

| Param | Type | Description | | --- | --- | --- | | name | String | name |

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

| Param | Type | Description | | --- | --- | --- | | name | String | name |

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

| Param | Type | Description | | --- | --- | --- | | name | String | name |

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 balena 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.