es-blur 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # es-blur <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
+
3
+ A drop-in shim/polyfill/replacement for `window.blur()` that works as far down as ES3.
4
+
5
+ ## Installation
6
+
7
+ Using NPM:
8
+ ```bash
9
+ $ npm install --save es-blur
10
+ ```
11
+ Using Yarn:
12
+ ```bash
13
+ $ yarn add es-blur
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ If you want to shim `blur` into a global variable, use like this:
19
+
20
+ ```js
21
+ require('es-blur/auto')
22
+
23
+ console.log(blur) // Output: [Function: blur]
24
+ ```
25
+
26
+ If you just want to require the implementation, do this instead:
27
+
28
+ ```js
29
+ var blur = require('es-blur/implementation')
30
+
31
+ console.log(blur) // Output: [Function: blur]
32
+ ```
package/auto.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ require("./shim")();
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ function blur() {}
4
+
5
+ module.exports = blur;
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ throw new Error(
2
+ 'Do not require es-blur directly, instead use es-blur/auto or es-blur/implementation depending on the usage. See the README for more information.'
3
+ )
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "es-blur",
3
+ "version": "1.0.0",
4
+ "description": "A drop-in shim/polyfill/replacement for `window.blur() that works as far down as ES3.",
5
+ "keywords": [
6
+ "blur",
7
+ "polyfill",
8
+ "shim"
9
+ ],
10
+ "homepage": "https://github.com/tj-commits/es-blur#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/tj-commits/es-blur/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/tj-commits/es-blur.git"
17
+ },
18
+ "license": "MIT",
19
+ "author": "me",
20
+ "type": "commonjs",
21
+ "main": "index.js",
22
+ "scripts": {
23
+ "test": "echo \"Error: no test specified\" && exit 1"
24
+ },
25
+ "dependencies": {
26
+ "const": "^1.0.0",
27
+ "define-properties": "^1.2.1"
28
+ }
29
+ }
package/polyfill.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ var implementation = require("./implementation");
4
+ var constant = require("const");
5
+
6
+ module.exports = constant(implementation);
package/shim-helper.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var define = require("define-properties");
4
+
5
+ module.exports = function shimHelper(object, property, getPolyfill) {
6
+ return function shim() {
7
+ var polyfill = getPolyfill();
8
+ var o = {};
9
+ o[property] = polyfill;
10
+ var p = {};
11
+ p[property] = function () {
12
+ return object[property] !== polyfill;
13
+ };
14
+ define(object, o, p);
15
+ return polyfill;
16
+ };
17
+ };
package/shim.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var getPolyfill = require("./polyfill");
4
+ var shimHelper = require("./shim-helper");
5
+
6
+ function shim() {
7
+ try {
8
+ shimHelper(window, "blur", getPolyfill)();
9
+ } catch {}
10
+ try {
11
+ shimHelper(global, "blur", getPolyfill)();
12
+ } catch {}
13
+ try {
14
+ shimHelper(self, "blur", getPolyfill)();
15
+ } catch {}
16
+ try {
17
+ shimHelper(globalThis, "blur", getPolyfill)();
18
+ } catch {}
19
+ }
20
+
21
+ module.exports = shim;
package/t.js ADDED
@@ -0,0 +1,2 @@
1
+ require('./auto')
2
+ console.log(global.blur)