Нет описания

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * lodash 3.0.9 (Custom Build) <https://lodash.com/>
  3. * Build: `lodash modern modularize exports="npm" -o ./`
  4. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  7. * Available under MIT license <https://lodash.com/license>
  8. */
  9. /** Used to detect unsigned integer values. */
  10. var reIsUint = /^\d+$/;
  11. /**
  12. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  13. * of an array-like value.
  14. */
  15. var MAX_SAFE_INTEGER = 9007199254740991;
  16. /**
  17. * The base implementation of `_.property` without support for deep paths.
  18. *
  19. * @private
  20. * @param {string} key The key of the property to get.
  21. * @returns {Function} Returns the new function.
  22. */
  23. function baseProperty(key) {
  24. return function(object) {
  25. return object == null ? undefined : object[key];
  26. };
  27. }
  28. /**
  29. * Gets the "length" property value of `object`.
  30. *
  31. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  32. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  33. *
  34. * @private
  35. * @param {Object} object The object to query.
  36. * @returns {*} Returns the "length" value.
  37. */
  38. var getLength = baseProperty('length');
  39. /**
  40. * Checks if `value` is array-like.
  41. *
  42. * @private
  43. * @param {*} value The value to check.
  44. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  45. */
  46. function isArrayLike(value) {
  47. return value != null && isLength(getLength(value));
  48. }
  49. /**
  50. * Checks if `value` is a valid array-like index.
  51. *
  52. * @private
  53. * @param {*} value The value to check.
  54. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  55. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  56. */
  57. function isIndex(value, length) {
  58. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  59. length = length == null ? MAX_SAFE_INTEGER : length;
  60. return value > -1 && value % 1 == 0 && value < length;
  61. }
  62. /**
  63. * Checks if the provided arguments are from an iteratee call.
  64. *
  65. * @private
  66. * @param {*} value The potential iteratee value argument.
  67. * @param {*} index The potential iteratee index or key argument.
  68. * @param {*} object The potential iteratee object argument.
  69. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  70. */
  71. function isIterateeCall(value, index, object) {
  72. if (!isObject(object)) {
  73. return false;
  74. }
  75. var type = typeof index;
  76. if (type == 'number'
  77. ? (isArrayLike(object) && isIndex(index, object.length))
  78. : (type == 'string' && index in object)) {
  79. var other = object[index];
  80. return value === value ? (value === other) : (other !== other);
  81. }
  82. return false;
  83. }
  84. /**
  85. * Checks if `value` is a valid array-like length.
  86. *
  87. * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
  88. *
  89. * @private
  90. * @param {*} value The value to check.
  91. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  92. */
  93. function isLength(value) {
  94. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  95. }
  96. /**
  97. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  98. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  99. *
  100. * @static
  101. * @memberOf _
  102. * @category Lang
  103. * @param {*} value The value to check.
  104. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  105. * @example
  106. *
  107. * _.isObject({});
  108. * // => true
  109. *
  110. * _.isObject([1, 2, 3]);
  111. * // => true
  112. *
  113. * _.isObject(1);
  114. * // => false
  115. */
  116. function isObject(value) {
  117. // Avoid a V8 JIT bug in Chrome 19-20.
  118. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  119. var type = typeof value;
  120. return !!value && (type == 'object' || type == 'function');
  121. }
  122. module.exports = isIterateeCall;