index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. /** `Object#toString` result references. */
  10. var boolTag = '[object Boolean]';
  11. /** Used for built-in method references. */
  12. var objectProto = Object.prototype;
  13. /**
  14. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  15. * of values.
  16. */
  17. var objectToString = objectProto.toString;
  18. /**
  19. * Checks if `value` is classified as a boolean primitive or object.
  20. *
  21. * @static
  22. * @memberOf _
  23. * @category Lang
  24. * @param {*} value The value to check.
  25. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  26. * @example
  27. *
  28. * _.isBoolean(false);
  29. * // => true
  30. *
  31. * _.isBoolean(null);
  32. * // => false
  33. */
  34. function isBoolean(value) {
  35. return value === true || value === false ||
  36. (isObjectLike(value) && objectToString.call(value) == boolTag);
  37. }
  38. /**
  39. * Checks if `value` is object-like. A value is object-like if it's not `null`
  40. * and has a `typeof` result of "object".
  41. *
  42. * @static
  43. * @memberOf _
  44. * @category Lang
  45. * @param {*} value The value to check.
  46. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  47. * @example
  48. *
  49. * _.isObjectLike({});
  50. * // => true
  51. *
  52. * _.isObjectLike([1, 2, 3]);
  53. * // => true
  54. *
  55. * _.isObjectLike(_.noop);
  56. * // => false
  57. *
  58. * _.isObjectLike(null);
  59. * // => false
  60. */
  61. function isObjectLike(value) {
  62. return !!value && typeof value == 'object';
  63. }
  64. module.exports = isBoolean;