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 interface. It works in an ES3-supported environment and complies with the spec proposal.
Most common usage:
var global = ; // returns native method if compliant /* or */var global = ; // returns native method if compliant
Example
var 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;
/* when `global` is not present */var shimmedGlobal = ; /* or */var shimmedGlobal = ; assert;assert;
/* when `global` is present */var shimmedGlobal = ; assert;assert;
Tests
Simply clone the repo, npm install
, and run npm test