antiglobal
Advanced tools
Comparing version 0.1.0 to 0.1.2
{ | ||
"name": "antiglobal", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "Node/browser library to detect global/window namespace pollution", | ||
@@ -5,0 +5,0 @@ "main": "dist/antiglobal.js", |
@@ -63,2 +63,10 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.antiglobal=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
/** | ||
* Reset current globals. | ||
*/ | ||
antiglobal.reset = function() { | ||
lastGlobals = getGlobals(); | ||
}; | ||
/** | ||
* Public properties. | ||
@@ -89,3 +97,6 @@ */ | ||
if (global.hasOwnProperty(key)) { | ||
globals.push(key); | ||
// Ignore this module. | ||
if (key !== 'antiglobal') { | ||
globals.push(key); | ||
} | ||
} | ||
@@ -92,0 +103,0 @@ } |
13
index.js
@@ -61,2 +61,10 @@ /** | ||
/** | ||
* Reset current globals. | ||
*/ | ||
antiglobal.reset = function() { | ||
lastGlobals = getGlobals(); | ||
}; | ||
/** | ||
* Public properties. | ||
@@ -87,3 +95,6 @@ */ | ||
if (global.hasOwnProperty(key)) { | ||
globals.push(key); | ||
// Ignore this module. | ||
if (key !== 'antiglobal') { | ||
globals.push(key); | ||
} | ||
} | ||
@@ -90,0 +101,0 @@ } |
{ | ||
"name": "antiglobal", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "Node/browser library to detect global/window namespace pollution", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,15 +44,16 @@ # antiglobal | ||
```javascript | ||
```html | ||
<script src='js/antiglobal.js'></script> | ||
<script src='js/foo.js'></script> // Creates window.FOO. | ||
<script src='js/foo.js'></script> // Creates window.FOO | ||
<script> | ||
antiglobal('FOO'); // OK, returns true. | ||
antiglobal('FOO'); // OK, returns true | ||
</script> | ||
<script src='js/bar.js'></script> // Creates window.BAR. | ||
<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] | ||
antiglobal('QWE'); // ERROR: given globals do not match real new globals | ||
// [given: QWE | real: BAR] | ||
</script> | ||
@@ -72,2 +73,7 @@ ``` | ||
#### `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 | ||
@@ -74,0 +80,0 @@ |
@@ -8,3 +8,2 @@ var antiglobal = require('../'); | ||
test.ok(antiglobal()); | ||
test.done(); | ||
@@ -17,3 +16,2 @@ }, | ||
test.ok(antiglobal('AAA')); | ||
test.done(); | ||
@@ -27,3 +25,2 @@ }, | ||
test.ok(antiglobal('BBB', 'CCC')); | ||
test.done(); | ||
@@ -48,5 +45,13 @@ }, | ||
test.ok(antiglobal()); | ||
test.done(); | ||
}, | ||
'antiglobal.reset() works': function(test) { | ||
global.FFF = 'fff'; | ||
antiglobal.reset(); | ||
test.ok(antiglobal()); | ||
test.done(); | ||
} | ||
}; |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
21150
369
98