Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

runtimey

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

runtimey

Easily detect which JavaScript runtime is being used.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

runtimey

Easily detect which JavaScript runtime is being used. Bun, Deno, Node.JS or browser.

Useful for packages or scripts to customize functionality of their code depending on the runtime being executed.

Usage

index.js

import { currentRuntime } from "runtimey";
console.log(currentRuntime);

shell

$ bun index.js && deno run index.js && node index.js
bun
deno
node

Documentation

  • isBun

    true if the Bun runtime is being used.

  • isDeno

    true if the Deno runtime is being used.

  • isNode

    true if the Node.JS runtime is being used.

  • isBrowser

    true if running inside a browser.

  • currentRuntime: "bun" | "deno" | "node" | "browser" | "unknown"

    The name of the current runtime being used.

  • runtimeValue({ bun, deno, node, browser, default })

    Returns the value according to the runtime being used.

    index.js

    import { runtimeValue } from "runtimey";
    const val = runtimeValue({ bun: "RUNTIME_BUN", deno: "RUNTIME_DENO", node: "RUNTIME_NODE" });
    console.log("Current runtime:", val);
    

    shell

    $ bun index.js && deno run index.js && node index.js
    Current runtime: RUNTIME_BUN
    Current runtime: RUNTIME_DENO
    Current runtime: RUNTIME_NODE
    
  • isServiceWorker

    true if running in a worker environment.

License

This repository uses MIT License. See LICENSE for full license text.

Keywords

FAQs

Package last updated on 21 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc