Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object.keys polyfill #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/babel-plugin-polyfill-es-shims/README.md
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions packages/babel-plugin-polyfill-es-shims/data/polyfills.json
Original file line number Diff line number Diff line change
@@ -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",
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
- `Array.prototype.copyWithin()`
- `Array.prototype.fill()`
- `Array.prototype.indexOf()`
- `Object.keys()`
- `Object.setPrototypeOf()`
- `Math.acosh()`
- `Math.asinh()`
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
@@ -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");

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();
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;
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
@@ -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";
@@ -13,7 +14,8 @@ _ObjectEntries();

_ArrayPrototypeEntries([]);

Object.keys();
_ObjectKeys();

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

_ArrayPrototypeKeys([]);
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
@@ -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];
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
});
@@ -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, {
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
@@ -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";
@@ -70,7 +71,7 @@ Object.isExtensible;
Object.isFrozen;
Object.isSealed;
_ObjectIs;
Object.keys;
_ObjectKeys;
Object.preventExtensions;
Object.seal;
Object.setPrototypeOf;
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
@@ -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",
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -166,7 +166,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/helper-define-polyfill-provider@^0.0.4, @babel/helper-define-polyfill-provider@workspace:packages/babel-helper-define-polyfill-provider":
"@babel/helper-define-polyfill-provider@^0.0.5, @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:
@@ -3596,7 +3596,7 @@ __metadata:
dependencies:
"@babel/compat-data": ^7.11.0
"@babel/core": ^7.11.5
"@babel/helper-define-polyfill-provider": ^0.0.4
"@babel/helper-define-polyfill-provider": ^0.0.5
"@babel/helper-plugin-test-runner": ^7.10.4
"@babel/plugin-transform-for-of": ^7.10.4
"@babel/plugin-transform-modules-commonjs": ^7.10.4
@@ -3611,7 +3611,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.4
"@babel/helper-define-polyfill-provider": ^0.0.5
"@babel/helper-plugin-test-runner": ^7.10.4
"@babel/plugin-syntax-dynamic-import": ^7.8.3
"@babel/plugin-transform-for-of": ^7.10.4
@@ -3628,7 +3628,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.4
"@babel/helper-define-polyfill-provider": ^0.0.5
"@babel/helper-plugin-test-runner": ^7.10.4
array.from: ^1.1.0
peerDependencies:
@@ -3641,7 +3641,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.4
"@babel/helper-define-polyfill-provider": ^0.0.5
"@babel/helper-plugin-test-runner": ^7.10.4
peerDependencies:
"@babel/core": ^7.0.0-0