UNPKG

slimfits

Version:

Package for loading data stored in FITS data format

29 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ArrayUtils_1 = require("../utils/ArrayUtils"); var ArrayBufferFile = /** @class */ (function () { function ArrayBufferFile(data) { this.data = data; } ArrayBufferFile.prototype.initialize = function () { var _this = this; return this.getStringAsync(0, 6).then(function (value) { return (value === 'SIMPLE') && (_this.getByteLength() % 2880 === 0); }); }; ArrayBufferFile.prototype.getByteLength = function () { return this.data != null ? this.data.byteLength : 0; }; ArrayBufferFile.prototype.getStringAsync = function (start, length) { return Promise.resolve(String.fromCharCode.apply(null, new Uint8Array(this.data, start, length))); }; ArrayBufferFile.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 ArrayBufferFile; }()); exports.ArrayBufferFile = ArrayBufferFile; //# sourceMappingURL=ArrayBufferFile.js.map