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

teeny-conf

v6.2.4

Published

A small npm package to handle config files in Node apps. Works fine with Electron and NW.js

Downloads

209

Readme

teeny-conf

Build Status Dependencies

A small npm package to handle one or multiple config files in Node apps. Works well with Electron and NW.js.

All I/O operations are synchronous and write operation are atomic to avoid files corruption.

Saving and reloading are manual, in case you have to handle large files and avoid useless I/O operations.

Why another ?

I didn't find what I wanted on npm, I was needing a conf I could put in a variable, so I could export it without any problem to another scope.

Installation

npm install teeny-conf

Usage

Basic

config.js:

import teeny from 'teeny-conf';

const config = new teeny('config.json'));

conf.set('language', 'en');
conf.save(); // Save is a manual operation

Nested keys

config.js:

import teeny from 'teeny-conf';

const config = new teeny('config.json', {
  some: {
    nested: {
      property: 42
    }
  }
}));

conf.get('some.nested.property'); // -> 42

Using an export

config.js:

import teeny from 'teeny-conf';

const config = new teeny('config.json'));

export default config;

main.js

import config from './config.js';
// now you can use config.set(), config.get(), etc...

API

All key in the docs refer to a usual key or a nested key.

Constructor

new teeny(configPath[, defaultConfig])

Params

configPath String the filename where you want your config / your config already is. If the directory/file does not exist, it will be created automatically.

defaultConfig Object the default configuration to use if the config file does not already exists.

Return value

A teeny object.

teenyconf.get([key])

Get the key value in your config. If no key is specified, returns the whole conf. Please note set does not support sub-keys yet.

Params

key String (optional) name of the key

Return value

any

teenyconf.set(key, value)

Set key to value.

Params

key String name of the key

value any the new value for this key

teenyconf.has(key)

Check if a key exists in the conf.

Params

key String name of the key

Return value

Boolean

teenyconf.delete(key)

Delete key.

Params

key String name of the key

teenyconf.clear()

Clear the conf and set it to empty object.

teenyconf.save([minify])

Save the current config into its associated file.

Params

minify Boolean default to false. Let you minify the content of the file

Return value

none

teenyconf.reload()

Reload the configuration from file. Can be useful if you have multiple instances of teeny-conf using the same file.

Return value

none