forIn-9b83dde4.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.82
  5. */
  6. import { i as isObject, b as baseGetTag, c as isObjectLike, r as root, f as freeGlobal } from './debounce-c4df98cc.js';
  7. /**
  8. * Checks if `value` is classified as an `Array` object.
  9. *
  10. * @static
  11. * @memberOf _
  12. * @since 0.1.0
  13. * @category Lang
  14. * @param {*} value The value to check.
  15. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  16. * @example
  17. *
  18. * _.isArray([1, 2, 3]);
  19. * // => true
  20. *
  21. * _.isArray(document.body.children);
  22. * // => false
  23. *
  24. * _.isArray('abc');
  25. * // => false
  26. *
  27. * _.isArray(_.noop);
  28. * // => false
  29. */
  30. var isArray = Array.isArray;
  31. /**
  32. * This method returns the first argument it receives.
  33. *
  34. * @static
  35. * @since 0.1.0
  36. * @memberOf _
  37. * @category Util
  38. * @param {*} value Any value.
  39. * @returns {*} Returns `value`.
  40. * @example
  41. *
  42. * var object = { 'a': 1 };
  43. *
  44. * console.log(_.identity(object) === object);
  45. * // => true
  46. */
  47. function identity(value) {
  48. return value;
  49. }
  50. /** `Object#toString` result references. */
  51. var asyncTag = '[object AsyncFunction]',
  52. funcTag$1 = '[object Function]',
  53. genTag = '[object GeneratorFunction]',
  54. proxyTag = '[object Proxy]';
  55. /**
  56. * Checks if `value` is classified as a `Function` object.
  57. *
  58. * @static
  59. * @memberOf _
  60. * @since 0.1.0
  61. * @category Lang
  62. * @param {*} value The value to check.
  63. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  64. * @example
  65. *
  66. * _.isFunction(_);
  67. * // => true
  68. *
  69. * _.isFunction(/abc/);
  70. * // => false
  71. */
  72. function isFunction(value) {
  73. if (!isObject(value)) {
  74. return false;
  75. }
  76. // The use of `Object#toString` avoids issues with the `typeof` operator
  77. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  78. var tag = baseGetTag(value);
  79. return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
  80. }
  81. /** Used as references for various `Number` constants. */
  82. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  83. /** Used to detect unsigned integer values. */
  84. var reIsUint = /^(?:0|[1-9]\d*)$/;
  85. /**
  86. * Checks if `value` is a valid array-like index.
  87. *
  88. * @private
  89. * @param {*} value The value to check.
  90. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  91. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  92. */
  93. function isIndex(value, length) {
  94. var type = typeof value;
  95. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  96. return !!length &&
  97. (type == 'number' ||
  98. (type != 'symbol' && reIsUint.test(value))) &&
  99. (value > -1 && value % 1 == 0 && value < length);
  100. }
  101. /** Used as references for various `Number` constants. */
  102. var MAX_SAFE_INTEGER = 9007199254740991;
  103. /**
  104. * Checks if `value` is a valid array-like length.
  105. *
  106. * **Note:** This method is loosely based on
  107. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  108. *
  109. * @static
  110. * @memberOf _
  111. * @since 4.0.0
  112. * @category Lang
  113. * @param {*} value The value to check.
  114. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  115. * @example
  116. *
  117. * _.isLength(3);
  118. * // => true
  119. *
  120. * _.isLength(Number.MIN_VALUE);
  121. * // => false
  122. *
  123. * _.isLength(Infinity);
  124. * // => false
  125. *
  126. * _.isLength('3');
  127. * // => false
  128. */
  129. function isLength(value) {
  130. return typeof value == 'number' &&
  131. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  132. }
  133. /**
  134. * Checks if `value` is array-like. A value is considered array-like if it's
  135. * not a function and has a `value.length` that's an integer greater than or
  136. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  137. *
  138. * @static
  139. * @memberOf _
  140. * @since 4.0.0
  141. * @category Lang
  142. * @param {*} value The value to check.
  143. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  144. * @example
  145. *
  146. * _.isArrayLike([1, 2, 3]);
  147. * // => true
  148. *
  149. * _.isArrayLike(document.body.children);
  150. * // => true
  151. *
  152. * _.isArrayLike('abc');
  153. * // => true
  154. *
  155. * _.isArrayLike(_.noop);
  156. * // => false
  157. */
  158. function isArrayLike(value) {
  159. return value != null && isLength(value.length) && !isFunction(value);
  160. }
  161. /** Used for built-in method references. */
  162. var objectProto$3 = Object.prototype;
  163. /**
  164. * Checks if `value` is likely a prototype object.
  165. *
  166. * @private
  167. * @param {*} value The value to check.
  168. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  169. */
  170. function isPrototype(value) {
  171. var Ctor = value && value.constructor,
  172. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$3;
  173. return value === proto;
  174. }
  175. /**
  176. * The base implementation of `_.times` without support for iteratee shorthands
  177. * or max array length checks.
  178. *
  179. * @private
  180. * @param {number} n The number of times to invoke `iteratee`.
  181. * @param {Function} iteratee The function invoked per iteration.
  182. * @returns {Array} Returns the array of results.
  183. */
  184. function baseTimes(n, iteratee) {
  185. var index = -1,
  186. result = Array(n);
  187. while (++index < n) {
  188. result[index] = iteratee(index);
  189. }
  190. return result;
  191. }
  192. /** `Object#toString` result references. */
  193. var argsTag$1 = '[object Arguments]';
  194. /**
  195. * The base implementation of `_.isArguments`.
  196. *
  197. * @private
  198. * @param {*} value The value to check.
  199. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  200. */
  201. function baseIsArguments(value) {
  202. return isObjectLike(value) && baseGetTag(value) == argsTag$1;
  203. }
  204. /** Used for built-in method references. */
  205. var objectProto$2 = Object.prototype;
  206. /** Used to check objects for own properties. */
  207. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  208. /** Built-in value references. */
  209. var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
  210. /**
  211. * Checks if `value` is likely an `arguments` object.
  212. *
  213. * @static
  214. * @memberOf _
  215. * @since 0.1.0
  216. * @category Lang
  217. * @param {*} value The value to check.
  218. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  219. * else `false`.
  220. * @example
  221. *
  222. * _.isArguments(function() { return arguments; }());
  223. * // => true
  224. *
  225. * _.isArguments([1, 2, 3]);
  226. * // => false
  227. */
  228. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  229. return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
  230. !propertyIsEnumerable.call(value, 'callee');
  231. };
  232. /**
  233. * This method returns `false`.
  234. *
  235. * @static
  236. * @memberOf _
  237. * @since 4.13.0
  238. * @category Util
  239. * @returns {boolean} Returns `false`.
  240. * @example
  241. *
  242. * _.times(2, _.stubFalse);
  243. * // => [false, false]
  244. */
  245. function stubFalse() {
  246. return false;
  247. }
  248. /** Detect free variable `exports`. */
  249. var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
  250. /** Detect free variable `module`. */
  251. var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
  252. /** Detect the popular CommonJS extension `module.exports`. */
  253. var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
  254. /** Built-in value references. */
  255. var Buffer = moduleExports$1 ? root.Buffer : undefined;
  256. /* Built-in method references for those with the same name as other `lodash` methods. */
  257. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  258. /**
  259. * Checks if `value` is a buffer.
  260. *
  261. * @static
  262. * @memberOf _
  263. * @since 4.3.0
  264. * @category Lang
  265. * @param {*} value The value to check.
  266. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  267. * @example
  268. *
  269. * _.isBuffer(new Buffer(2));
  270. * // => true
  271. *
  272. * _.isBuffer(new Uint8Array(2));
  273. * // => false
  274. */
  275. var isBuffer = nativeIsBuffer || stubFalse;
  276. /** `Object#toString` result references. */
  277. var argsTag = '[object Arguments]',
  278. arrayTag = '[object Array]',
  279. boolTag = '[object Boolean]',
  280. dateTag = '[object Date]',
  281. errorTag = '[object Error]',
  282. funcTag = '[object Function]',
  283. mapTag = '[object Map]',
  284. numberTag = '[object Number]',
  285. objectTag = '[object Object]',
  286. regexpTag = '[object RegExp]',
  287. setTag = '[object Set]',
  288. stringTag = '[object String]',
  289. weakMapTag = '[object WeakMap]';
  290. var arrayBufferTag = '[object ArrayBuffer]',
  291. dataViewTag = '[object DataView]',
  292. float32Tag = '[object Float32Array]',
  293. float64Tag = '[object Float64Array]',
  294. int8Tag = '[object Int8Array]',
  295. int16Tag = '[object Int16Array]',
  296. int32Tag = '[object Int32Array]',
  297. uint8Tag = '[object Uint8Array]',
  298. uint8ClampedTag = '[object Uint8ClampedArray]',
  299. uint16Tag = '[object Uint16Array]',
  300. uint32Tag = '[object Uint32Array]';
  301. /** Used to identify `toStringTag` values of typed arrays. */
  302. var typedArrayTags = {};
  303. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  304. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  305. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  306. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  307. typedArrayTags[uint32Tag] = true;
  308. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  309. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  310. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  311. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  312. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  313. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  314. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  315. typedArrayTags[weakMapTag] = false;
  316. /**
  317. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  318. *
  319. * @private
  320. * @param {*} value The value to check.
  321. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  322. */
  323. function baseIsTypedArray(value) {
  324. return isObjectLike(value) &&
  325. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  326. }
  327. /**
  328. * The base implementation of `_.unary` without support for storing metadata.
  329. *
  330. * @private
  331. * @param {Function} func The function to cap arguments for.
  332. * @returns {Function} Returns the new capped function.
  333. */
  334. function baseUnary(func) {
  335. return function(value) {
  336. return func(value);
  337. };
  338. }
  339. /** Detect free variable `exports`. */
  340. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  341. /** Detect free variable `module`. */
  342. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  343. /** Detect the popular CommonJS extension `module.exports`. */
  344. var moduleExports = freeModule && freeModule.exports === freeExports;
  345. /** Detect free variable `process` from Node.js. */
  346. var freeProcess = moduleExports && freeGlobal.process;
  347. /** Used to access faster Node.js helpers. */
  348. var nodeUtil = (function() {
  349. try {
  350. // Use `util.types` for Node.js 10+.
  351. var types = freeModule && freeModule.require && freeModule.require('util').types;
  352. if (types) {
  353. return types;
  354. }
  355. // Legacy `process.binding('util')` for Node.js < 10.
  356. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  357. } catch (e) {}
  358. }());
  359. /* Node.js helper references. */
  360. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  361. /**
  362. * Checks if `value` is classified as a typed array.
  363. *
  364. * @static
  365. * @memberOf _
  366. * @since 3.0.0
  367. * @category Lang
  368. * @param {*} value The value to check.
  369. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  370. * @example
  371. *
  372. * _.isTypedArray(new Uint8Array);
  373. * // => true
  374. *
  375. * _.isTypedArray([]);
  376. * // => false
  377. */
  378. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  379. /** Used for built-in method references. */
  380. var objectProto$1 = Object.prototype;
  381. /** Used to check objects for own properties. */
  382. var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
  383. /**
  384. * Creates an array of the enumerable property names of the array-like `value`.
  385. *
  386. * @private
  387. * @param {*} value The value to query.
  388. * @param {boolean} inherited Specify returning inherited property names.
  389. * @returns {Array} Returns the array of property names.
  390. */
  391. function arrayLikeKeys(value, inherited) {
  392. var isArr = isArray(value),
  393. isArg = !isArr && isArguments(value),
  394. isBuff = !isArr && !isArg && isBuffer(value),
  395. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  396. skipIndexes = isArr || isArg || isBuff || isType,
  397. result = skipIndexes ? baseTimes(value.length, String) : [],
  398. length = result.length;
  399. for (var key in value) {
  400. if ((inherited || hasOwnProperty$1.call(value, key)) &&
  401. !(skipIndexes && (
  402. // Safari 9 has enumerable `arguments.length` in strict mode.
  403. key == 'length' ||
  404. // Node.js 0.10 has enumerable non-index properties on buffers.
  405. (isBuff && (key == 'offset' || key == 'parent')) ||
  406. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  407. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  408. // Skip index properties.
  409. isIndex(key, length)
  410. ))) {
  411. result.push(key);
  412. }
  413. }
  414. return result;
  415. }
  416. /**
  417. * This function is like
  418. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  419. * except that it includes inherited enumerable properties.
  420. *
  421. * @private
  422. * @param {Object} object The object to query.
  423. * @returns {Array} Returns the array of property names.
  424. */
  425. function nativeKeysIn(object) {
  426. var result = [];
  427. if (object != null) {
  428. for (var key in Object(object)) {
  429. result.push(key);
  430. }
  431. }
  432. return result;
  433. }
  434. /** Used for built-in method references. */
  435. var objectProto = Object.prototype;
  436. /** Used to check objects for own properties. */
  437. var hasOwnProperty = objectProto.hasOwnProperty;
  438. /**
  439. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  440. *
  441. * @private
  442. * @param {Object} object The object to query.
  443. * @returns {Array} Returns the array of property names.
  444. */
  445. function baseKeysIn(object) {
  446. if (!isObject(object)) {
  447. return nativeKeysIn(object);
  448. }
  449. var isProto = isPrototype(object),
  450. result = [];
  451. for (var key in object) {
  452. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  453. result.push(key);
  454. }
  455. }
  456. return result;
  457. }
  458. /**
  459. * Creates an array of the own and inherited enumerable property names of `object`.
  460. *
  461. * **Note:** Non-object values are coerced to objects.
  462. *
  463. * @static
  464. * @memberOf _
  465. * @since 3.0.0
  466. * @category Object
  467. * @param {Object} object The object to query.
  468. * @returns {Array} Returns the array of property names.
  469. * @example
  470. *
  471. * function Foo() {
  472. * this.a = 1;
  473. * this.b = 2;
  474. * }
  475. *
  476. * Foo.prototype.c = 3;
  477. *
  478. * _.keysIn(new Foo);
  479. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  480. */
  481. function keysIn(object) {
  482. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  483. }
  484. /**
  485. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  486. *
  487. * @private
  488. * @param {boolean} [fromRight] Specify iterating from right to left.
  489. * @returns {Function} Returns the new base function.
  490. */
  491. function createBaseFor(fromRight) {
  492. return function(object, iteratee, keysFunc) {
  493. var index = -1,
  494. iterable = Object(object),
  495. props = keysFunc(object),
  496. length = props.length;
  497. while (length--) {
  498. var key = props[fromRight ? length : ++index];
  499. if (iteratee(iterable[key], key, iterable) === false) {
  500. break;
  501. }
  502. }
  503. return object;
  504. };
  505. }
  506. /**
  507. * The base implementation of `baseForOwn` which iterates over `object`
  508. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  509. * Iteratee functions may exit iteration early by explicitly returning `false`.
  510. *
  511. * @private
  512. * @param {Object} object The object to iterate over.
  513. * @param {Function} iteratee The function invoked per iteration.
  514. * @param {Function} keysFunc The function to get the keys of `object`.
  515. * @returns {Object} Returns `object`.
  516. */
  517. var baseFor = createBaseFor();
  518. /**
  519. * Casts `value` to `identity` if it's not a function.
  520. *
  521. * @private
  522. * @param {*} value The value to inspect.
  523. * @returns {Function} Returns cast function.
  524. */
  525. function castFunction(value) {
  526. return typeof value == 'function' ? value : identity;
  527. }
  528. /**
  529. * Iterates over own and inherited enumerable string keyed properties of an
  530. * object and invokes `iteratee` for each property. The iteratee is invoked
  531. * with three arguments: (value, key, object). Iteratee functions may exit
  532. * iteration early by explicitly returning `false`.
  533. *
  534. * @static
  535. * @memberOf _
  536. * @since 0.3.0
  537. * @category Object
  538. * @param {Object} object The object to iterate over.
  539. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  540. * @returns {Object} Returns `object`.
  541. * @see _.forInRight
  542. * @example
  543. *
  544. * function Foo() {
  545. * this.a = 1;
  546. * this.b = 2;
  547. * }
  548. *
  549. * Foo.prototype.c = 3;
  550. *
  551. * _.forIn(new Foo, function(value, key) {
  552. * console.log(key);
  553. * });
  554. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  555. */
  556. function forIn(object, iteratee) {
  557. return object == null
  558. ? object
  559. : baseFor(object, castFunction(iteratee), keysIn);
  560. }
  561. export { forIn as f, isArray as i };