mirror of
https://github.com/GayPizzaSpecifications/dough.git
synced 2025-08-05 06:21:32 +00:00
Fix nodejs support.
This commit is contained in:
@ -6,18 +6,16 @@ enum class JsPlatformType {
|
||||
Unknown;
|
||||
|
||||
companion object {
|
||||
fun current(): JsPlatformType {
|
||||
val isWindowAvailable = js("typeof window") != undefined
|
||||
val isProcessAvailable = js("typeof process") != undefined
|
||||
val current: JsPlatformType
|
||||
get() {
|
||||
val isWindowAvailable = js("typeof window") != undefined
|
||||
val isProcessAvailable = js("typeof process") != undefined
|
||||
|
||||
if (isProcessAvailable) {
|
||||
return Nodejs
|
||||
return when {
|
||||
isProcessAvailable -> Nodejs
|
||||
isWindowAvailable -> Browser
|
||||
else -> Unknown
|
||||
}
|
||||
}
|
||||
|
||||
if (isWindowAvailable) {
|
||||
return Browser
|
||||
}
|
||||
return Unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,9 @@ package gay.pizza.dough.core
|
||||
|
||||
import gay.pizza.dough.core.time.ClockProvider
|
||||
import gay.pizza.dough.core.time.UnixTime
|
||||
import kotlin.js.Date
|
||||
|
||||
object StandardClockProvider : ClockProvider {
|
||||
override fun now(): UnixTime =
|
||||
UnixTime(js("(new Date()).getTime()") as Long)
|
||||
UnixTime(Date().getTime().toLong())
|
||||
}
|
||||
|
Reference in New Issue
Block a user