Skip to content

Commit

Permalink
only loop through desired data in "caniuse"
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jul 13, 2023
1 parent b5f4480 commit b07e747
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions compat-table/src/caniuse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,37 @@ const supportedAgents: Record<string, Engine> = {
safari: 'Safari',
}

export const js: SupportMap<JSFeature> = {} as SupportMap<JSFeature>

const jsFeatures: Record<string, JSFeature> = {
'es6-module-dynamic-import': 'DynamicImport',
}

for (const feature in lite.features) {
export const js: SupportMap<JSFeature> = {} as SupportMap<JSFeature>

for (const feature in jsFeatures) {
const jsFeature = jsFeatures[feature]
if (jsFeature) {
const entry = lite.feature(lite.features[feature])
const engines: Partial<Record<Engine, Record<string, Support>>> = {}
const engines: Partial<Record<Engine, Record<string, Support>>> = {}
const entry = lite.feature(lite.features[feature])

for (const agent in entry.stats) {
const engine = supportedAgents[agent]
if (!engine) continue
for (const agent in entry.stats) {
const engine = supportedAgents[agent]
if (!engine) continue

const versionRanges = entry.stats[agent]
const versions: Record<string, Support> = {}
const versionRanges = entry.stats[agent]
const versions: Record<string, Support> = {}

for (const versionRange in versionRanges) {
const statusCodes = versionRanges[versionRange].split(' ')
const isSupported = statusCodes.includes(StatusCode.Yes)
for (const versionRange in versionRanges) {
const statusCodes = versionRanges[versionRange].split(' ')
const isSupported = statusCodes.includes(StatusCode.Yes)

for (const version of versionRange.split('-')) {
if (/^\d+(?:\.\d+(?:\.\d+)?)?$/.test(version)) {
versions[version] = { force: isSupported }
}
for (const version of versionRange.split('-')) {
if (/^\d+(?:\.\d+(?:\.\d+)?)?$/.test(version)) {
versions[version] = { force: isSupported }
}
}

engines[engine] = versions
}

js[jsFeature] = engines
engines[engine] = versions
}

js[jsFeature] = engines
}

0 comments on commit b07e747

Please sign in to comment.