v13.js 1.0 KB

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const tslib_1 = require("tslib");
  4. const v10_1 = tslib_1.__importDefault(require("./v10"));
  5. let decode = v10_1.default;
  6. const hasBuffer = typeof Buffer !== 'undefined';
  7. const utf8Slice = hasBuffer ? Buffer.prototype.utf8Slice : null;
  8. if (utf8Slice) {
  9. decode = (buf, start, length) => length <= 10 ? (0, v10_1.default)(buf, start, length) : utf8Slice.call(buf, start, start + length);
  10. }
  11. else {
  12. const from = hasBuffer ? Buffer.from : null;
  13. if (from) {
  14. decode = (buf, start, length) => length < 30
  15. ? (0, v10_1.default)(buf, start, length)
  16. : from(buf)
  17. .subarray(start, start + length)
  18. .toString();
  19. }
  20. else if (typeof TextDecoder !== 'undefined') {
  21. const decoder = new TextDecoder();
  22. decode = (buf, start, length) => length < 150 ? (0, v10_1.default)(buf, start, length) : decoder.decode(buf.subarray(start, start + length));
  23. }
  24. }
  25. exports.default = decode;
  26. //# sourceMappingURL=v13.js.map