Skip to content

Commit

Permalink
alphabetize engine names in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jun 27, 2023
1 parent cdb6c7c commit babcb2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions pkg/api/api_js_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@ type EngineName uint8

const (
EngineChrome EngineName = iota
EngineDeno
EngineEdge
EngineFirefox
EngineHermes
EngineIE
EngineIOS
EngineNode
EngineOpera
EngineSafari
EngineDeno
EngineHermes
EngineRhino
EngineSafari
)

func convertEngineName(engine EngineName) compat.Engine {
switch engine {
case EngineChrome:
return compat.Chrome
case EngineDeno:
return compat.Deno
case EngineEdge:
return compat.Edge
case EngineFirefox:
return compat.Firefox
case EngineHermes:
return compat.Hermes
case EngineIE:
return compat.IE
case EngineIOS:
Expand All @@ -36,14 +40,10 @@ func convertEngineName(engine EngineName) compat.Engine {
return compat.Node
case EngineOpera:
return compat.Opera
case EngineSafari:
return compat.Safari
case EngineDeno:
return compat.Deno
case EngineHermes:
return compat.Hermes
case EngineRhino:
return compat.Rhino
case EngineSafari:
return compat.Safari
default:
panic("Invalid engine name")
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/compat-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,12 +665,12 @@ import "github.com/evanw/esbuild/internal/compat"
type EngineName uint8
const (
${engines.filter(x => x !== 'es').map((x, i) => `\tEngine${upper(x)}${i ? '' : ' EngineName = iota'}`).join('\n')}
${engines.slice().sort().filter(x => x !== 'es').map((x, i) => `\tEngine${upper(x)}${i ? '' : ' EngineName = iota'}`).join('\n')}
)
func convertEngineName(engine EngineName) compat.Engine {
\tswitch engine {
${engines.filter(x => x !== 'es').map(x => `\tcase Engine${upper(x)}:\n\t\treturn compat.${upper(x)}`).join('\n')}
${engines.slice().sort().filter(x => x !== 'es').map(x => `\tcase Engine${upper(x)}:\n\t\treturn compat.${upper(x)}`).join('\n')}
\tdefault:
\t\tpanic("Invalid engine name")
\t}
Expand Down

0 comments on commit babcb2c

Please sign in to comment.