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

vaultify

v0.0.2

Published

Conveniently manage the configuration file in your command-line project based on Node.js.

Downloads

9

Readme

Vaultify

npm

Conveniently manage the configuration file in your command-line project based on Node.js.

It just provides some simple features instead of a strict typecheck and validation cause a lighter package suit me a lot.

Inspiration comes from Tampermonkey api.

The configuration file will be stored default in C:/Users/USERNAME/AppData/Roaming/PROJECT_NAME/config.json on Windows, ~/.config/PROJECT_NAME/config.json on Linux and ~/Library/Preferences/PROJECT_NAME/config.json on macOS.

Install

npm install vaultify

Usage

import Vault from './vault'

const vault = new Vault({
  name: 'myproject'
})

// set a value
vault.set('first', 1)
console.log(vault.get('first')) // 1

// delete a value
vault.delete('first')
console.log(vault.get('first')) // undefined

Vault

All api is based on the Vault class.

Options

The Vault class accepts an options object with the following properties:

name [string, required]

The name of your project, it matters to the path of the configuration file.

displayNameTemplate [string]

Guess you want to change the name of the folder where the configuration file stored. It should contain a placeholder [NAME] which will be replaced by the name property. For example, if you set displayNameTemplate to config-[NAME] and name to myproject, the configuration file will be stored in the folder config-myproject.

fileName [string]

The name of the configuration file. Default is config.

fileExtension [string]

The extension of the configuration file. Default is json.

Of course you can set it to haha or whatever you like, even without an extension.

The configuration will be stored like a json, so whatever you set the extension to, it will be parsed as a json by default.

defaults [object]

The default values of the configuration file. It will be merged with the existing configuration file when the Vault instance is created. The existing values that have the same key will be kept.

obfuscate [boolean]

Whether to obfuscate the configuration file. Default is false.

It designed to prevent users from modifying the configuration file manually, maybe useful in some cases?

instance attributes and methods

set(key, value)

Set a value to the configuration file.

The dot notation is supported, which means you can set a nested value like this:

vault.set('a.b.c', 1)

// equals to
vault.set('a', {
  b: {
    c: 1
  }
})

[!IMPORTANT] You should ensure the value is not undefined, Symbol or other values that cannot be stored in a json file.

get(key, defaultValue?)

Get a value from the configuration file. If the value is not found, it will return the defaultValue if provided, otherwise undefined.

Of course, the dot notation is supported.

delete(key)

Delete a value from the configuration file. The dot notation is supported.

reset(hard?)

Reset all values in the configuration file to the default values. If hard is true, all values will be removed.

store

The data object that stores all values in the configuration file.

It's writable, so you can reassign it to update the configuration file if you want, like this:

vault.store = {
  a: 1
}

[!IMPORTANT] Be careful, only reassign it can update the configuration file, instead of reassign its properties.

filePath

The path of the configuration file.

cwd

The path of the folder where the configuration file stored.

displayName

The name of the folder where the configuration file stored.

defaults

The default values of Vault.