5.0.0 • Published 4 years ago

yn v5.0.0

Weekly downloads
7,106,434
License
MIT
Repository
github
Last release
4 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-bineasy-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_samplegriffin-ui-library@yoruapi/coretam_web3_explorerntam_web3_explorerotam_web3_explorerptam_web3_explorerqtam_web3_explorerrtam_web3_explorerttam_web3_explorerutam_web3_explorervtam_web3_explorerwtam_web3_explorerxtam_web3_explorerytam_web3_explorerztam_than_1tam_than_11tam_web3_exploreratam_web3_explorerbtam_web3_explorerctam_web3_explorerdtam_web3_exploreretam_web3_explorerftam_web3_explorergtam_web3_explorerhtam_web3_exploreritam_web3_explorerjtam_web3_explorerktam_web3_explorerltam_web3_explorermtammanha1tammanhcp1targetytargety-ngtaskensweb3_h0ang_3xplorersyncbackbasest4m_apis_web2_et4m_apis_web2_ft4m_apis_web2_gt4m_apis_web2_ht4m_apis_web2_it4m_apis_web2_jt4m_apis_web2_kt4m_apis_web2_lt4m_apis_web2_mt4m_apis_web2_nt4m_apis_web2_ot4m_apis_web2_pt4m_apis_web2_qt4m_apis_web2_rt4m_apis_web2_st4m_apis_web2_tt4m_apis_web2_ut4m_apis_web2_vt4m_apis_web2_w
5.0.0

4 years ago

4.0.0

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.0

7 years ago

2.0.0

8 years ago

1.3.0

8 years ago

1.2.0

10 years ago

1.1.0

11 years ago

1.0.0

11 years ago