{"id":13454094,"url":"https://github.com/sindresorhus/yn","last_synced_at":"2025-04-14T20:52:46.642Z","repository":{"id":19457482,"uuid":"22701918","full_name":"sindresorhus/yn","owner":"sindresorhus","description":"Parse yes/no like values","archived":false,"fork":false,"pushed_at":"2022-07-08T13:20:11.000Z","size":31,"stargazers_count":268,"open_issues_count":1,"forks_count":20,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-24T13:03:10.965Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-08-06T23:42:30.000Z","updated_at":"2025-03-22T08:16:55.000Z","dependencies_parsed_at":"2022-07-12T15:15:02.963Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/yn","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fyn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fyn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fyn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fyn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/yn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245327491,"owners_count":20597235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:00:50.854Z","updated_at":"2025-03-31T14:07:54.029Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","包","Command-line utilities","目录","Framework agnostic packages"],"sub_categories":["Command-line utilities","命令行工具","Node","命令行实用工具"],"readme":"# yn\n\n\u003e Parse yes/no like values\n\nUseful for validating answers of a CLI prompt.\n\n---\n\nThe following case-insensitive values are recognized:\n\n```js\n'y', 'yes', 'true', true, '1', 1, 'n', 'no', 'false', false, '0', 0, 'on', 'off'\n```\n\n*Enable lenient mode to gracefully handle typos.*\n\n## Install\n\n```\n$ npm install yn\n```\n\n## Usage\n\n```js\nimport yn from 'yn';\n\nyn('y');\n//=\u003e true\n\nyn('NO');\n//=\u003e false\n\nyn(true);\n//=\u003e true\n\nyn('abomasum');\n//=\u003e undefined\n\nyn('abomasum', {default: false});\n//=\u003e false\n\nyn('mo', {lenient: true});\n//=\u003e false\n```\n\nUnrecognized values return `undefined`.\n\n## API\n\n### yn(input, options?)\n\n#### input\n\nType: `unknown`\n\nThe value that should be converted.\n\n#### options\n\nType: `object`\n\n##### lenient\n\nType: `boolean`\\\nDefault: `false`\n\nUse a key distance-based score to leniently accept typos of `yes` and `no`.\n\n##### default\n\nType: `boolean`\\\nDefault: `undefined`\n\nThe default value if no match was found.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fyn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fyn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fyn/lists"}