JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1242
  • Score
    100M100P100Q124714F
  • License MIT

Manage CLI application encrypted preferences.

Package Exports

  • preferences

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (preferences) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Preferences

NPM version NPM downloads

Node.JS Module for handling encrypted user preferences.

Designed for CLI applications.

js-standard-style

Installation

npm install --save preferences

Usage

var Preferences = require("preferences");

// Init preference file with an unique identifier and an optional default data
var prefs = new Preferences('com.your.app.identifier',{
  account: {
    username: 'MrRobot',
    password: 'fsociety'
  },
  test: {
    cycles: 1
  }
});

// Preferences can be accessed directly
prefs.test.cycles++;

console.log(prefs.account);

Preferences are automatically saved on disk before process exit.

Encryption uses your private ssh key if founded, otherwise it will automatically use an identifier dependant generated password.

You can override the default key path in the options:

var prefs = new Preferences('com.foo.bar',{}, {
  key: '~/certs/my-custom-key.pem'
});

License

MIT. Copyright (c) 2015 Caffeina.