@@ -156,24 +156,26 @@ function deepGet(obj, path) {
156156 return length ? obj : void 0 ;
157157}
158158
159+ // Common logic for isArrayLike and isBufferLike.
160+ var MAX_ARRAY_INDEX = Math . pow ( 2 , 53 ) - 1 ;
161+ function createSizePropertyCheck ( getSizeProperty ) {
162+ return function ( collection ) {
163+ var sizeProperty = getSizeProperty ( collection ) ;
164+ return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX ;
165+ }
166+ }
167+
159168// Helper for collection methods to determine whether a collection
160169// should be iterated as an array or as an object.
161170// Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
162171// Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
163- var MAX_ARRAY_INDEX = Math . pow ( 2 , 53 ) - 1 ;
164172var getLength = shallowProperty ( 'length' ) ;
165- function isArrayLike ( collection ) {
166- var length = getLength ( collection ) ;
167- return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX ;
168- }
173+ var isArrayLike = createSizePropertyCheck ( getLength ) ;
169174
170175// Likewise to determine whether we should spend extensive checks against
171176// `ArrayBuffer` et al.
172177var getByteLength = shallowProperty ( 'byteLength' ) ;
173- function isBufferLike ( collection ) {
174- var byteLength = getByteLength ( collection ) ;
175- return typeof byteLength == 'number' && byteLength >= 0 && byteLength <= MAX_ARRAY_INDEX ;
176- }
178+ var isBufferLike = createSizePropertyCheck ( getByteLength ) ;
177179
178180// Collection Functions
179181// --------------------
0 commit comments