slimfits
Version:
Package for loading data stored in FITS data format
27 lines • 1.21 kB
JavaScript
import { ArrayUtils } from '../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.generateTypedArray(bitPix, length);
ArrayUtils.copy(this.data, typedArray.buffer, start, length, bitPix, changeEndian);
return Promise.resolve(typedArray);
};
return ArrayBufferFile;
}());
export { ArrayBufferFile };
//# sourceMappingURL=ArrayBufferFile.js.map