Travis build: 674 [ci skip]

This commit is contained in:
Travis CI
2017-12-30 17:26:00 +00:00
parent b190263f08
commit 17eee378c8
3 changed files with 39 additions and 5 deletions

View File

@ -251,6 +251,7 @@
* [`toDecimalMark`](#todecimalmark)
* [`toOrdinalSuffix`](#toordinalsuffix)
* [`validateNumber`](#validatenumber)
* [`yesNo`](#yesno)
</details>
@ -4202,6 +4203,33 @@ validateNumber('10'); // true
<br>[⬆ Back to top](#table-of-contents)
### yesNo
Returns `true` if the string is `y`/`yes` or `false` if the string is `n`/`no`.
Use `RegExp.test()` to check if the string evaluates to `y/yes` or `n/no`.
Omit the second argument, `def` to set the default answer as `no`.
```js
const yesNo = (val, def = false) =>
/^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def;
```
<details>
<summary>Examples</summary>
```js
yesNo('Y'); // true
yesNo('yes'); // true
yesNo('No'); // false
yesNo('Foo', true); // true
```
</details>
<br>[⬆ Back to top](#table-of-contents)
## Credits
*Icons made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [www.flaticon.com](https://www.flaticon.com/) is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/).*

File diff suppressed because one or more lines are too long

View File

@ -11,8 +11,8 @@ const yesNo = (val, def = false) =>
```
```js
yesNo('Y') // true
yesNo('yes') // true
yesNo('No') // false
yesNo('Foo', true) // true
yesNo('Y'); // true
yesNo('yes'); // true
yesNo('No'); // false
yesNo('Foo', true); // true
```