Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
4199da09
Unverified
Commit
4199da09
authored
Aug 08, 2022
by
Sukka
Committed by
GitHub
Aug 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Object#fromEntries polyfill (#36426)
parent
ab48f547
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
index.js
packages/next-polyfill-module/src/index.js
+24
-0
No files found.
packages/next-polyfill-module/src/index.js
View file @
4199da09
...
@@ -94,3 +94,27 @@ if (!Promise.prototype.finally) {
...
@@ -94,3 +94,27 @@ if (!Promise.prototype.finally) {
)
)
}
}
}
}
/**
* Available in:
* Edge: never
* Firefox: 63
* Chrome: 73
* Safari: 12.1
*
* https://caniuse.com/mdn-javascript_builtins_object_fromentries
*/
// Modified from https://github.com/tc39/proposal-object-from-entries/blob/main/polyfill.js
// Modified from https://github.com/feross/fromentries/blob/29b52a850bb3a47c390937631c2638edf3443942/index.js
// License MIT
if
(
!
Object
.
fromEntries
)
{
Object
.
fromEntries
=
function
(
iterable
)
{
// Assume the input is either an iterable object or an array-like object
return
Array
.
from
(
iterable
).
reduce
(
function
(
obj
,
entry
)
{
// https://github.com/tc39/proposal-object-from-entries/blob/e4837799c1586a07c101570b27997497e5290c22/polyfill.js#L9-L10
// contract is that entry has "0" and "1" keys, not that it is an array or iterable.
obj
[
entry
[
0
]]
=
entry
[
1
]
return
obj
},
{})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment