mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 04:22:05 +01:00
web: Better way to detect NodeJS
This commit is contained in:
parent
c2df8326fc
commit
a5eb1b84ab
@ -18,12 +18,21 @@ package web
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/gopherjs/gopherjs/js"
|
"github.com/gopherjs/gopherjs/js"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
isNodeJSOnce sync.Once
|
||||||
|
isNodeJS = false
|
||||||
|
)
|
||||||
|
|
||||||
func IsNodeJS() bool {
|
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 {
|
func IsBrowser() bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user