@adviser/cement - v0.0.0
    Preparing search index...

    Function runtimeFn

    • Detects the current JavaScript runtime environment.

      Performs feature detection to identify which runtime environment the code is executing in. Checks for environment-specific global objects and APIs in priority order:

      1. Cloudflare Workers (caches.default + WebSocketPair)
      2. React Native (navigator.product === "ReactNative")
      3. Deno (global Deno object)
      4. Node.js (process.versions.node)
      5. Browser (none of the above)

      The detection is mutually exclusive - only one environment flag will be true.

      Returns Runtime

      Runtime object with boolean flags for each environment

      const runtime = runtimeFn();

      if (runtime.isNodeIsh) {
      // Use Node.js APIs
      const fs = require('fs');
      } else if (runtime.isBrowser) {
      // Use browser APIs
      console.log(window.location.href);
      } else if (runtime.isDeno) {
      // Use Deno APIs
      const file = await Deno.readTextFile('./config.json');
      } else if (runtime.isCFWorker) {
      // Use Cloudflare Workers APIs
      const cache = caches.default;
      }