diff --git a/src/header/__tests__/parseFITSHeaderBlock.ts b/src/header/__tests__/parseFITSHeaderBlock.spec.ts similarity index 95% rename from src/header/__tests__/parseFITSHeaderBlock.ts rename to src/header/__tests__/parseFITSHeaderBlock.spec.ts index cc62d14..35d7bca 100644 --- a/src/header/__tests__/parseFITSHeaderBlock.ts +++ b/src/header/__tests__/parseFITSHeaderBlock.spec.ts @@ -8,7 +8,7 @@ import { describe, expect, it, suite } from 'vitest' -import { parseFITSHeaderBlock } from '../' +import { parseFITSHeaderBlock } from '..' /*****************************************************************************************************************/ diff --git a/src/header/readFITSHeaderFromBlocks.ts b/src/header/readFITSHeaderFromBlocks.ts index 64d440b..ba38f3a 100644 --- a/src/header/readFITSHeaderFromBlocks.ts +++ b/src/header/readFITSHeaderFromBlocks.ts @@ -6,9 +6,9 @@ /*****************************************************************************************************************/ -import { FITSBlock } from '../types' +import { FITSBlock, FITSHeader } from '../types' -import { parseFITSHeaderBlock } from '../header' +import { parseFITSHeaderRow, parseFITSHeaderBlock } from '../header' import { readBlockAsArrayBuffer } from '../utilities' @@ -25,7 +25,10 @@ import { readBlockAsArrayBuffer } from '../utilities' export const readFITSHeaderFromBlocks = async ( file: File, blocks: FITSBlock[] -): Promise<FITSBlock[]> => { +): Promise<{ + headers: FITSHeader[] + blocks: FITSBlock[] +}> => { for (const block of blocks) { // obtain the individual slices of the file: const blob = file.slice(block.offsetStart, block.offsetEnd) @@ -34,7 +37,10 @@ export const readFITSHeaderFromBlocks = async ( const { headers, end, parsed } = await readBlockAsArrayBuffer(blob, parseFITSHeaderBlock) // the raw parsed string from the array buffer: - block.headers = headers + for (const header of headers) { + block.headers.push(parseFITSHeaderRow(header)) + } + // make a note of the block that has been parsed: block.parsed = parsed @@ -43,5 +49,8 @@ export const readFITSHeaderFromBlocks = async ( } // return the original blocks: - return blocks + return { + blocks, + headers: blocks.flatMap(block => block.headers) + } } diff --git a/src/types/block.ts b/src/types/block.ts index 2a71bb1..31ff9d5 100644 --- a/src/types/block.ts +++ b/src/types/block.ts @@ -6,6 +6,10 @@ /*****************************************************************************************************************/ +import { type FITSHeader } from '../types' + +/*****************************************************************************************************************/ + export interface FITSBlock { /** * @@ -24,7 +28,7 @@ export interface FITSBlock { * The ArrayBuffer as a raw parsed array of strings * */ - headers: string[] + headers: FITSHeader[] /** * *