loaders.gl
Version:
Framework-independent loaders for 3D graphics formats
55 lines (42 loc) • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
// The MIT License (MIT) Copyright (c) 2016 Till Affeldt
/* global window */
// allowed encoding strings for utf-8
var utf8Encodings = ['utf8', 'utf-8', 'unicode-1-1-utf-8'];
var TextEncoderPolyfill =
/*#__PURE__*/
function () {
function TextEncoderPolyfill(encoding) {
_classCallCheck(this, TextEncoderPolyfill);
if (utf8Encodings.indexOf(encoding) < 0 && typeof encoding !== 'undefined' && encoding !== null) {
throw new RangeError('Invalid encoding type. Only utf-8 is supported');
} else {
this.encoding = 'utf-8';
}
}
_createClass(TextEncoderPolyfill, [{
key: "encode",
value: function encode(str) {
if (typeof str !== 'string') {
throw new TypeError('passed argument must be of tye string');
}
var binstr = unescape(encodeURIComponent(str));
var arr = new Uint8Array(binstr.length);
binstr.split('').forEach(function (char, i) {
arr[i] = char.charCodeAt(0);
});
return arr;
}
}]);
return TextEncoderPolyfill;
}();
var _default = typeof window !== 'undefined' ? window.TextEncoder : TextEncoderPolyfill;
exports.default = _default;
//# sourceMappingURL=text-encoder.js.map