-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshim.js
31 lines (27 loc) · 953 Bytes
/
shim.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
var supportsDescriptors = require('has-property-descriptors')();
var gOPD = require('gopd');
var getPolyfill = require('./polyfill');
var defineProperty = Object.defineProperty;
var $TypeError = require('es-errors/type');
var $SyntaxError = require('es-errors/syntax');
var getProto = require('get-proto');
module.exports = function shimDetached() {
if (!supportsDescriptors || !getProto) {
throw new $TypeError('ArrayBuffer.prototype.detached requires a true ES5+ environment that supports property descriptors');
}
if (typeof ArrayBuffer !== 'function') {
throw new $SyntaxError('ArrayBuffer is not available in this environment');
}
var polyfill = getPolyfill();
var proto = ArrayBuffer.prototype;
var descriptor = gOPD(proto, 'detached');
if (!descriptor || descriptor.get !== polyfill) {
defineProperty(proto, 'detached', {
configurable: true,
enumerable: false,
get: polyfill
});
}
return polyfill;
};