JSPM

system.global

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q9609F
  • License MIT

ECMAScript spec-compliant polyfill/shim for `System.global`

Package Exports

  • system.global
  • system.global/implementation

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (system.global) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

#system.global Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

An ECMAScript spec-compliant polyfill/shim for System.global. Invoke its "shim" method to shim System.global if it is unavailable.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec proposal.

Most common usage:

var global = require('system.global'); // returns native method if compliant
    /* or */
var global = require('system.global/polyfill')(); // returns native method if compliant

Example

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());
/* when System or System.global is not present */
if (typeof System === 'object') { delete System.global; }
delete System;
var shimmedGlobal = require('system.global').shim();
    /* or */
var shimmedGlobal = require('system.global/shim')();

assert.equal(shimmedGlobal, global);
assert.equal(shimmedGlobal, System.global);
assert.equal(shimmedGlobal, getGlobal());
/* when System.global is present */
var shimmedGlobal = require('system.global').shim();

assert.equal(shimmedGlobal, System.global);
assert.equal(shimmedGlobal, getGlobal());

Tests

Simply clone the repo, npm install, and run npm test