Comparing version 1.0.0 to 1.1.0
'use strict'; | ||
module.exports = function (val) { | ||
var lenient = require('./lenient'); | ||
module.exports = function (val, opts) { | ||
val = String(val).trim(); | ||
opts = opts || {}; | ||
@@ -13,3 +16,7 @@ if (/^(?:y|yes|true)$/i.test(val)) { | ||
if (opts.lenient === true) { | ||
return lenient(val); | ||
} | ||
return null; | ||
}; |
{ | ||
"name": "yn", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Parse yes/no like values", | ||
@@ -19,3 +19,4 @@ "license": "MIT", | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"lenient.js" | ||
], | ||
@@ -33,7 +34,8 @@ "keywords": [ | ||
"false", | ||
"parse" | ||
"parse", | ||
"lenient" | ||
], | ||
"devDependencies": { | ||
"ava": "0.0.3" | ||
"ava": "0.0.4" | ||
} | ||
} |
@@ -15,3 +15,5 @@ # yn [![Build Status](https://travis-ci.org/sindresorhus/yn.svg?branch=master)](https://travis-ci.org/sindresorhus/yn) | ||
*Enable lenient mode to gracefully handle typos.* | ||
## Install | ||
@@ -38,7 +40,12 @@ | ||
yn('unicorn'); | ||
yn('abomasum'); | ||
//=> null | ||
// lenient mode will use a key distance-based score | ||
// to leniently accept typos of "yes" and "no" | ||
yn('mo', {lenient: true}); | ||
//=> false | ||
``` | ||
Unrecognized values returns `null`. | ||
Unrecognized values return `null`. | ||
@@ -45,0 +52,0 @@ |
3024
4
106
54