Skip to content

Commit

Permalink
add expected types to unfilled outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaranville committed Mar 5, 2024
1 parent 5b7e36c commit 790e673
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/hdf5_hl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function process_data(data: Uint8Array, metadata: Metadata, json_compatible: boo
// let length: number;
if (type === Module.H5T_class_t.H5T_STRING.value) {
if (metadata.vlen) {
let output = [];
let output: string[] = [];
let reader = (metadata.cset == 1) ? Module.UTF8ToString : Module.AsciiToString;
let ptrs = new Uint32Array(data.buffer);
for (let ptr of ptrs) {
Expand All @@ -124,7 +124,7 @@ function process_data(data: Uint8Array, metadata: Metadata, json_compatible: boo
let decoder = new TextDecoder(encoding);
let size = metadata.size;
let n = Math.floor(data.byteLength / size);
let output = [];
let output: string[] = [];
for (let i = 0; i < n; i++) {
let bytes = data.slice(i * size, (i + 1) * size);
// truncate at first null
Expand Down Expand Up @@ -153,9 +153,9 @@ function process_data(data: Uint8Array, metadata: Metadata, json_compatible: boo
else if (type === Module.H5T_class_t.H5T_COMPOUND.value) {
const { size, compound_type } = <{size: Metadata["size"], compound_type: CompoundTypeMetadata}>metadata;
let n = Math.floor(data.byteLength / size);
let output = [];
let output: OutputData[] = [];
for (let i = 0; i < n; i++) {
let row = [];
let row: OutputData = [];
let row_data = data.slice(i * size, (i + 1) * size);
for (let member of compound_type.members) {
let member_data = row_data.slice(member.offset, member.offset + member.size);
Expand Down Expand Up @@ -1108,7 +1108,7 @@ function create_nested_array(value: JSONCompatibleOutputData[], shape: number[])
const subdims = shape.slice(1).reverse();
for (let dim of subdims) {
// in each pass, replace input with array of slices of input
const new_output = [];
const new_output: JSONCompatibleOutputData = [];
const { length } = output;
let cursor = 0;
while (cursor < length) {
Expand Down

0 comments on commit 790e673

Please sign in to comment.