react / wstein / node_modules / jest-cli / node_modules / lodash.template / node_modules / lodash._isiterateecall / index.js
80677 views/**1* lodash 3.0.9 (Custom Build) <https://lodash.com/>2* Build: `lodash modern modularize exports="npm" -o ./`3* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>4* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>5* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors6* Available under MIT license <https://lodash.com/license>7*/89/** Used to detect unsigned integer values. */10var reIsUint = /^\d+$/;1112/**13* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)14* of an array-like value.15*/16var MAX_SAFE_INTEGER = 9007199254740991;1718/**19* The base implementation of `_.property` without support for deep paths.20*21* @private22* @param {string} key The key of the property to get.23* @returns {Function} Returns the new function.24*/25function baseProperty(key) {26return function(object) {27return object == null ? undefined : object[key];28};29}3031/**32* Gets the "length" property value of `object`.33*34* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)35* that affects Safari on at least iOS 8.1-8.3 ARM64.36*37* @private38* @param {Object} object The object to query.39* @returns {*} Returns the "length" value.40*/41var getLength = baseProperty('length');4243/**44* Checks if `value` is array-like.45*46* @private47* @param {*} value The value to check.48* @returns {boolean} Returns `true` if `value` is array-like, else `false`.49*/50function isArrayLike(value) {51return value != null && isLength(getLength(value));52}5354/**55* Checks if `value` is a valid array-like index.56*57* @private58* @param {*} value The value to check.59* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.60* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.61*/62function isIndex(value, length) {63value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;64length = length == null ? MAX_SAFE_INTEGER : length;65return value > -1 && value % 1 == 0 && value < length;66}6768/**69* Checks if the provided arguments are from an iteratee call.70*71* @private72* @param {*} value The potential iteratee value argument.73* @param {*} index The potential iteratee index or key argument.74* @param {*} object The potential iteratee object argument.75* @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.76*/77function isIterateeCall(value, index, object) {78if (!isObject(object)) {79return false;80}81var type = typeof index;82if (type == 'number'83? (isArrayLike(object) && isIndex(index, object.length))84: (type == 'string' && index in object)) {85var other = object[index];86return value === value ? (value === other) : (other !== other);87}88return false;89}9091/**92* Checks if `value` is a valid array-like length.93*94* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).95*96* @private97* @param {*} value The value to check.98* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.99*/100function isLength(value) {101return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;102}103104/**105* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.106* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)107*108* @static109* @memberOf _110* @category Lang111* @param {*} value The value to check.112* @returns {boolean} Returns `true` if `value` is an object, else `false`.113* @example114*115* _.isObject({});116* // => true117*118* _.isObject([1, 2, 3]);119* // => true120*121* _.isObject(1);122* // => false123*/124function isObject(value) {125// Avoid a V8 JIT bug in Chrome 19-20.126// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.127var type = typeof value;128return !!value && (type == 'object' || type == 'function');129}130131module.exports = isIterateeCall;132133134