Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

w3i

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

w3i

A NodeJS library for handling configuration

latest
npmnpm
Version
0.3.2
Version published
Maintainers
1
Created
Source

w3i

A typescript library for handling configuration for modules imported by other modules.

This package offers opinionated methods implemented in packages that have configurations.

With this module other packages can easily expose a .set method for setting their parameters.

Implementation

A common implementation is the following:

  • Import and instanciate the Weights class:
// src/config/index.ts
import {Weights, DeepPartial} from 'w3i';

type Config = {
  debug: boolean
}

export const weights = new Weights<Config>({
  debug: false,
});

export const set = (params: DeepPartial<Config>) => {
  weights.set(params);
};
  • Export a set method in order to set the configuration:
// src/main.ts
import {set} from './config/index.js';
export const config = {set};
  • Use the configuration inside the package:
// src/business.ts
import {weights} from './config/index.js';

function main(){
  if(weights.params.debug === true){
    console.log('Debugging...');
  }
}

Unix philosophy

This repo try to follow the Unix philosophy.

Name

w3i stands for weight, like in Atomic weight.

3xp A typescript library for validating objects.

i0n A typescript library for console logging.

r4y A typescript library for managing child processes.

FAQs

Package last updated on 20 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts