Parse yes/no like values with lenient mode for handling typos, useful for CLI prompts and configuration.
yn is a JavaScript library that parses yes/no like values from various input types including strings, booleans, and numbers. It solves the problem of consistently interpreting boolean-like user input in CLI tools, configuration parsing, and other applications where human-readable yes/no values need conversion to proper booleans.
JavaScript/TypeScript developers building CLI tools, configuration systems, or applications that need to parse user-provided boolean values.
Developers choose yn for its simplicity, lenient mode that handles typos gracefully, and consistent behavior across different input formats without needing to write custom parsing logic.
Parse yes/no like values
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Lenient mode uses key distance-based scoring to accept typos like 'mo' for 'no', making it robust for error-prone user input in CLIs.
Recognizes a wide range of case-insensitive values including 'y', 'yes', 'true', '1', and negatives, simplifying parsing without custom logic.
Allows setting a default boolean for unrecognized inputs, preventing undefined returns and improving error handling in configurations.
Fully typed API with clear option definitions, ensuring type safety and easy integration in TypeScript projects.
Only handles yes/no like values from a fixed list; cannot parse custom strings or complex boolean expressions, requiring additional libraries for broader use.
For trivial cases with guaranteed input formats, using a library might be overkill compared to simple checks like `input === 'yes'`, adding unnecessary bloat.
Lacks built-in validation hooks, async support, or integration with common frameworks, limiting its utility in complex application workflows.