https://github.com/igorskyflyer/npm-zitto
π€« Zitto - quiet config, loud clarity. A zero-dependency TypeScript/JavaScript helper for merging defaults and options across Node, Deno, Bun, and browsers. π―
https://github.com/igorskyflyer/npm-zitto
back-end config default igor-dimitrijevic igorskyflyer interface javascript js options quiet silent ts typescript zitto
Last synced: 24 days ago
JSON representation
π€« Zitto - quiet config, loud clarity. A zero-dependency TypeScript/JavaScript helper for merging defaults and options across Node, Deno, Bun, and browsers. π―
- Host: GitHub
- URL: https://github.com/igorskyflyer/npm-zitto
- Owner: igorskyflyer
- License: mit
- Created: 2025-09-22T21:03:39.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-09-23T18:57:42.000Z (9 months ago)
- Last Synced: 2025-10-19T18:36:53.601Z (8 months ago)
- Topics: back-end, config, default, igor-dimitrijevic, igorskyflyer, interface, javascript, js, options, quiet, silent, ts, typescript, zitto
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@igorskyflyer/zitto
- Size: 91.8 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Support: SUPPORT.md
Awesome Lists containing this project
README
Zitto
Zero-Dependency Utility β’ Runtime-Safe Options β’ Predictable Defaults β’ Strict Config Control
π€« Zitto - quiet config, loud clarity. A zero-dependency TypeScript/JavaScript helper for merging defaults and options across Node, Deno, Bun, and browsers. π―
## π Table of Contents
- [**Features**](#-features)
- [**Usage**](#-usage)
- [**API**](#-api)
- [**Examples**](#οΈ-examples)
- [**Changelog**](#-changelog)
- [**Support**](#-support)
- [**License**](#-license)
- [**Related**](#-related)
- [**Author**](#-author)
## π€ Features
- β‘ Always returns defaults when no opts passed
- π Merges known keys with defaults
- π« Throws on unknown keys at runtime
- π§© Enforces object shape with TS and runtime
- π Strict variant drops extras automatically
- πͺΆ Tiny zero-dep footprint
- π¦ Predictable results across runtimes
## π΅πΌ Usage
Install it by executing any of the following, depending on your preferred package manager:
```bash
pnpm add @igorskyflyer/zitto
```
```bash
yarn add @igorskyflyer/zitto
```
```bash
npm i @igorskyflyer/zitto
```
## π€ΉπΌ API
### defineOptions
```ts
function defineOptions(
defaults: T,
options?: Partial
): T
```
Merge defaults with optional user options.
`T` - Shape of the `defaults` object
`defaults` - Base configuration with required keys
`options` - Optional overrides, must be a subset of defaults
Returns a new object with defaults and overrides merged.
### defineStrictOptions
```ts
function defineStrictOptions>(
defaults: T,
options?: U
): T
```
Merge defaults with optional user options, dropping unknown keys.
`T` - Shape of the defaults object
`U` - Subset of `T` allowed as overrides
`defaults` - Base configuration with required keys
`options` - Optional overrides, must be a subset of defaults
Throws a `TypeError` if `options` is not an object
Throws an `Error` if `options` contains unknown keys
Returns a new object with defaults and known overrides merged.
## ποΈ Examples
```ts
import { defineOptions, defineStrictOptions } from '@igorskyflyer/zitto'
const opts = defineOptions({ retries: 3, verbose: false }, { verbose: true })
// => { retries: 3, verbose: true }
const opts = defineStrictOptions({ retries: 3, verbose: false }, { retries: 5, extra: 'x' })
// => { retries: 5, verbose: false } // 'extra' is dropped
```
## π Changelog
π Read about the latest changes in the [**CHANGELOG**](https://github.com/igorskyflyer/npm-zitto/blob/main/CHANGELOG.md).
## πͺͺ License
Licensed under the [**MIT license**](https://github.com/igorskyflyer/npm-zitto/blob/main/LICENSE).
## π Support
I work hard for every project, including this one and your support means a lot to me!
Consider buying me a coffee. β
Thank you for supporting my efforts! ππ
## 𧬠Related
[**@igorskyflyer/strip-html**](https://www.npmjs.com/package/@igorskyflyer/strip-html)
> _π₯ Removes HTML code from the given string. Can even extract text-only from the given an HTML string. β¨_
[**@igorskyflyer/is-rootdir**](https://www.npmjs.com/package/@igorskyflyer/is-rootdir)
> _πΌ Checks whether the given path is the root of a drive or filesystem. β_
[**@igorskyflyer/unc-path**](https://www.npmjs.com/package/@igorskyflyer/unc-path)
> _π₯½ Provides ways of parsing UNC paths and checking whether they are valid. π±_
[**@igorskyflyer/regkeys**](https://www.npmjs.com/package/@igorskyflyer/regkeys)
> _π A package for fetching Windows registry keys. π_
[**@igorskyflyer/rawelement**](https://www.npmjs.com/package/@igorskyflyer/rawelement)
> _π― A utility that lets you manipulate HTML elements, their attributes and innerHTML as strings, on the go and then render the modified HTML. Very useful in SSG projects. π€_
## π¨π»βπ» Author
Created by **Igor DimitrijeviΔ ([*@igorskyflyer*](https://github.com/igorskyflyer/))**.