5.0.0 • Published 3 years ago

yn v5.0.0

Weekly downloads
7,106,434
License
MIT
Repository
github
Last release
3 years ago

yn

Parse yes/no like values

Useful for validating answers of a CLI prompt.


The following case-insensitive values are recognized:

'y', 'yes', 'true', true, '1', 1, 'n', 'no', 'false', false, '0', 0, 'on', 'off'

Enable lenient mode to gracefully handle typos.

Install

$ npm install yn

Usage

import yn from 'yn';

yn('y');
//=> true

yn('NO');
//=> false

yn(true);
//=> true

yn('abomasum');
//=> undefined

yn('abomasum', {default: false});
//=> false

yn('mo', {lenient: true});
//=> false

Unrecognized values return undefined.

API

yn(input, options?)

input

Type: unknown

The value that should be converted.

options

Type: object

lenient

Type: boolean\ Default: false

Use a key distance-based score to leniently accept typos of yes and no.

default

Type: boolean\ Default: undefined

The default value if no match was found.

ts-nodecuc-gaf@kraken.js/aws@nmh/myanmar-cities-townshipsarchetype-librarybit-bin@backstage/cli@teambit/legacyeasy-select-rntypeorm-model-generator-relations-republishfabric-client-gmqiuguochaohashql-transactionsmart-mfa-serviceriver-sharing@oleksandr_kryvous/dicky-libscriptmailchimp2.0ts-node031@jttechnic/interpreter@dicta-io/storage-junctionstypes-gis@newhorizon-tech/dd-npm-package-templatereact-native-shekhar-bridge-test@oiti/documentoscopy-react-nativequoc-test@aws/aws-codesuite-backend-plugin-for-backstage@botpress/qna@infinitebrahmanuniverse/nolb-yn@prodam/prodam-typesplugin-golden-state-backendparcel-plugin-shebang2luminos-ui-core@anakz/backstage-plugin-dependency-check-backendjawwy-sdkjawwy_gamification_release@everything-registry/sub-chunk-3207@tumido/plugin-demo2-backendreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkg@seatgeek/plugin-awards-backend@seatgeek/plugin-awards-common@seatgeek/plugin-catalog-backend-module-okta@seatgeek/plugin-slack-catalog-backend@dictadata/redshift-junctionreact-native-jawwy_samplefabric-commonfabric-common-bft2fabric-common-extfabric-common-flerpfacilisoccaecatifabric-client-flerpfawaterak-online-paymentfawatrak-online-paymentfc-toolkitfederungfalbit-utilsfastyarnfast-validatorsfhir2fluent.adflow.reactnativesdkfluent.adflow.reactnativesdk-alphafmslfrdrk-js-semaphorefyarnfootprint-nodefrost-sharedfront-end-engineeringfront-and-backelm-upgradeewm-dico-engineevanutilsimagemagick-cloudway-projink-confirm-inputink-confirm-input2iuv-egg-ts-helperidrbt-fabric-commonjamuskalimjeopardyconverteregu-saas-auto-reactedge-boilerplateedge-builderedge-commonebit-binegg-ts-helpergriffin-ui-librarygrandline-cligetghreposgogencygogency-test-2hardhat-teaplughardhat-teaxyzhamza_atmguruwayguruway.jsgamification-integration-newframework_test_library_sixdeeframework_test_library_sixdee_newframework_test_library_sixdee_new_new
5.0.0

3 years ago

4.0.0

4 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.0.0

7 years ago

1.3.0

7 years ago

1.2.0

9 years ago

1.1.0

10 years ago

1.0.0

10 years ago