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

node-desktop-app-settings

v1.1.1

Published

Module providing multi-platform application settings with automatic saving and creation.

Downloads

3

Readme

node-desktop-app-settings

This npm module provides generic desktop application settings for Linux, Mac OS, and Windows. It runs synchronously for reading and writing. It automatically loads a settings JSON file on invocation and saves the file when node exits.

Usage

Usage is fairly simple:

let ndas = require('node-desktop-app-settings')

let myConfig = ndas('MyProgramName')

myConfig.settings.myOption = 123;

After this, whether from Ctrl-C, sigs, or regular closing of the program, the data file will be saved to USERDATA/settings.json.

API

NDAS(, [options])

require('node-desktop-app-settings') returns a function that is used to create a desired settings.

options

An options object can optionally be passed to the NDAS constructor. The possible options are:

  • saveOn: ["exit", "SIGINT", "unhandledException"]
    • Setting this to an empty array will prevent any sort of saving on program exit.
  • appData: <String>
    • Manually override the default appData location.
  • userData: <String>
    • Manually override the default userData location.
  • settingsPath: <String>
    • Manually override the default settings path.
Example
let ndas = require('node-desktop-app-settings')
let myConfig = ndas('MyProgram')

let myConfig = require('node-desktop-app-settings')('MyProgram')

config.settings

This property is the object that is saved on a call to save() or program exit. If options.saveOn is set to an empty array, this will not automatically by saved.

config.appData

This property returns:

  • MacOS: /Users/user/Library/Preferences
  • Linux: /home/user/.local/share
  • Windows 8+: C:\Users\user\AppData\Roaming
  • Windows XP: C:\Documents and Settings\user\Application Data

NOTE: This uses the APPDATA or HOME environment variables along with some OS detection. See source for details.

config.userData

This property returns the appData path with the first argument passed to ndas().

Example
let myConfig = require('node-desktop-app-settings')('MyProgram')

console.log(myConfig.userData) // returns appData + "/MyProgram"

config.settingsPath

This property returns the corresponding settings.json file path.

Example
let myConfig = require('node-desktop-app-settings')('MyProgram')

console.log(myConfig.settingsPath) // returns userData + "/settings.json"

config.save()

Saves the settings synchronously.

Example
myConfig.save()

config.clear()

Clears the current settings to an empty state.

Example
myConfig.close()