Socket
Socket
Sign inDemoInstall

antiglobal

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    antiglobal

Node/browser library to detect global/window namespace pollution


Version published
Weekly downloads
7
decreased by-66.67%
Maintainers
1
Install size
22.0 kB
Created
Weekly downloads
 

Readme

Source

antiglobal

Node/browser library to detect global/window namespace pollution.

Installation

  • With npm:
$ npm install antiglobal

NPM

  • With bower:
$ bower install antiglobal

Usage in Node

var antiglobal = require('antiglobal');

Browserified library

Take a browserified version of the library from the dist/ folder:

  • dist/antiglobal-X.Y.Z.js: The uncompressed version.
  • dist/antiglobal-X.Y.Z.min.js: The compressed production-ready version.
  • dist/antiglobal.js: A copy of the uncompressed version.

They all expose the global window.antiglobal function.

<script src='antiglobal.js'></script>

Usage Example

<script src='js/antiglobal.js'></script>

<script src='js/foo.js'></script>  // Creates window.FOO

<script>
    antiglobal('FOO');  // OK, returns true
</script>

<script src='js/bar.js'></script>  // Creates window.BAR

<script>
    antiglobal('QWE');  // ERROR: given globals do not match real new globals
                        // [given: QWE | real: BAR]
</script>

Documentation

antiglobal(name1, name2, ...) function
  • nameN: The name (string) of a new expected element in the global/window namespace.

Returns true if given arguments match the new elements in the global/window namespace. It updates the list of elements in the global/window namespace for the next execution.

antiglobal.reset() function

Reset the list of elements in the global/window namespace. Useful to ignore globals introduced by a library while still allowing antiglobal() to check other libraries loaded after that.

antiglobal.log read/write property

If set to true, errors when calling antiglobal() are logged to console.error. Default value is true.

antiglobal.throw read/write property

If set to true, errors when calling antiglobal() throw an Error exception. Default value is false.

Author

Iñaki Baz Castillo.

License

ISC.

FAQs

Last updated on 09 Nov 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc