Skip to content

Commit

Permalink
read me
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 30, 2016
1 parent f01b02d commit f6df9b3
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#system.global <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>

[![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 `System.global`. Invoke its "shim" method to shim System.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 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());
```

```js
/* 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`

[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

0 comments on commit f6df9b3

Please sign in to comment.