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. π―
- β‘ 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
Install it by executing any of the following, depending on your preferred package manager:
pnpm add @igorskyflyer/zittoyarn add @igorskyflyer/zittonpm i @igorskyflyer/zittofunction defineOptions<T extends object>(
defaults: T,
options?: Partial<T>
): TMerge 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.
function defineStrictOptions<T extends object, U extends Partial<T>>(
defaults: T,
options?: U
): TMerge 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.
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π Read about the latest changes in the CHANGELOG.
Licensed under the MIT license.
Consider buying me a coffee. β
Thank you for supporting my efforts! ππ
π₯ Removes HTML code from the given string. Can even extract text-only from the given an HTML string. β¨
πΌ Checks whether the given path is the root of a drive or filesystem. β
π₯½ Provides ways of parsing UNC paths and checking whether they are valid. π±
π A package for fetching Windows registry keys. π
π― 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. π€
Created by Igor DimitrijeviΔ (@igorskyflyer).