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