Skip to content

Commit

Permalink
transform engine names to lower case in core-js-compat targets parser
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Feb 7, 2022
1 parent 2e532d6 commit ea62b2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Changelog
##### Unreleased
- Added a [bug](https://bugs.webkit.org/show_bug.cgi?id=236541)fix for the WebKit `Array.prototype.{ groupBy, groupByToMap }` implementation
- `core-js-compat` targets parser transforms engine names to lower case
- `atob` / `btoa` marked as [fixed](https://github.com/nodejs/node/pull/41478) in NodeJS 17.5
- Added Electron 18.0 compat data mapping
- Added Deno 1.20 compat data mapping
Expand Down
13 changes: 9 additions & 4 deletions packages/core-js-compat/targets-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ const validTargets = new Set([
'samsung',
]);

const toLowerKeys = function (object) {
return Object.entries(object).reduce((accumulator, [key, value]) => {
accumulator[key.toLowerCase()] = value;
return accumulator;
}, {});
};

module.exports = function (targets) {
if (typeof targets != 'object' || Array.isArray(targets)) {
targets = { browsers: targets };
}
const { browsers, esmodules, node, ...rest } = (typeof targets != 'object' || Array.isArray(targets))
? { browsers: targets } : toLowerKeys(targets);

const { browsers, esmodules, node, ...rest } = targets;
const list = Object.entries(rest);

if (browsers) {
Expand Down

0 comments on commit ea62b2e

Please sign in to comment.