index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 numberTag = '[object Number]';
  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 object-like. A value is object-like if it's not `null`
  20. * and has a `typeof` result of "object".
  21. *
  22. * @static
  23. * @memberOf _
  24. * @category Lang
  25. * @param {*} value The value to check.
  26. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  27. * @example
  28. *
  29. * _.isObjectLike({});
  30. * // => true
  31. *
  32. * _.isObjectLike([1, 2, 3]);
  33. * // => true
  34. *
  35. * _.isObjectLike(_.noop);
  36. * // => false
  37. *
  38. * _.isObjectLike(null);
  39. * // => false
  40. */
  41. function isObjectLike(value) {
  42. return !!value && typeof value == 'object';
  43. }
  44. /**
  45. * Checks if `value` is classified as a `Number` primitive or object.
  46. *
  47. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified
  48. * as numbers, use the `_.isFinite` method.
  49. *
  50. * @static
  51. * @memberOf _
  52. * @category Lang
  53. * @param {*} value The value to check.
  54. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  55. * @example
  56. *
  57. * _.isNumber(3);
  58. * // => true
  59. *
  60. * _.isNumber(Number.MIN_VALUE);
  61. * // => true
  62. *
  63. * _.isNumber(Infinity);
  64. * // => true
  65. *
  66. * _.isNumber('3');
  67. * // => false
  68. */
  69. function isNumber(value) {
  70. return typeof value == 'number' ||
  71. (isObjectLike(value) && objectToString.call(value) == numberTag);
  72. }
  73. module.exports = isNumber;