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@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_samplegriffin-ui-library@yoruapi/core@section.io/sectionctl-helper@stigg/sidecar@steedos/steedos-model-generator@steedos/cli@stemn/yarn@stellarbeat/js-stellar-node-connector@philips-software/backstage-plugin-upptime-backend@thinxviewx/core-rn@thismr/bitmindtest-core@strawberryjam/plugin-randomgreeting-backend@suinesia/suinesiaswap-sdk@suvayu/converter@sudophunk/fulido@taingo97/react-native-awesome-module@taingo97/react-native-bluetooth-xprinter@taingo97/react-native-generate-key-rsa@taingo97/react-native-key-rsa@taingo97/react-native-print-xprinter@taingo97/react-native-rsa-expo@taingo97/react-native-sunmi-printer@tduniec/backstage-plugin-time-saver-backend@teambit/lanes@telereso/backstage-plugin-custom-entities-backend@snooful/orangered-parser@serouslabs/joi-to-zod-codemod@slimio/cli@solace-labs/plugin-ep-devp-try-me-backend@solace-labs/backstage-plugin-ep-devp-consumer-products-backend@solace-labs/backstage-plugin-ep-devp-event-api-products-backend@solace-labs/backstage-plugin-ep-devp-events-backend@solace-labs/backstage-plugin-ep-devp-manage-apps-backend@solace-labs/backstage-plugin-ep-devp-search-backend@solace-labs/backstage-plugin-ep-devp-applications-backend@solace-labs/backstage-plugin-ep-devp-auth-backend@solace-labs/backstage-plugin-ep-devp-backend@solace-labs/backstage-plugin-ep-devp-consumer-apps-backend@solace-labs/backstage-plugin-ep-devp-vault-backend@solace-labs/backstage-plugin-ep-devp-vault-backend-common@solace-labs/plugin-ep-devp-approvals-backend@solace-labs/plugin-ep-devp-fetch-zip-backend@solace-labs/plugin-ep-devp-git-webhook-plugin-backend@solace-labs/plugin-ep-devp-gitlab-file-fetch-backend@solo.io/platform-portal-backstage-plugin-backend@soodam.re/env-utils@snailcode.net/basic-stat@sidghimire/react-native-mapbox-navigation@slallemand/aws-proton-plugin-backend@shlomya/throttler@sephriot/react-native-persistable-uri@skedulr/nebula-ui-library@skillswaveca/nova-shared-libraries@spnez/bcrypt
5.0.0

3 years ago

4.0.0

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.0

6 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