@effect/io
Advanced tools
Comparing version 0.29.1 to 0.29.2
@@ -45,13 +45,23 @@ "use strict"; | ||
}; | ||
exports.globalClockScheduler = globalClockScheduler; | ||
const performanceNowNanos = /*#__PURE__*/function () { | ||
const origin = /*#__PURE__*/BigInt( /*#__PURE__*/Math.round(performance.timeOrigin * 1000000)); | ||
return () => { | ||
const now = performance.now(); | ||
const millis = Math.floor(now); | ||
return origin + BigInt(millis * 1000000) + BigInt(Math.round((now - millis) * 1000000)); | ||
}; | ||
}(); | ||
/** @internal */ | ||
exports.globalClockScheduler = globalClockScheduler; | ||
class ClockImpl { | ||
constructor() { | ||
this[_a] = ClockTypeId; | ||
this.processHrtime = typeof process === "object" && "hrtime" in process ? process.hrtime : undefined; | ||
this.timeOrigin = this.processHrtime ? performanceNowNanos() - this.processHrtime.bigint() : 0n; | ||
} | ||
unsafeCurrentTimeMillis() { | ||
return new Date().getTime(); | ||
return Date.now(); | ||
} | ||
unsafeCurrentTimeNanos() { | ||
return BigInt(Math.round(performance.timeOrigin * 1000000)) + BigInt(Math.round(performance.now() * 1000000)); | ||
return this.processHrtime ? this.timeOrigin + this.processHrtime.bigint() : performanceNowNanos(); | ||
} | ||
@@ -58,0 +68,0 @@ currentTimeMillis() { |
{ | ||
"name": "@effect/io", | ||
"version": "0.29.1", | ||
"version": "0.29.2", | ||
"license": "MIT", | ||
@@ -10,3 +10,3 @@ "repository": { | ||
"dependencies": { | ||
"@effect/data": "~0.12.6" | ||
"@effect/data": "~0.12.10" | ||
}, | ||
@@ -13,0 +13,0 @@ "publishConfig": { |
@@ -42,2 +42,11 @@ import * as Context from "@effect/data/Context" | ||
const performanceNowNanos = (function() { | ||
const origin = BigInt(Math.round(performance.timeOrigin * 1_000_000)) | ||
return () => { | ||
const now = performance.now() | ||
const millis = Math.floor(now) | ||
return origin + BigInt(millis * 1000000) + BigInt(Math.round((now - millis) * 1_000_000)) | ||
} | ||
})() | ||
/** @internal */ | ||
@@ -47,8 +56,15 @@ class ClockImpl implements Clock.Clock { | ||
readonly processHrtime = typeof process === "object" && "hrtime" in process ? process.hrtime : undefined | ||
readonly timeOrigin = this.processHrtime ? | ||
performanceNowNanos() - this.processHrtime.bigint() : | ||
0n | ||
unsafeCurrentTimeMillis(): number { | ||
return new Date().getTime() | ||
return Date.now() | ||
} | ||
unsafeCurrentTimeNanos(): bigint { | ||
return BigInt(Math.round(performance.timeOrigin * 1000000)) + BigInt(Math.round(performance.now() * 1000000)) | ||
return this.processHrtime ? | ||
this.timeOrigin + this.processHrtime.bigint() : | ||
performanceNowNanos() | ||
} | ||
@@ -55,0 +71,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6955446
119325
Updated@effect/data@~0.12.10