|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.6 KB
|
| Line | |
|---|
| 1 | # globals
|
|---|
| 2 |
|
|---|
| 3 | > Global identifiers from different JavaScript environments
|
|---|
| 4 |
|
|---|
| 5 | It's just a [JSON file](globals.json), so use it in any environment.
|
|---|
| 6 |
|
|---|
| 7 | This package is used by ESLint.
|
|---|
| 8 |
|
|---|
| 9 | **This package [no longer accepts](https://github.com/sindresorhus/globals/issues/82) new environments. If you need it for ESLint, just [create a plugin](http://eslint.org/docs/developer-guide/working-with-plugins#environments-in-plugins).**
|
|---|
| 10 |
|
|---|
| 11 | ## Install
|
|---|
| 12 |
|
|---|
| 13 | ```sh
|
|---|
| 14 | npm install globals
|
|---|
| 15 | ```
|
|---|
| 16 |
|
|---|
| 17 | ## Usage
|
|---|
| 18 |
|
|---|
| 19 | ```js
|
|---|
| 20 | const globals = require('globals');
|
|---|
| 21 |
|
|---|
| 22 | console.log(globals.browser);
|
|---|
| 23 | /*
|
|---|
| 24 | {
|
|---|
| 25 | addEventListener: false,
|
|---|
| 26 | applicationCache: false,
|
|---|
| 27 | ArrayBuffer: false,
|
|---|
| 28 | atob: false,
|
|---|
| 29 | …
|
|---|
| 30 | }
|
|---|
| 31 | */
|
|---|
| 32 | ```
|
|---|
| 33 |
|
|---|
| 34 | 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.
|
|---|
| 35 |
|
|---|
| 36 | For Node.js this package provides two sets of globals:
|
|---|
| 37 |
|
|---|
| 38 | - `globals.nodeBuiltin`: Globals available to all code running in Node.js.
|
|---|
| 39 | These will usually be available as properties on the `global` object and include `process`, `Buffer`, but not CommonJS arguments like `require`.
|
|---|
| 40 | See: https://nodejs.org/api/globals.html
|
|---|
| 41 | - `globals.node`: A combination of the globals from `nodeBuiltin` plus all CommonJS arguments ("CommonJS module scope").
|
|---|
| 42 | See: https://nodejs.org/api/modules.html#modules_the_module_scope
|
|---|
| 43 |
|
|---|
| 44 | When analyzing code that is known to run outside of a CommonJS wrapper, for example, JavaScript modules, `nodeBuiltin` can find accidental CommonJS references.
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.