diff --git a/src/io.ts b/src/io.ts index 326aca35..2f0de8d4 100644 --- a/src/io.ts +++ b/src/io.ts @@ -18,6 +18,7 @@ import { loadMultiscales, MAGENTA_GREEN, MAX_CHANNELS, + nested, open, parseMatrix, range, @@ -115,6 +116,18 @@ function loadMultiChannel(config: MultichannelConfig, data: ZarrPixelSource { const node = await open(config.source); let data: ZarrArray[]; @@ -122,6 +135,10 @@ export async function createSourceData(config: ImageLayerConfig): Promise { - if (key === 'getItem' || key === 'containsItem' || key === 'setItem') { - return (path: string, ...args: any[]) => { + if (key === 'getItem' || key === 'containsItem') { + return (path: string, ...args: unknown[]) => { if (path.endsWith('.zarray') || path.endsWith('.zattrs') || path.endsWith('.zgroup')) { - if (key === 'setItem') { - // TypeScript: setItem() needs 'value' - return target[key](path, args[0]); - } else { - return target[key](path, ...args); - } + return target[key](path, ...args); } const prefix = path.split('/'); - const chunkKey = prefix.pop() as string; + const chunkKey = prefix.pop()!; const newPath = [...prefix, chunkKey.replaceAll('.', '/')].join('/'); - if (key === 'setItem') { - return target[key](newPath, args[0]); - } else { - return target[key](newPath, ...args); - } + return target[key](newPath, ...args); }; } return Reflect.get(target, key);