mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
merging mrjjwright's isBoolean, with tests, docs, and credit
This commit is contained in:
1
README
1
README
@@ -28,3 +28,4 @@ Many thanks to our contributors:
|
||||
Jed Schmidt
|
||||
Noah Sloan
|
||||
Luke Sutton
|
||||
John Wright
|
||||
|
||||
12
index.html
12
index.html
@@ -162,7 +162,7 @@
|
||||
<a href="#functions">functions</a>, <a href="#extend">extend</a>, <a href="#clone">clone</a>, <a href="#tap">tap</a>,
|
||||
<a href="#isEqual">isEqual</a>, <a href="#isEmpty">isEmpty</a>, <a href="#isElement">isElement</a>,
|
||||
<a href="#isArray">isArray</a>, <a href="#isArguments">isArguments</a>, <a href="#isFunction">isFunction</a>, <a href="#isString">isString</a>,
|
||||
<a href="#isNumber">isNumber</a>, <a href="#isDate">isDate</a>, <a href="#isRegExp">isRegExp</a>
|
||||
<a href="#isNumber">isNumber</a>, <a href="#isBoolean">isBoolean</a>, <a href="#isDate">isDate</a>, <a href="#isRegExp">isRegExp</a>
|
||||
<a href="#isNaN">isNaN</a>, <a href="#isNull">isNull</a>,
|
||||
<a href="#isUndefined">isUndefined</a>
|
||||
</span>
|
||||
@@ -874,6 +874,16 @@ _.isFunction("moe");
|
||||
<pre>
|
||||
_.isNumber(8.4 * 5);
|
||||
=> true
|
||||
</pre>
|
||||
|
||||
<p id="isBoolean">
|
||||
<b class="header">isBoolean</b><code>_.isBoolean(object)</code>
|
||||
<br />
|
||||
Returns <i>true</i> if <b>object</b> is either <i>true</i> or <i>false</i>.
|
||||
</p>
|
||||
<pre>
|
||||
_.isBoolean(null);
|
||||
=> false
|
||||
</pre>
|
||||
|
||||
<p id="isDate">
|
||||
|
||||
@@ -14,7 +14,7 @@ $(document).ready(function() {
|
||||
var expected = ["all", "any", "bind", "bindAll", "breakLoop", "clone", "compact",
|
||||
"compose","defer", "delay", "detect", "each", "every", "extend", "filter", "first",
|
||||
"flatten", "foldl", "foldr", "forEach", "functions", "head", "identity", "include",
|
||||
"indexOf", "inject", "intersect", "invoke", "isArguments", "isArray", "isDate", "isElement", "isEmpty", "isEqual",
|
||||
"indexOf", "inject", "intersect", "invoke", "isArguments", "isArray", "isBoolean", "isDate", "isElement", "isEmpty", "isEqual",
|
||||
"isFunction", "isNaN", "isNull", "isNumber", "isRegExp", "isString", "isUndefined", "keys", "last", "lastIndexOf", "map", "max",
|
||||
"methods", "min", "mixin", "noConflict", "pluck", "range", "reduce", "reduceRight", "reject", "rest", "select",
|
||||
"size", "some", "sortBy", "sortedIndex", "tail", "tap", "template", "times", "toArray", "uniq",
|
||||
@@ -136,6 +136,8 @@ $(document).ready(function() {
|
||||
ok(!_.isBoolean("true"), 'the string "true" is not a boolean');
|
||||
ok(!_.isBoolean(arguments), 'the arguments object is not a boolean');
|
||||
ok(!_.isBoolean(undefined), 'undefined is not a boolean');
|
||||
ok(!_.isBoolean(NaN), 'NaN is not a boolean');
|
||||
ok(!_.isBoolean(null), 'null is not a boolean');
|
||||
ok(_.isBoolean(true), 'but true is');
|
||||
ok(_.isBoolean(false), 'and so is false');
|
||||
ok(_.isBoolean(iBoolean), 'even from another frame');
|
||||
|
||||
@@ -527,7 +527,7 @@
|
||||
|
||||
// Is a given value a boolean?
|
||||
_.isBoolean = function(obj) {
|
||||
return (toString.call(obj) === '[object Boolean]');
|
||||
return obj === true || obj === false;
|
||||
};
|
||||
|
||||
// Is a given value a date?
|
||||
|
||||
Reference in New Issue
Block a user