standard-objects-globalthis 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # `standard-objects-globalthis`
2
+ The standard built-in object `globalThis` if it exists, otherwise `undefined`.
3
+
4
+ Part of the [Standard Objects](https://github.com/10xly/standard-objects) project.
5
+
6
+ ## Installation
7
+ ```bash
8
+ npm install standard-objects-globalthis
9
+ ```
10
+
11
+ ## Usage
12
+ ```javascript
13
+ const $globalThis = require("standard-objects-globalthis")
14
+ const assert = require("assert")
15
+ if (typeof globalThis !== "undefined") {
16
+ assert($globalThis === globalThis)
17
+ } else {
18
+ assert($globalThis === undefined)
19
+ }
20
+ ```
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export = globalThis
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+ var constant = require("lodash.constant")
2
+ var attempt = require("attempt-statement")
3
+ var _return = require("returndotjs/safe")._return
4
+ var functions = require("returndotjs/safe").functions
5
+ var noop = require("n0p3-es2015-cjs")
6
+
7
+ functions.getGlobalThis = function() {
8
+ attempt(() => {
9
+ globalThis.globalThis.globalThis
10
+ _return(require("@10xly/global")) // @10xly/global exports the global object, which is the same as globalThis anyway
11
+ }).rescue(() => {
12
+ _return()
13
+ }).else(noop).ensure(noop).end()
14
+ }
15
+ module.__defineGetter__("exports", constant(functions.getGlobalThis()))
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "standard-objects-globalthis",
3
+ "version": "1.0.0",
4
+ "description": "Standard built-in object globalThis",
5
+ "keywords": [
6
+ "standard",
7
+ "objects"
8
+ ],
9
+ "homepage": "https://github.com/10xly/standard-objects#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/10xly/standard-objects/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/10xly/standard-objects.git"
16
+ },
17
+ "license": "MIT",
18
+ "author": "10x'ly Made",
19
+ "type": "commonjs",
20
+ "main": "index.js",
21
+ "scripts": {
22
+ "test": "echo \"Error: no test specified\" && exit 1"
23
+ },
24
+ "dependencies": {
25
+ "@10xly/global": "1.1.0",
26
+ "attempt-statement": "1.2.1",
27
+ "lodash.constant": "3.0.0",
28
+ "n0p3-es2015-cjs": "1.0.1",
29
+ "returndotjs": "1.1.0",
30
+ "undefined": "0.1.0"
31
+ }
32
+ }