diff options
author | Thomas Groman <tgroman@nuegia.net> | 2021-04-27 13:46:46 -0700 |
---|---|---|
committer | Thomas Groman <tgroman@nuegia.net> | 2021-04-27 13:46:46 -0700 |
commit | bdd6513d0f37d075e9b3b11058b9cf6fcdf5055f (patch) | |
tree | eebab5128efbec1a555d443bac04f4dbd4241987 /js/src/builtin/Object.js | |
parent | 702b3bf53ac4d7e3d483c9b12123235ba83c5395 (diff) | |
download | UXP-bdd6513d0f37d075e9b3b11058b9cf6fcdf5055f.tar UXP-bdd6513d0f37d075e9b3b11058b9cf6fcdf5055f.tar.gz UXP-bdd6513d0f37d075e9b3b11058b9cf6fcdf5055f.tar.lz UXP-bdd6513d0f37d075e9b3b11058b9cf6fcdf5055f.tar.xz UXP-bdd6513d0f37d075e9b3b11058b9cf6fcdf5055f.zip |
Add object-from-entrieswebbrowser
Uriel was right
Diffstat (limited to 'js/src/builtin/Object.js')
-rw-r--r-- | js/src/builtin/Object.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/js/src/builtin/Object.js b/js/src/builtin/Object.js index 9ed1be0e1..c4739037e 100644 --- a/js/src/builtin/Object.js +++ b/js/src/builtin/Object.js @@ -202,3 +202,21 @@ function ObjectLookupGetter(name) { // Step 3.d. (implicit) } + +// Stage 4 draft 2020-09-06 https://tc39.github.io/proposal-object-from-entries/ +// Object.fromEntries (iterable) +function ObjectFromEntries(iter) { + // We omit the usual step number comments here because they don't help. + // This implementation inlines AddEntriesFromIterator and + // CreateDataPropertyOnObject, so it looks more like the polyfill + // than the step-by-step spec algorithm. + const obj = {}; + + for (const pair of allowContentIter(iter)) { + if (!IsObject(pair)) + ThrowTypeError(JSMSG_INVALID_MAP_ITERABLE, "Object.fromEntries"); + _DefineDataProperty(obj, pair[0], pair[1]); + } + + return obj; +} |