add some more polyfills for old browsers
This commit is contained in:
parent
89f86d83d5
commit
bdf1ce8d64
8
npm-shrinkwrap.json
generated
8
npm-shrinkwrap.json
generated
|
@ -1920,7 +1920,8 @@
|
||||||
"core-js": {
|
"core-js": {
|
||||||
"version": "2.5.3",
|
"version": "2.5.3",
|
||||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz",
|
||||||
"integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4="
|
"integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
@ -2422,11 +2423,6 @@
|
||||||
"event-emitter": "0.3.5"
|
"event-emitter": "0.3.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"es6-promise": {
|
|
||||||
"version": "4.2.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz",
|
|
||||||
"integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ=="
|
|
||||||
},
|
|
||||||
"es6-set": {
|
"es6-set": {
|
||||||
"version": "0.1.5",
|
"version": "0.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz",
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
"browserify-derequire": "^0.9.4",
|
"browserify-derequire": "^0.9.4",
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
|
"core-js": "^2.5.3",
|
||||||
"eslint": "^4.16.0",
|
"eslint": "^4.16.0",
|
||||||
"eslint-config-airbnb": "^16.1.0",
|
"eslint-config-airbnb": "^16.1.0",
|
||||||
"eslint-config-airbnb-base": "^12.1.0",
|
"eslint-config-airbnb-base": "^12.1.0",
|
||||||
|
@ -78,9 +79,7 @@
|
||||||
"babel-plugin-transform-remove-strict-mode": "0.0.2",
|
"babel-plugin-transform-remove-strict-mode": "0.0.2",
|
||||||
"bn.js": "^4.11.8",
|
"bn.js": "^4.11.8",
|
||||||
"buffer": "^5.0.8",
|
"buffer": "^5.0.8",
|
||||||
"core-js": "^2.5.3",
|
|
||||||
"elliptic": "git+https://github.com/openpgpjs/elliptic.git",
|
"elliptic": "git+https://github.com/openpgpjs/elliptic.git",
|
||||||
"es6-promise": "^4.2.4",
|
|
||||||
"jwk-to-pem": "^1.2.6",
|
"jwk-to-pem": "^1.2.6",
|
||||||
"node-fetch": "^1.7.3",
|
"node-fetch": "^1.7.3",
|
||||||
"node-localstorage": "~1.3.0",
|
"node-localstorage": "~1.3.0",
|
||||||
|
|
|
@ -41,12 +41,10 @@ import config from './config/config';
|
||||||
import util from './util';
|
import util from './util';
|
||||||
import AsyncProxy from './worker/async_proxy';
|
import AsyncProxy from './worker/async_proxy';
|
||||||
|
|
||||||
// Polyfills
|
// Old browser polyfills
|
||||||
require('core-js/fn/array/fill');
|
if (typeof window !== 'undefined') {
|
||||||
require('core-js/fn/array/find');
|
require('./polyfills');
|
||||||
require('core-js/fn/array/from');
|
}
|
||||||
require('core-js/fn/typed/uint8-array');
|
|
||||||
require('core-js/fn/symbol');
|
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// //
|
// //
|
||||||
|
|
36
src/polyfills.js
Normal file
36
src/polyfills.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// Old browser polyfills
|
||||||
|
// All are listed as dev dependencies because Node does not need them
|
||||||
|
// and for browser babel will take care of it
|
||||||
|
|
||||||
|
if (typeof window.fetch === 'undefined') {
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
require('whatwg-fetch');
|
||||||
|
}
|
||||||
|
if (typeof Array.prototype.fill === 'undefined') {
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
require('core-js/fn/array/fill');
|
||||||
|
}
|
||||||
|
if (typeof Array.prototype.find === 'undefined') {
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
require('core-js/fn/array/find');
|
||||||
|
}
|
||||||
|
if (typeof Array.from === 'undefined') {
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
require('core-js/fn/array/from');
|
||||||
|
}
|
||||||
|
if (typeof Promise === 'undefined') {
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
require('core-js/fn/promise');
|
||||||
|
}
|
||||||
|
if (typeof Uint8Array.from === 'undefined') {
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
require('core-js/fn/typed/uint8-array');
|
||||||
|
}
|
||||||
|
if (typeof String.prototype.repeat === 'undefined') {
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
require('core-js/fn/string/repeat');
|
||||||
|
}
|
||||||
|
if (typeof Symbol === 'undefined') {
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
require('core-js/fn/symbol');
|
||||||
|
}
|
|
@ -19,11 +19,6 @@
|
||||||
|
|
||||||
self.window = {}; // to make UMD bundles work
|
self.window = {}; // to make UMD bundles work
|
||||||
|
|
||||||
// ES6 Promise polyfill
|
|
||||||
if (typeof Promise === 'undefined') {
|
|
||||||
require('es6-promise').polyfill();
|
|
||||||
}
|
|
||||||
|
|
||||||
importScripts('openpgp.js');
|
importScripts('openpgp.js');
|
||||||
var openpgp = window.openpgp;
|
var openpgp = window.openpgp;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
// ES6 Promise polyfill
|
|
||||||
if (typeof Promise === 'undefined') {
|
|
||||||
require('es6-promise').polyfill();
|
|
||||||
}
|
|
||||||
|
|
||||||
(typeof window !== 'undefined' ? window : global).resolves = function(val) {
|
(typeof window !== 'undefined' ? window : global).resolves = function(val) {
|
||||||
return new Promise(function(res) { res(val); });
|
return new Promise(function(res) { res(val); });
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user