index.js
 1  /**
 2   * lodash 3.0.3 (Custom Build) <https://lodash.com/>
 3   * Build: `lodash modularize exports="npm" -o ./`
 4   * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
 5   * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
 6   * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
 7   * Available under MIT license <https://lodash.com/license>
 8   */
 9  
10  /** `Object#toString` result references. */
11  var boolTag = '[object Boolean]';
12  
13  /** Used for built-in method references. */
14  var objectProto = Object.prototype;
15  
16  /**
17   * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
18   * of values.
19   */
20  var objectToString = objectProto.toString;
21  
22  /**
23   * Checks if `value` is classified as a boolean primitive or object.
24   *
25   * @static
26   * @memberOf _
27   * @category Lang
28   * @param {*} value The value to check.
29   * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
30   * @example
31   *
32   * _.isBoolean(false);
33   * // => true
34   *
35   * _.isBoolean(null);
36   * // => false
37   */
38  function isBoolean(value) {
39    return value === true || value === false ||
40      (isObjectLike(value) && objectToString.call(value) == boolTag);
41  }
42  
43  /**
44   * Checks if `value` is object-like. A value is object-like if it's not `null`
45   * and has a `typeof` result of "object".
46   *
47   * @static
48   * @memberOf _
49   * @category Lang
50   * @param {*} value The value to check.
51   * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
52   * @example
53   *
54   * _.isObjectLike({});
55   * // => true
56   *
57   * _.isObjectLike([1, 2, 3]);
58   * // => true
59   *
60   * _.isObjectLike(_.noop);
61   * // => false
62   *
63   * _.isObjectLike(null);
64   * // => false
65   */
66  function isObjectLike(value) {
67    return !!value && typeof value == 'object';
68  }
69  
70  module.exports = isBoolean;