You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
584 B
18 lines
584 B
'use strict'; |
|
const { compare, intersection, semver } = require('./helpers'); |
|
const modulesByVersions = require('./modules-by-versions'); |
|
const modules = require('./modules'); |
|
|
|
module.exports = function (raw) { |
|
const corejs = semver(raw); |
|
if (corejs.major !== 3) { |
|
throw RangeError('This version of `core-js-compat` works only with `core-js@3`.'); |
|
} |
|
const result = []; |
|
for (const version of Object.keys(modulesByVersions)) { |
|
if (compare(version, '<=', corejs)) { |
|
result.push(...modulesByVersions[version]); |
|
} |
|
} |
|
return intersection(result, modules); |
|
};
|
|
|