https://github.com/fraction/exports-polyfill
A JavaScript polyfill for using the global namespace with `module.exports`.
https://github.com/fraction/exports-polyfill
Last synced: over 1 year ago
JSON representation
A JavaScript polyfill for using the global namespace with `module.exports`.
- Host: GitHub
- URL: https://github.com/fraction/exports-polyfill
- Owner: fraction
- License: other
- Created: 2014-07-07T23:31:35.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-11-07T03:15:32.000Z (over 10 years ago)
- Last Synced: 2024-04-14T23:30:09.096Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 172 KB
- Stars: 7
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Exports Polyfill
=======================
A JavaScript polyfill for using the global namespace with `module.exports`.
## Usage
Use `module.exports` as described in the [documentation](http://nodejs.org/api/modules.html#modules_module_exports) to **read/extend** the namespace.
```js
module.exports = {
foo: 42
};
console.log(module.exports.foo); // 42
console.log(foo); // 42
```
Use the `exports` [shortcut](http://nodejs.org/api/modules.html#modules_exports_alias) to **read** the namespace.
```js
module.exports = {
foo: 42
};
console.log(exports.foo); // 42
```
Use `module.namespace` to **change** the namespace.
```js
var obj = {};
module.namespace = obj;
module.exports = {
foo: 42
};
console.log(obj.foo); // 42
console.log(exports.foo); // 42
```
## Support
Please [open an issue](https://github.com/fraction/exports-polyfill/issues/new) for questions and concerns.
## Contributing
Fork this repository, commit your changes, and [open a pull request](https://github.com/fraction/exports-polyfill/compare/).