polyfill.js 638 B

123456789101112131415161718192021
  1. 'use strict';
  2. var callBind = require('call-bind');
  3. var implementation = require('./implementation');
  4. var ownSlice = typeof ArrayBuffer === 'function' && new ArrayBuffer(0).slice;
  5. var ownSliceBound = ownSlice && callBind(ownSlice);
  6. var ownSliceWrapper = ownSliceBound && function slice(start, end) {
  7. /* eslint no-invalid-this: 0 */
  8. if (arguments.length < 2) {
  9. return ownSliceBound(this, arguments.length > 0 ? start : 0);
  10. }
  11. return ownSliceBound(this, start, end);
  12. };
  13. module.exports = function getPolyfill() {
  14. return (typeof ArrayBuffer === 'function' && ArrayBuffer.prototype.slice)
  15. || ownSliceWrapper
  16. || implementation;
  17. };