forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 18 additions & 1 deletion
19
packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
import _Array$from from "../../core-js/array/from"; | ||
import _isIterable from "../../core-js/is-iterable"; | ||
export default function _iterableToArray(iter) { | ||
if (_isIterable(Object(iter)) || Object.prototype.toString.call(iter) === "[object Arguments]") return _Array$from(iter); | ||
var prototypeWhiteList = ['[object Arguments]']; | ||
var hasSymbol = false; | ||
|
||
try { | ||
if (_isIterable(Object(iter))) { | ||
hasSymbol = true; | ||
} | ||
} catch (e) {} | ||
|
||
if (hasSymbol) { | ||
return _Array$from(iter); | ||
} | ||
|
||
if (prototypeWhiteList.indexOf(Object.prototype.toString.call(iter)) !== -1) { | ||
return _Array$from(iter); | ||
} | ||
|
||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
export default function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
var prototypeWhiteList = ['[object Arguments]']; | ||
var hasSymbol = false; | ||
|
||
try { | ||
if (Symbol.iterator in Object(iter)) { | ||
hasSymbol = true; | ||
} | ||
} catch (e) {} | ||
|
||
if (hasSymbol) { | ||
return Array.from(iter); | ||
} | ||
|
||
if (prototypeWhiteList.indexOf(Object.prototype.toString.call(iter)) !== -1) { | ||
return Array.from(iter); | ||
} | ||
|
||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
var prototypeWhiteList = ['[object Arguments]']; | ||
var hasSymbol = false; | ||
|
||
try { | ||
if (Symbol.iterator in Object(iter)) { | ||
hasSymbol = true; | ||
} | ||
} catch (e) {} | ||
|
||
if (hasSymbol) { | ||
return Array.from(iter); | ||
} | ||
|
||
if (prototypeWhiteList.indexOf(Object.prototype.toString.call(iter)) !== -1) { | ||
return Array.from(iter); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
module.exports = _iterableToArray; |