Home / Function/ nextRange() — bun Function Reference

nextRange() — bun Function Reference

Architecture documentation for the nextRange() function in realworld_stream.mjs from the bun codebase.

Entity Profile

Dependency Diagram

graph TD
  4cb7c470_0a54_e6de_e803_1a8c65182639["nextRange()"]
  84d16578_5017_ddc0_94ca_db43e33f2805["chunks()"]
  84d16578_5017_ddc0_94ca_db43e33f2805 -->|calls| 4cb7c470_0a54_e6de_e803_1a8c65182639
  d467d310_e883_6020_8ffb_fc378ed6c44d["nextInt()"]
  4cb7c470_0a54_e6de_e803_1a8c65182639 -->|calls| d467d310_e883_6020_8ffb_fc378ed6c44d
  style 4cb7c470_0a54_e6de_e803_1a8c65182639 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

bench/emitter/realworld_stream.mjs lines 13–19

function nextRange(start, end) {
  // returns in range [start, end): including start, excluding end
  // can't modulu nextInt because of weak randomness in lower bits
  const rangeSize = end - start;
  const randomUnder1 = nextInt() / 0x7fffffff; // 2**31 - 1
  return start + Math.floor(randomUnder1 * rangeSize);
}

Subdomains

Calls

Called By

Frequently Asked Questions

What does nextRange() do?
nextRange() is a function in the bun codebase.
What does nextRange() call?
nextRange() calls 1 function(s): nextInt.
What calls nextRange()?
nextRange() is called by 1 function(s): chunks.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free