From d328cac8e222ffb294101c442597d5b45d93471c Mon Sep 17 00:00:00 2001 From: Ryan Kennedy Date: Mon, 16 Oct 2017 17:52:45 -0400 Subject: [PATCH] Update: Polyfill Proxy on Node 4 --- .travis.yml | 1 + README.md | 2 +- package-lock.json | 61 +++++++++++++++++++++++++---------------------- package.json | 7 +++++- src/index.js | 4 ++++ 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2f71d2..d09020f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ node_js: - '8' - '7' - '6' + - '4' before_script: - npm prune script: diff --git a/README.md b/README.md index 91b0b2a..568764a 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ describe('Example test suite', function () { `anticipated-call` intercepts function calls with [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), and returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). To do this, the `Proxy` and `Promise` constructors must be available as globals. -If you're running Node 8, these are included in core, so you don't have to do anything. Similarly, if you're using `babel-polyfill` or similar, this is handled for you. +The `Promise` constructor is assumed to be available, since it was implemented in Node 4. If `Proxy` is not available, it will be polyfilled. ## API diff --git a/package-lock.json b/package-lock.json index 22a3a14..76ce87a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -107,6 +107,16 @@ } } }, + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "abab": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", @@ -1575,8 +1585,8 @@ "integrity": "sha512-8od6g684Fhi5Vpp4ABRv/RBsW1AY6wSHbJHEK6FGTv+8jvAAnlABniZu/FVmX9TcirkHepaEsa1QGkRvbg0CKw==", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.1", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.2.0", @@ -3017,14 +3027,6 @@ } } }, - "string_decoder": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, "string-width": { "version": "1.0.2", "bundled": true, @@ -3035,6 +3037,14 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, "stringstream": { "version": "0.0.5", "bundled": true, @@ -3452,6 +3462,11 @@ } } }, + "harmony-reflect": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/harmony-reflect/-/harmony-reflect-1.5.1.tgz", + "integrity": "sha1-tUymF7AMyK71Wbuxez2FQx3H4yk=" + }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", @@ -4894,16 +4909,6 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -6452,15 +6457,6 @@ "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-length": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/string-length/-/string-length-2.0.0.tgz", @@ -6499,6 +6495,15 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", diff --git a/package.json b/package.json index 12439dd..5d4549b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "test": "jest", "semantic-release": "semantic-release pre && npm publish && semantic-release post" }, - "files": ["lib"], + "files": [ + "lib" + ], "author": "Ryan Kennedy ", "license": "MIT", "release": { @@ -34,5 +36,8 @@ "eslint-config-react-app": "^2.0.1", "jest": "^21.2.1", "semantic-release": "^8.0.3" + }, + "dependencies": { + "harmony-reflect": "^1.5.1" } } diff --git a/src/index.js b/src/index.js index ebf66af..1c92eae 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,9 @@ const EventEmitter = require('events'); +if (typeof Proxy === 'undefined') { + require('harmony-reflect'); +} + class Anticipated extends EventEmitter { nthNextCall(n) { let counter = 0;