# w3i

> A NodeJS library for handling configuration

Latest version **0.3.2** (published 2023-11-20) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install w3i
pnpm add w3i
yarn add w3i
bun add w3i
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2023-11-20 |
| First published | 2023-11-19 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | x71c9 |
| Maintainers | x71c9 |

## Links

- npm: https://www.npmjs.com/package/w3i
- Repository: git@github.com:x71c9/w3i
- npm.io page: https://npm.io/package/w3i

## Recent versions

- 0.3.2 (latest) — 2023-11-20
- 0.3.1 — 2023-11-20
- 0.3.0 — 2023-11-20
- 0.2.0 — 2023-11-20
- 0.1.0 — 2023-11-20
- 0.0.2 — 2023-11-19

## README

# 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:
```typescript
// 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:
```typescript
// src/main.ts
import {set} from './config/index.js';
export const config = {set};
```

- Use the configuration inside the package:
```typescript
// 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](https://en.wikipedia.org/wiki/Unix_philosophy).

## Name

`w3i` stands for weight, like in
[Atomic weight](https://en.wikipedia.org/wiki/Standard_atomic_weight).

## Other related repositories

[`3xp`](https://www.npmjs.com/package/3xp) A typescript library for validating objects.

[`i0n`](https://www.npmjs.com/package/i0n) A typescript library for console logging.

[`r4y`](https://www.npmjs.com/package/r4y) A typescript library for managing child processes.

---
_Source: https://npm.io/package/w3i · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
