mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 13:07:26 +01:00
web: Better way to detect NodeJS
This commit is contained in:
parent
c2df8326fc
commit
a5eb1b84ab
@ -18,12 +18,21 @@ package web
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
)
|
||||
|
||||
var (
|
||||
isNodeJSOnce sync.Once
|
||||
isNodeJS = false
|
||||
)
|
||||
|
||||
func IsNodeJS() bool {
|
||||
return js.Global.Get("require") != js.Undefined
|
||||
isNodeJSOnce.Do(func() {
|
||||
isNodeJS = js.Global.Get("process") != js.Undefined
|
||||
})
|
||||
return isNodeJS
|
||||
}
|
||||
|
||||
func IsBrowser() bool {
|
||||
|
Loading…
Reference in New Issue
Block a user