From 0b0bf353fae4cdca982991480dac15f5b29eff04 Mon Sep 17 00:00:00 2001 From: Tomer Horowitz <45624804+tomerh2001@users.noreply.github.com> Date: Sat, 6 Apr 2024 12:47:47 +0300 Subject: [PATCH] docs: Updated Bun.nanoseconds documentation (#9986) --- packages/bun-types/bun.d.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 906384c598..3a7165b9d5 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -2992,12 +2992,19 @@ declare module "bun" { } /** - * Nanoseconds since Bun.js was started as an integer. + * Returns the number of nanoseconds since the process was started. * - * This uses a high-resolution monotonic system timer. + * This function uses a high-resolution monotonic system timer to provide precise time measurements. + * In JavaScript, numbers are represented as double-precision floating-point values (IEEE 754), + * which can safely represent integers up to 2^53 - 1 (Number.MAX_SAFE_INTEGER). * - * After 14 weeks of consecutive uptime, this function - * wraps + * Due to this limitation, while the internal counter may continue beyond this point, + * the precision of the returned value will degrade after 14.8 weeks of uptime (when the nanosecond + * count exceeds Number.MAX_SAFE_INTEGER). Beyond this point, the function will continue to count but + * with reduced precision, which might affect time calculations and comparisons in long-running applications. + * + * @returns {number} The number of nanoseconds since the process was started, with precise values up to + * Number.MAX_SAFE_INTEGER. */ function nanoseconds(): number;