55
66const regexFlagsSupported = / a / g. flags !== undefined ;
77
8- const arrayFrom = require ( 'array-from' ) ;
8+ const arrayFromSet = set => {
9+ const array = [ ] ;
10+ set . forEach ( value => array . push ( value ) ) ;
11+
12+ return array ;
13+ } ;
14+
15+ const arrayFromMap = map => {
16+ const array = [ ] ;
17+ map . forEach ( ( value , key ) => array . push ( [ key , value ] ) ) ;
18+
19+ return array ;
20+ } ;
921
1022const objectIs = Object . is ? Object . is : require ( 'object-is' ) ;
1123const objectGetOwnPropertySymbols = Object . getOwnPropertySymbols ? Object . getOwnPropertySymbols : ( ) => [ ] ;
@@ -347,7 +359,7 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
347359
348360function setHasEqualElement ( set , val1 , strict , memo ) {
349361 // Go looking.
350- const setValues = arrayFrom ( set . values ( ) ) ;
362+ const setValues = arrayFromSet ( set ) ;
351363 for ( let i = 0 ; i < setValues . length ; i ++ ) {
352364 const val2 = setValues [ i ] ;
353365 if ( innerDeepEqual ( val1 , val2 , strict , memo ) ) {
@@ -410,7 +422,7 @@ function setEquiv(a, b, strict, memo) {
410422 // This is a lazily initiated Set of entries which have to be compared
411423 // pairwise.
412424 let set = null ;
413- const aValues = arrayFrom ( a . values ( ) ) ;
425+ const aValues = arrayFromSet ( a ) ;
414426 for ( let i = 0 ; i < aValues . length ; i ++ ) {
415427 const val = aValues [ i ] ;
416428 // Note: Checking for the objects first improves the performance for object
@@ -442,7 +454,7 @@ function setEquiv(a, b, strict, memo) {
442454 }
443455
444456 if ( set !== null ) {
445- const bValues = arrayFrom ( b . values ( ) ) ;
457+ const bValues = arrayFromSet ( b ) ;
446458 for ( let i = 0 ; i < bValues . length ; i ++ ) {
447459 const val = bValues [ i ] ;
448460 // We have to check if a primitive value is already
@@ -466,7 +478,7 @@ function mapHasEqualEntry(set, map, key1, item1, strict, memo) {
466478 // To be able to handle cases like:
467479 // Map([[{}, 'a'], [{}, 'b']]) vs Map([[{}, 'b'], [{}, 'a']])
468480 // ... we need to consider *all* matching keys, not just the first we find.
469- const setValues = arrayFrom ( set . values ( ) ) ;
481+ const setValues = arrayFromSet ( set ) ;
470482 for ( let i = 0 ; i < setValues . length ; i ++ ) {
471483 const key2 = setValues [ i ] ;
472484 if ( innerDeepEqual ( key1 , key2 , strict , memo ) &&
@@ -482,7 +494,7 @@ function mapHasEqualEntry(set, map, key1, item1, strict, memo) {
482494function mapEquiv ( a , b , strict , memo ) {
483495 let set = null ;
484496
485- const aEntries = arrayFrom ( a . entries ( ) ) ;
497+ const aEntries = arrayFromMap ( a ) ;
486498 for ( let i = 0 ; i < aEntries . length ; i ++ ) {
487499 const [ key , item1 ] = aEntries [ i ] ;
488500 if ( typeof key === 'object' && key !== null ) {
@@ -511,7 +523,7 @@ function mapEquiv(a, b, strict, memo) {
511523 }
512524
513525 if ( set !== null ) {
514- const bEntries = arrayFrom ( b . entries ( ) ) ;
526+ const bEntries = arrayFromMap ( b ) ;
515527 for ( let i = 0 ; i < bEntries . length ; i ++ ) {
516528 const [ key , item ] = bEntries [ i ] ;
517529 if ( typeof key === 'object' && key !== null ) {
0 commit comments