pax_global_header00006660000000000000000000000064127730525340014522gustar00rootroot0000000000000052 comment=b797760224b4b6129c96e42ecb6fab2d56663cc2 es-shims-globalThis-b797760/000077500000000000000000000000001277305253400156275ustar00rootroot00000000000000es-shims-globalThis-b797760/.eslintrc000066400000000000000000000001521277305253400174510ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "rules": { "max-statements-per-line": [2, { "max": 2 }] } } es-shims-globalThis-b797760/.gitignore000066400000000000000000000010301277305253400176110ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory node_modules # Optional npm cache directory .npm # Optional REPL history .node_repl_history dist/ es-shims-globalThis-b797760/.jscs.json000066400000000000000000000100541277305253400175420ustar00rootroot00000000000000{ "es3": true, "additionalRules": [], "requireSemicolons": true, "disallowMultipleSpaces": true, "disallowIdentifierNames": [], "requireCurlyBraces": { "allExcept": [], "keywords": ["if", "else", "for", "while", "do", "try", "catch"] }, "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], "disallowSpaceAfterKeywords": [], "disallowSpaceBeforeComma": true, "disallowSpaceAfterComma": false, "disallowSpaceBeforeSemicolon": true, "disallowNodeTypes": [ "DebuggerStatement", "ForInStatement", "LabeledStatement", "SwitchCase", "SwitchStatement", "WithStatement" ], "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, "requireSpaceBetweenArguments": true, "disallowSpacesInsideParentheses": true, "disallowSpacesInsideArrayBrackets": true, "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] }, "disallowSpaceAfterObjectKeys": true, "requireCommaBeforeLineBreak": true, "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], "requireSpaceAfterPrefixUnaryOperators": [], "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], "requireSpaceBeforePostfixUnaryOperators": [], "disallowSpaceBeforeBinaryOperators": [], "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "disallowSpaceAfterBinaryOperators": [], "disallowImplicitTypeConversion": ["binary", "string"], "disallowKeywords": ["with", "eval"], "requireKeywordsOnNewLine": [], "disallowKeywordsOnNewLine": ["else"], "requireLineFeedAtFileEnd": true, "disallowTrailingWhitespace": true, "disallowTrailingComma": true, "excludeFiles": ["node_modules/**", "vendor/**"], "disallowMultipleLineStrings": true, "requireDotNotation": { "allExcept": ["keywords"] }, "requireParenthesesAroundIIFE": true, "validateLineBreaks": "LF", "validateQuoteMarks": { "escape": true, "mark": "'" }, "disallowOperatorBeforeLineBreak": [], "requireSpaceBeforeKeywords": [ "do", "for", "if", "else", "switch", "case", "try", "catch", "finally", "while", "with", "return" ], "validateAlignedFunctionParameters": { "lineBreakAfterOpeningBraces": true, "lineBreakBeforeClosingBraces": true }, "requirePaddingNewLinesBeforeExport": true, "validateNewlineAfterArrayElements": { "maximum": 1 }, "requirePaddingNewLinesAfterUseStrict": true, "disallowArrowFunctions": true, "disallowMultiLineTernary": true, "validateOrderInObjectKeys": "asc-insensitive", "disallowIdenticalDestructuringNames": true, "disallowNestedTernaries": { "maxLevel": 1 }, "requireSpaceAfterComma": { "allExcept": ["trailing"] }, "requireAlignedMultilineParams": false, "requireSpacesInGenerator": { "afterStar": true }, "disallowSpacesInGenerator": { "beforeStar": true }, "disallowVar": false, "requireArrayDestructuring": false, "requireEnhancedObjectLiterals": false, "requireObjectDestructuring": false, "requireEarlyReturn": false, "requireCapitalizedConstructorsNew": { "allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] }, "requireImportAlphabetized": false, "requireSpaceBeforeObjectValues": true, "requireSpaceBeforeDestructuredValues": true, "disallowSpacesInsideTemplateStringPlaceholders": true, "disallowArrayDestructuringReturn": false, "requireNewlineBeforeSingleStatementsInIf": false, "disallowUnusedVariables": true, "requireSpacesInsideImportedObjectBraces": true, "requireUseStrict": true } es-shims-globalThis-b797760/.npmignore000066400000000000000000000001001277305253400176150ustar00rootroot00000000000000npm-debug.log browserShim.js .npmignore .travis.yml .jscs.json es-shims-globalThis-b797760/.travis.yml000066400000000000000000000044231277305253400177430ustar00rootroot00000000000000language: node_js node_js: - "6.7" - "6.6" - "6.5" - "6.4" - "6.3" - "6.2" - "6.1" - "6.0" - "5.12" - "5.11" - "5.10" - "5.9" - "5.8" - "5.7" - "5.6" - "5.5" - "5.4" - "5.3" - "5.2" - "5.1" - "5.0" - "4.6" - "4.5" - "4.4" - "4.3" - "4.2" - "4.1" - "4.0" - "iojs-v3.3" - "iojs-v3.2" - "iojs-v3.1" - "iojs-v3.0" - "iojs-v2.5" - "iojs-v2.4" - "iojs-v2.3" - "iojs-v2.2" - "iojs-v2.1" - "iojs-v2.0" - "iojs-v1.8" - "iojs-v1.7" - "iojs-v1.6" - "iojs-v1.5" - "iojs-v1.4" - "iojs-v1.3" - "iojs-v1.2" - "iojs-v1.1" - "iojs-v1.0" - "0.12" - "0.11" - "0.10" - "0.9" - "0.8" - "0.6" - "0.4" before_install: - 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' - 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' script: - 'if [ -n "${LINT-}" ]; then npm run lint ; fi' - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi' - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi' sudo: false env: - TEST=true matrix: fast_finish: true include: - node_js: "node" env: LINT=true allow_failures: - node_js: "6.6" - node_js: "6.5" - node_js: "6.4" - node_js: "6.3" - node_js: "6.2" - node_js: "6.1" - node_js: "6.0" - node_js: "5.11" - node_js: "5.10" - node_js: "5.9" - node_js: "5.8" - node_js: "5.7" - node_js: "5.6" - node_js: "5.5" - node_js: "5.4" - node_js: "5.3" - node_js: "5.2" - node_js: "5.1" - node_js: "5.0" - node_js: "4.5" - node_js: "4.4" - node_js: "4.3" - node_js: "4.2" - node_js: "4.1" - node_js: "4.0" - node_js: "iojs-v3.2" - node_js: "iojs-v3.1" - node_js: "iojs-v3.0" - node_js: "iojs-v2.4" - node_js: "iojs-v2.3" - node_js: "iojs-v2.2" - node_js: "iojs-v2.1" - node_js: "iojs-v2.0" - node_js: "iojs-v1.7" - node_js: "iojs-v1.6" - node_js: "iojs-v1.5" - node_js: "iojs-v1.4" - node_js: "iojs-v1.3" - node_js: "iojs-v1.2" - node_js: "iojs-v1.1" - node_js: "iojs-v1.0" - node_js: "0.11" - node_js: "0.9" - node_js: "0.6" - node_js: "0.4" es-shims-globalThis-b797760/CHANGELOG.md000066400000000000000000000005301277305253400174360ustar00rootroot000000000000002.0.0 / 2016-09-28 ================== * [Breaking] Rename `System.global` to `global` * [Deps] update `object-keys` * [Dev Deps] update `browserify`, `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config` * [Tests] up to `node` `v6.7`, `v5.12`, `v4.6`; improve test matrix 1.0.0 / 2016-03-29 ================== * Initial release. es-shims-globalThis-b797760/LICENSE000066400000000000000000000020711277305253400166340ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2016 Jordan Harband Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. es-shims-globalThis-b797760/README.md000066400000000000000000000051001277305253400171020ustar00rootroot00000000000000#system.global [![Version Badge][npm-version-svg]][npm-url] [![Build Status][travis-svg]][travis-url] [![dependency status][deps-svg]][deps-url] [![dev dependency status][dev-deps-svg]][dev-deps-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][npm-badge-png]][npm-url] [![browser support][testling-png]][testling-url] An ECMAScript spec-compliant polyfill/shim for `global`. Invoke its "shim" method to shim `global` if it is unavailable. This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec proposal](https://github.com/tc39/proposal-global). Most common usage: ```js var global = require('system.global')(); // returns native method if compliant /* or */ var global = require('system.global/polyfill')(); // returns native method if compliant ``` ## Example ```js var assert = require('assert'); // the below function is not CSP-compliant, but reliably gets the // global object in sloppy mode in every engine. var getGlobal = Function('return this'); assert.equal(global, getGlobal()); ``` ```js /* when `global` is not present */ var shimmedGlobal = require('system.global').shim(); /* or */ var shimmedGlobal = require('system.global/shim')(); assert.equal(shimmedGlobal, global); assert.equal(shimmedGlobal, getGlobal()); ``` ```js /* when `global` is present */ var shimmedGlobal = require('system.global').shim(); assert.equal(shimmedGlobal, global); assert.equal(shimmedGlobal, getGlobal()); ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [npm-url]: https://npmjs.org/package/system.global [npm-version-svg]: http://versionbadg.es/ljharb/System.global.svg [travis-svg]: https://travis-ci.org/ljharb/System.global.svg [travis-url]: https://travis-ci.org/ljharb/System.global [deps-svg]: https://david-dm.org/ljharb/System.global.svg?theme=shields.io [deps-url]: https://david-dm.org/ljharb/System.global [dev-deps-svg]: https://david-dm.org/ljharb/System.global/dev-status.svg?theme=shields.io [dev-deps-url]: https://david-dm.org/ljharb/System.global#info=devDependencies [testling-png]: https://ci.testling.com/ljharb/System.global.png [testling-url]: https://ci.testling.com/ljharb/System.global [npm-badge-png]: https://nodei.co/npm/system.global.png?downloads=true&stars=true [license-image]: http://img.shields.io/npm/l/system.global.svg [license-url]: LICENSE [downloads-image]: http://img.shields.io/npm/dm/system.global.svg [downloads-url]: http://npm-stat.com/charts.html?package=system.global es-shims-globalThis-b797760/browserShim.js000066400000000000000000000001301277305253400204630ustar00rootroot00000000000000'use strict'; var systemGlobal = require('./'); module.exports = systemGlobal.shim(); es-shims-globalThis-b797760/implementation.js000066400000000000000000000005471277305253400212200ustar00rootroot00000000000000/* globals self, window, global */ /* eslint no-negated-condition: 0, no-new-func: 0 */ 'use strict'; if (typeof self !== 'undefined') { module.exports = self; } else if (typeof window !== 'undefined') { module.exports = window; } else if (typeof global !== 'undefined') { module.exports = global; } else { module.exports = Function('return this')(); } es-shims-globalThis-b797760/index.js000066400000000000000000000006301277305253400172730ustar00rootroot00000000000000'use strict'; var defineProperties = require('define-properties'); var implementation = require('./implementation'); var getPolyfill = require('./polyfill'); var shim = require('./shim'); var polyfill = getPolyfill(); var getGlobal = function () { return polyfill; }; defineProperties(getGlobal, { getPolyfill: getPolyfill, implementation: implementation, shim: shim }); module.exports = getGlobal; es-shims-globalThis-b797760/package.json000066400000000000000000000036501277305253400201210ustar00rootroot00000000000000{ "name": "system.global", "version": "2.0.0", "author": "Jordan Harband", "description": "ECMAScript spec-compliant polyfill/shim for `global`", "license": "MIT", "main": "index.js", "scripts": { "pretest": "npm run --silent lint && es-shim-api --bound --property", "test": "npm run --silent tests-only", "posttest": "npm run --silent security", "tests-only": "npm run --silent test:implementation && npm run --silent test:shim", "test:native": "node test/native.js", "test:shim": "node test/shimmed.js", "test:implementation": "node test/index.js", "coverage": "covert test/*.js", "coverage:quiet": "covert test/*.js --quiet", "lint": "npm run --silent jscs && npm run --silent eslint", "eslint": "eslint *.js test/*.js", "jscs": "jscs *.js test/*.js", "build": "mkdir -p dist && browserify browserShim.js > dist/browser.js", "prepublish": "npm run --silent build", "security": "nsp check" }, "repository": { "type": "git", "url": "git://github.com/ljharb/System.global.git" }, "keywords": [ "window", "self", "global", "System.global", "global object", "ECMAScript", "es-shim API", "polyfill", "shim" ], "dependencies": { "function-bind": "^1.1.0", "object-keys": "^1.0.11", "define-properties": "^1.1.2" }, "devDependencies": { "browserify": "^13.1.0", "is": "^3.1.0", "tape": "^4.6.0", "covert": "^1.1.0", "jscs": "^3.0.7", "nsp": "^2.6.1", "eslint": "^3.6.1", "@ljharb/eslint-config": "^8.0.0", "@es-shims/api": "^1.2.0", "for-each": "^0.3.2" }, "testling": { "files": "test/index.js", "browsers": [ "iexplore/6.0..latest", "firefox/3.0..6.0", "firefox/15.0..latest", "firefox/nightly", "chrome/4.0..10.0", "chrome/20.0..latest", "chrome/canary", "opera/10.0..latest", "opera/next", "safari/4.0..latest", "ipad/6.0..latest", "iphone/6.0..latest", "android-browser/4.2" ] }, "engines": { "node": ">= 0.4" } } es-shims-globalThis-b797760/polyfill.js000066400000000000000000000003731277305253400200220ustar00rootroot00000000000000'use strict'; var implementation = require('./implementation'); module.exports = function getPolyfill() { if (typeof global !== 'object' || !global || global.Math !== Math || global.Array !== Array) { return implementation; } return global; }; es-shims-globalThis-b797760/shim.js000066400000000000000000000012331277305253400171240ustar00rootroot00000000000000'use strict'; var define = require('define-properties'); var getPolyfill = require('./polyfill'); module.exports = function shimGlobal() { var polyfill = getPolyfill(); if (define.supportsDescriptors) { var descriptor = Object.getOwnPropertyDescriptor(polyfill, 'global'); if (!descriptor || (descriptor.configurable && (descriptor.enumerable || descriptor.writable || global !== polyfill))) { Object.defineProperty(polyfill, 'global', { configurable: true, enumerable: false, value: polyfill, writable: false }); } } else if (typeof global !== 'object' || global !== polyfill) { polyfill.global = polyfill; } return polyfill; }; es-shims-globalThis-b797760/test/000077500000000000000000000000001277305253400166065ustar00rootroot00000000000000es-shims-globalThis-b797760/test/index.js000066400000000000000000000003041277305253400202500ustar00rootroot00000000000000'use strict'; var systemGlobal = require('../'); var test = require('tape'); var runTests = require('./tests'); test('as a function', function (t) { runTests(systemGlobal(), t); t.end(); }); es-shims-globalThis-b797760/test/native.js000066400000000000000000000010661277305253400204350ustar00rootroot00000000000000'use strict'; var test = require('tape'); var defineProperties = require('define-properties'); var isEnumerable = Object.prototype.propertyIsEnumerable; var runTests = require('./tests'); test('native', function (t) { t.equal(typeof global, 'object', 'global is an object'); t.equal(global in global, true, 'global is in global'); t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) { et.equal(false, isEnumerable.call(global, 'global'), 'global is not enumerable'); et.end(); }); runTests(global, t); t.end(); }); es-shims-globalThis-b797760/test/shimmed.js000066400000000000000000000015551277305253400206000ustar00rootroot00000000000000'use strict'; var systemGlobal = require('../'); systemGlobal.shim(); var test = require('tape'); var defineProperties = require('define-properties'); var isEnumerable = Object.prototype.propertyIsEnumerable; var runTests = require('./tests'); test('shimmed', function (t) { t.equal(typeof global, 'object', 'global is an object'); t.equal('global' in global, true, 'global is in global'); t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) { et.equal(false, isEnumerable.call(global, 'global'), 'global.global is not enumerable'); et.end(); }); t.test('writability', { skip: !defineProperties.supportsDescriptors }, function (wt) { var desc = Object.getOwnPropertyDescriptor(global, 'global'); wt.equal(desc.writable, false, 'global.global is not writable'); wt.end(); }); runTests(global.global, t); t.end(); }); es-shims-globalThis-b797760/test/tests.js000066400000000000000000000025161277305253400203120ustar00rootroot00000000000000/* jscs:disable requireUseStrict */ /* eslint strict: 0, max-statements: 0 */ module.exports = function (theGlobal, t) { t.equal(typeof theGlobal, 'object', 'is an object'); t.test('built-in globals', function (st) { st.equal(theGlobal.Math, Math, 'Math is on the global'); st.equal(theGlobal.JSON, JSON, 'JSON is on the global'); st.equal(theGlobal.String, String, 'String is on the global'); st.equal(theGlobal.Array, Array, 'Array is on the global'); st.equal(theGlobal.Number, Number, 'Number is on the global'); st.equal(theGlobal.Boolean, Boolean, 'Boolean is on the global'); st.equal(theGlobal.Object, Object, 'Object is on the global'); st.equal(theGlobal.Function, Function, 'Function is on the global'); st.equal(theGlobal.Date, Date, 'Date is on the global'); st.equal(theGlobal.RegExp, RegExp, 'RegExp is on the global'); if (typeof Symbol === 'undefined') { st.comment('# SKIP Symbol is not supported'); } else { st.equal(theGlobal.Symbol, Symbol, 'Symbol is on the global'); } st.end(); }); t.test('custom property', function (st) { var key = 'random_custom_key_' + new Date().getTime(); var semaphore = {}; /* eslint no-eval: 1 */ eval(key + ' = semaphore;'); st.equal(theGlobal[key], semaphore, 'global variable ends up on the global object'); delete theGlobal[key]; st.end(); }); };