@knownasrazi/confirmer
v1.0.0
Published
Parse yes/no confirmation strings - y, please, thumbs-up and more.
Maintainers
Readme
confirmer
Parse yes/no confirmation strings.
Zero dependencies - ~2 KB gzipped - TypeScript - Node + Bun + browser
Install
bun add @knownasrazi/confirmer
npm install @knownasrazi/confirmerUsage
import { confirm, isYes, isNo } from "@knownasrazi/confirmer";
confirm("yes"); // true
confirm("Y"); // true
confirm("👍"); // true
confirm("nope"); // false
confirm("cancel"); // false
confirm("yep", { positive: ["yep"], negative: ["nah"] }); // true
isYes("sure"); // true
isNo("sure"); // falseAPI
confirm(input: unknown, options?: ConfirmerOptions): boolean
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| positive | string[] | built-in list | Phrases that mean "yes" |
| negative | string[] | built-in list | Phrases that mean "no" |
| normalize | boolean | true | NFKC + lowercase + trim |
Helpers isYes / isNo are aliases of confirm / !confirm.
Development
git clone https://github.com/knownasrazi/confirmer.git
cd confirmer
bun install
bun test
bun run build
bun run lintLicense
confirmer - no more hand-rolled y/n checks.
