UNPKG

slimfits

Version:

Package for loading data stored in FITS data format

32 lines 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var PromiseUtils_1 = require("../utils/PromiseUtils"); var ArrayUtils_1 = require("../utils/ArrayUtils"); var SingleRequestFile = /** @class */ (function () { function SingleRequestFile(url) { this.url = url; } SingleRequestFile.prototype.initialize = function () { var _this = this; return PromiseUtils_1.PromiseUtils.getRequestAsync(this.url).then(function (xhr) { _this.data = xhr.response; return (_this.getByteLength() % 2880 === 0); }); }; SingleRequestFile.prototype.getByteLength = function () { var byteLength = this.data.byteLength; return this.data != null ? this.data.byteLength : 0; }; SingleRequestFile.prototype.getStringAsync = function (start, length) { return Promise.resolve(String.fromCharCode.apply(null, new Uint8Array(this.data, start, length))); }; SingleRequestFile.prototype.getDataAsync = function (start, length, bitPix, changeEndian) { if (changeEndian === void 0) { changeEndian = true; } var typedArray = ArrayUtils_1.ArrayUtils.generateTypedArray(bitPix, length); ArrayUtils_1.ArrayUtils.copy(this.data, typedArray.buffer, start, length, bitPix, changeEndian); return Promise.resolve(typedArray); }; return SingleRequestFile; }()); exports.SingleRequestFile = SingleRequestFile; //# sourceMappingURL=SingleRequestFile.js.map