Skip to content

Commit

Permalink
Object.keys polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovalov committed Oct 14, 2020
1 parent 3c77659 commit ee2b322
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 23 deletions.
1 change: 1 addition & 0 deletions packages/babel-plugin-polyfill-es-shims/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This plugin supports the following `es-shims` polyfills.
| `Array.prototype.reduce` | [`array.prototype.reduce`](https://github.com/es-shims/Array.prototype.reduce) |
| `Array.prototype.reduceRight` | [`array.prototype.reduceright`](https://github.com/es-shims/Array.prototype.reduceRight) |
| `Array.prototype.some` | [`array.prototype.some`](https://github.com/es-shims/Array.prototype.some) |
| `Object.keys` | [`object.keys`](https://github.com/ljharb/object-keys) | [@ljharb](https://github.com/ljharb)
| `String.prototype.split` | [`string.prototype.split`](https://github.com/es-shims/String.prototype.split) |

### ES2015 (ES6)
Expand Down
15 changes: 15 additions & 0 deletions packages/babel-plugin-polyfill-es-shims/data/polyfills.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@
"samsung": "11",
"electron": "5"
},
"Object.keys": {
"chrome": "5",
"opera": "12",
"edge": "12",
"firefox": "4",
"safari": "4",
"node": "0.10",
"ie": "9",
"android": "4",
"ios": "6",
"phantom": "2",
"samsung": "1",
"electron": "0.20"
},
"Object.getOwnPropertyDescriptors": {
"chrome": "54",
"opera": "41",
Expand Down Expand Up @@ -401,6 +415,7 @@
"safari": "13.1",
"node": "14",
"ios": "13.4",
"samsung": "13",
"electron": "8"
},
"String.prototype.padEnd": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
- `Array.prototype.copyWithin()`
- `Array.prototype.fill()`
- `Array.prototype.indexOf()`
- `Object.keys()`
- `Object.setPrototypeOf()`
- `Math.acosh()`
- `Math.asinh()`
Expand Down
1 change: 1 addition & 0 deletions packages/babel-plugin-polyfill-es-shims/src/mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ defineStatic("Object", "assign", "4.1.0");
defineStatic("Object", "entries", "1.1.1");
defineStatic("Object", "fromEntries", "2.0.2");
defineStatic("Object", "is", "1.1.2", "object-is");
defineStatic("Object", "keys", "1.1.1", "object-keys");
defineStatic("Object", "getOwnPropertyDescriptors", "2.1.0");
defineStatic("Object", "values", "1.1.1");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "object.entries/auto";
import "object-keys/auto";
import "object.values/auto";
Object.entries();
Object.keys();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Some polyfills have been added but are not present in your dependencies.
Please run one of the following commands:
npm install --save object.entries@^1.1.1 object.values@^1.1.1
yarn add object.entries@^1.1.1 object.values@^1.1.1
npm install --save object-keys@^1.1.1 object.entries@^1.1.1 object.values@^1.1.1
yarn add object-keys@^1.1.1 object.entries@^1.1.1 object.values@^1.1.1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "object-keys/auto";
import "object.assign/auto";
Object.keys(foo);
const getOwnPropertySymbols = Object.getOwnPropertySymbols;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Some polyfills have been added but are not present in your dependencies.
Please run one of the following commands:
npm install --save object.assign@^4.1.0
yarn add object.assign@^4.1.0
npm install --save object-keys@^1.1.1 object.assign@^4.1.0
yarn add object-keys@^1.1.1 object.assign@^4.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var _obj, _obj2, _obj3, _str;

import _ObjectEntries from "object.entries";
import _ArrayPrototypeEntries from "array.prototype.entries";
import _ObjectKeys from "object-keys";
import _ArrayPrototypeKeys from "array.prototype.keys";
import _ObjectValues from "object.values";
import _ArrayPrototypeValues from "array.prototype.values";
Expand All @@ -13,7 +14,8 @@ _ObjectEntries();

_ArrayPrototypeEntries([]);

Object.keys();
_ObjectKeys();

(_obj2 = obj, Array.isArray(_obj2) ? _ArrayPrototypeKeys : Function.call.bind(_obj2.keys))(_obj2);

_ArrayPrototypeKeys([]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Some polyfills have been added but are not present in your dependencies.
Please run one of the following commands:
npm install --save array.prototype.entries@^1.0.0 array.prototype.keys@^1.0.0 array.prototype.values@^1.0.0 object.entries@^1.1.1 object.values@^1.1.1 string.prototype.split@^1.0.1
yarn add array.prototype.entries@^1.0.0 array.prototype.keys@^1.0.0 array.prototype.values@^1.0.0 object.entries@^1.1.1 object.values@^1.1.1 string.prototype.split@^1.0.1
npm install --save array.prototype.entries@^1.0.0 array.prototype.keys@^1.0.0 array.prototype.values@^1.0.0 object-keys@^1.1.1 object.entries@^1.1.1 object.values@^1.1.1 string.prototype.split@^1.0.1
yarn add array.prototype.entries@^1.0.0 array.prototype.keys@^1.0.0 array.prototype.values@^1.0.0 object-keys@^1.1.1 object.entries@^1.1.1 object.values@^1.1.1 string.prototype.split@^1.0.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

var _ObjectKeys = require("object-keys");

exports.__esModule = true;
var _exportNames = {
exp: true
Expand All @@ -16,7 +18,7 @@ var _fuz = require("fuz");

var _mod = require("mod");

Object.keys(_mod).forEach(function (key) {
_ObjectKeys(_mod).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
exports[key] = _mod[key];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Some polyfills have been added but are not present in your dependencies.
Please run one of the following commands:
npm install --save array-includes@^3.1.1 string.prototype.includes@^2.0.0
yarn add array-includes@^3.1.1 string.prototype.includes@^2.0.0
npm install --save array-includes@^3.1.1 object-keys@^1.1.1 string.prototype.includes@^2.0.0
yarn add array-includes@^3.1.1 object-keys@^1.1.1 string.prototype.includes@^2.0.0
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

var _ObjectKeys = require("object-keys");

Object.defineProperty(exports, "__esModule", {
value: true
});
Expand All @@ -18,7 +20,7 @@ var _fuz = require("fuz");

var _mod = require("mod");

Object.keys(_mod).forEach(function (key) {
_ObjectKeys(_mod).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Some polyfills have been added but are not present in your dependencies.
Please run one of the following commands:
npm install --save array-includes@^3.1.1 string.prototype.includes@^2.0.0
yarn add array-includes@^3.1.1 string.prototype.includes@^2.0.0
npm install --save array-includes@^3.1.1 object-keys@^1.1.1 string.prototype.includes@^2.0.0
yarn add array-includes@^3.1.1 object-keys@^1.1.1 string.prototype.includes@^2.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import _ObjectEntries from "object.entries";
import _ObjectFromEntries from "object.fromentries";
import _ObjectGetOwnPropertyDescriptors from "object.getownpropertydescriptors";
import _ObjectIs from "object-is";
import _ObjectKeys from "object-keys";
import _ObjectValues from "object.values";
import _ReflectOwnKeys from "reflect.ownkeys";
import _StringFromCodePoint from "string.fromcodepoint";
Expand Down Expand Up @@ -70,7 +71,7 @@ Object.isExtensible;
Object.isFrozen;
Object.isSealed;
_ObjectIs;
Object.keys;
_ObjectKeys;
Object.preventExtensions;
Object.seal;
Object.setPrototypeOf;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Some polyfills have been added but are not present in your dependencies.
Please run one of the following commands:
npm install --save array.from@^1.1.0 array.of@^1.0.0 is-nan@^1.2.1 object-is@^1.1.2 object.assign@^4.1.0 object.entries@^1.1.1 object.fromentries@^2.0.2 object.getownpropertydescriptors@^2.1.0 object.values@^1.1.1 reflect.ownkeys@^1.0.1 string.fromcodepoint@^1.0.0
yarn add array.from@^1.1.0 array.of@^1.0.0 is-nan@^1.2.1 object-is@^1.1.2 object.assign@^4.1.0 object.entries@^1.1.1 object.fromentries@^2.0.2 object.getownpropertydescriptors@^2.1.0 object.values@^1.1.1 reflect.ownkeys@^1.0.1 string.fromcodepoint@^1.0.0
npm install --save array.from@^1.1.0 array.of@^1.0.0 is-nan@^1.2.1 object-is@^1.1.2 object-keys@^1.1.1 object.assign@^4.1.0 object.entries@^1.1.1 object.fromentries@^2.0.2 object.getownpropertydescriptors@^2.1.0 object.values@^1.1.1 reflect.ownkeys@^1.0.1 string.fromcodepoint@^1.0.0
yarn add array.from@^1.1.0 array.of@^1.0.0 is-nan@^1.2.1 object-is@^1.1.2 object-keys@^1.1.1 object.assign@^4.1.0 object.entries@^1.1.1 object.fromentries@^2.0.2 object.getownpropertydescriptors@^2.1.0 object.values@^1.1.1 reflect.ownkeys@^1.0.1 string.fromcodepoint@^1.0.0
1 change: 1 addition & 0 deletions scripts/build-es-shims-data/es-shims-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {
"Object.is": "Object static methods / Object.is",
"Object.entries": "Object static methods / Object.entries",
"Object.fromEntries": "Object.fromEntries",
"Object.keys": "Object static methods / Object.keys",
"Object.getOwnPropertyDescriptors":
"Object static methods / Object.getOwnPropertyDescriptors",
"Object.values": "Object static methods / Object.values",
Expand Down
2 changes: 1 addition & 1 deletion scripts/download-compat-table.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

COMPAT_TABLE_COMMIT=40b385cb22a0d9194e4261c94210618bba9132f9
COMPAT_TABLE_COMMIT=abf3deb213266336df6e49d936e5cbf2e4e4f84a
GIT_HEAD=build/compat-table/.git/HEAD

if [ -d "build/compat-table" ]; then
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/helper-define-polyfill-provider@^0.0.3, @babel/helper-define-polyfill-provider@workspace:packages/babel-helper-define-polyfill-provider":
"@babel/helper-define-polyfill-provider@^0.0.4, @babel/helper-define-polyfill-provider@workspace:packages/babel-helper-define-polyfill-provider":
version: 0.0.0-use.local
resolution: "@babel/helper-define-polyfill-provider@workspace:packages/babel-helper-define-polyfill-provider"
dependencies:
Expand Down Expand Up @@ -3871,7 +3871,7 @@ __metadata:
dependencies:
"@babel/compat-data": ^7.11.0
"@babel/core": ^7.11.5
"@babel/helper-define-polyfill-provider": ^0.0.3
"@babel/helper-define-polyfill-provider": ^0.0.4
"@babel/helper-plugin-test-runner": ^7.10.4
"@babel/plugin-transform-for-of": ^7.10.4
"@babel/plugin-transform-modules-commonjs": ^7.10.4
Expand All @@ -3886,7 +3886,7 @@ __metadata:
resolution: "babel-plugin-polyfill-corejs3@workspace:packages/babel-plugin-polyfill-corejs3"
dependencies:
"@babel/core": ^7.11.5
"@babel/helper-define-polyfill-provider": ^0.0.3
"@babel/helper-define-polyfill-provider": ^0.0.4
"@babel/helper-plugin-test-runner": ^7.10.4
"@babel/plugin-syntax-dynamic-import": ^7.8.3
"@babel/plugin-transform-for-of": ^7.10.4
Expand All @@ -3902,7 +3902,7 @@ __metadata:
resolution: "babel-plugin-polyfill-es-shims@workspace:packages/babel-plugin-polyfill-es-shims"
dependencies:
"@babel/core": ^7.11.5
"@babel/helper-define-polyfill-provider": ^0.0.3
"@babel/helper-define-polyfill-provider": ^0.0.4
"@babel/helper-plugin-test-runner": ^7.10.4
peerDependencies:
"@babel/core": ^7.0.0-0
Expand All @@ -3914,7 +3914,7 @@ __metadata:
resolution: "babel-plugin-polyfill-regenerator@workspace:packages/babel-plugin-polyfill-regenerator"
dependencies:
"@babel/core": ^7.11.5
"@babel/helper-define-polyfill-provider": ^0.0.3
"@babel/helper-define-polyfill-provider": ^0.0.4
"@babel/helper-plugin-test-runner": ^7.10.4
peerDependencies:
"@babel/core": ^7.0.0-0
Expand Down

0 comments on commit ee2b322

Please sign in to comment.