Need help with globals?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

sindresorhus
215 Stars 95 Forks MIT License 270 Commits 6 Opened issues

Description

Global identifiers from different JavaScript environments

Services available

!
?

Need anything else?

Contributors list

# 207
node
exec
test-fr...
nextjs
122 commits
# 3,168
JavaScr...
ESLint
ecmascr...
static-...
9 commits
# 1,575
gitlab
GitHub
usersty...
clean-c...
7 commits
# 10,112
JavaScr...
Sass
node
node-js
6 commits
# 4,941
TypeScr...
Webpack
ESLint
ecmascr...
3 commits
# 5,756
JavaScr...
ESLint
Vue.js
cli-com...
3 commits
# 72,362
HTML
nokogir...
sketch-...
sketcha...
3 commits
# 119
ESLint
Rails
React
ecmascr...
2 commits
# 87,816
Objecti...
C
javascr...
osx
2 commits
# 45,310
JavaScr...
Vim
neovim-...
syntax-...
2 commits
# 8,160
ESLint
ecmascr...
Markdow...
Babel
2 commits
# 4,076
JavaScr...
TypeScr...
faceboo...
ESLint
2 commits
# 2,473
JavaScr...
gatsbyj...
sentry
ecmascr...
2 commits
# 3,507
ecmascr...
ast
OCaml
React
1 commit
# 827
Java
JavaScr...
osx
stream
1 commit
# 101,951
travis-...
HTML
ESLint
ecmascr...
1 commit
# 8,328
Ember
TypeScr...
javascr...
Rust
1 commit
# 208,639
HTML
CSS
Shell
mustach...
1 commit
# 10,928
Markdow...
ecmascr...
openlay...
spatial...
1 commit
# 102,883
xmlhttp...
ESLint
npm
ecmascr...
1 commit

globals

Global identifiers from different JavaScript environments

It's just a JSON file, so use it in any environment.

This package is used by ESLint.

This package no longer accepts new environments. If you need it for ESLint, just create a plugin.

Install

$ npm install globals

Usage

const globals = require('globals');

console.log(globals.browser); /* { addEventListener: false, applicationCache: false, ArrayBuffer: false, atob: false, … } */

Each global is given a value of

true
or
false
. A value of
true
indicates that the variable may be overwritten. A value of
false
indicates that the variable should be considered read-only. This information is used by static analysis tools to flag incorrect behavior. We assume all variables should be
false
unless we hear otherwise.

For Node.js this package provides two sets of globals:

  • globals.nodeBuiltin
    : Globals available to all code running in Node.js. These will usually be available as properties on the
    global
    object and include
    process
    ,
    Buffer
    , but not CommonJS arguments like
    require
    . See: https://nodejs.org/api/globals.html
  • globals.node
    : A combination of the globals from
    nodeBuiltin
    plus all CommonJS arguments ("CommonJS module scope"). See: https://nodejs.org/api/modules.html#modulesthemodule_scope

When analyzing code that is known to run outside of a CommonJS wrapper, for example, JavaScript modules,

nodeBuiltin
can find accidental CommonJS references.
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.