Skip to content

Commit 68ef898

Browse files
committed
Merge pull request #157 from marco-c/polyfills_without_semver
Polyfills without semver
2 parents a612120 + 57cb1ac commit 68ef898

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"http_ece": "^0.5.1",
3636
"jws": "^3.1.3",
3737
"minimist": "^1.2.0",
38-
"semver": "^5.1.0",
3938
"urlsafe-base64": "^1.0.0"
4039
},
4140
"devDependencies": {

shim.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
var semver = require('semver');
2-
if (semver.satisfies(process.version, '>= 0.12.0')) {
3-
return;
1+
if (typeof Promise === 'undefined') {
2+
global.Promise = require('bluebird');
43
}
54

6-
global.Promise = require('bluebird');
7-
require('array.prototype.find').shim();
8-
require('buffer-compare-shim');
9-
require('buffer-equals-polyfill');
10-
require('crypto').createECDH = require('create-ecdh');
5+
if (!Array.prototype.find) {
6+
require('array.prototype.find').shim();
7+
}
8+
9+
if (!Buffer.prototype.compare || !Buffer.compare) {
10+
require('buffer-compare-shim');
11+
}
12+
13+
if (!Buffer.prototype.equals) {
14+
require('buffer-equals-polyfill');
15+
}
16+
17+
var crypto = require('crypto');
18+
19+
if (!crypto.createECDH) {
20+
crypto.createECDH = require('create-ecdh');
21+
}

0 commit comments

Comments
 (0)