JavaScript Global Documentation Links
This package provides a programmatic way to access documentation URLs for JavaScript global objects across various environments including built-in types, non-standard APIs, and browser, worker, or Node.js specific globals. It exposes a `docs` object containing all categorized links and a `getDoc` function to retrieve a specific URL by name. The current stable version is 2.4.1, which was last published over seven years ago (as of April 2026). Crucially, the GitHub repository for this project has been archived, indicating that the package is no longer maintained and is considered abandoned. Users should be aware that the documentation links provided by this package are highly likely to be outdated and may no longer resolve correctly due to changes on the target documentation sites (e.g., MDN/Mozilla Developer Center).
Common errors
-
TypeError: Cannot destructure property 'getDoc' of 'require(...)' as it is undefined.
cause Attempting to use ESM `import` syntax for a CommonJS-only package without proper tooling, or trying to access a non-existent export.fixEnsure you are using CommonJS `const { getDoc } = require('globals-docs');`. If the symbol itself is truly missing, check the package's exports. -
Error [ERR_REQUIRE_ESM]: require() of ES Module ... is not supported.
cause This error usually implies the reverse: you're trying to `require()` an ESM-only package. However, in the context of `globals-docs`, this specific error is unlikely to appear from the package itself, but rather if your *own* project is ESM and trying to `require` a CJS module in a way your runtime doesn't implicitly support (e.g., `node --experimental-modules` might handle it, but pure ESM environments might not without specific loader configurations).fixWhile `globals-docs` is CJS, if you encounter this, it points to a broader module interoperability issue in your project. Ensure your Node.js version and project configuration support CJS `require` calls from your ESM code, or stick to CJS for projects using `globals-docs`. -
Documentation URL for Array: undefined
cause The `getDoc` function returned `undefined`, meaning it couldn't find a documentation link for the requested global name in its internal data.fixVerify the spelling of the global object name. Be aware that the package is outdated and may not contain links for all existing or newly introduced globals.
Warnings
- breaking The project's GitHub repository has been archived, indicating it is no longer actively maintained. This means no new features, bug fixes, or security updates will be released.
- gotcha Documentation links provided by this package are highly likely to be outdated. The last release was over seven years ago, and target documentation sites (like MDN) frequently update their URL structures and content.
- gotcha The package does not support ECMAScript Modules (ESM) directly. Attempting to use `import ... from 'globals-docs'` will result in a runtime error unless your build setup (e.g., Webpack, Rollup, Babel) is configured to transpile or resolve CommonJS modules.
- gotcha This package will not include documentation for newer JavaScript features, APIs (e.g., `globalThis`, many new Array methods), or browser/Node.js globals introduced after its last update in early 2019.
Install
-
npm install globals-docs -
yarn add globals-docs -
pnpm add globals-docs
Imports
- getDoc
import { getDoc } from 'globals-docs';const { getDoc } = require('globals-docs'); - docs
import { docs } from 'globals-docs';const { docs } = require('globals-docs'); - default (entire module)
import globalsDocs from 'globals-docs';
const globalsDocs = require('globals-docs'); // globalsDocs.getDoc(...) // globalsDocs.docs
Quickstart
const { getDoc, docs } = require('globals-docs');
// Get documentation URL for a specific global
const arrayDocUrl = getDoc('Array');
console.log(`Documentation URL for Array: ${arrayDocUrl}`);
const promiseDocUrl = getDoc('Promise');
console.log(`Documentation URL for Promise: ${promiseDocUrl}`);
// Access the full documentation object
console.log('\nAvailable environments in docs object:', Object.keys(docs));
// Example: Get a link from the 'browser' environment
if (docs.browser && docs.browser.fetch) {
console.log(`Browser 'fetch' API documentation: ${docs.browser.fetch}`);
}
// Try a global that might not exist or be commonly documented by this package's age
const nonExistentDoc = getDoc('NonExistentGlobalABCDEF');
console.log(`Documentation for NonExistentGlobalABCDEF: ${nonExistentDoc ? nonExistentDoc : 'Not found (expected)'}`);