diff --git a/deps.pure_ext.ts b/deps.pure_ext.ts index de609bb..6576fb1 100644 --- a/deps.pure_ext.ts +++ b/deps.pure_ext.ts @@ -1,8 +1,8 @@ // @deno-types="https://deno.land/std@0.221.0/csv/mod.ts" export {parse, stringify} from "https://esm.sh/gh/denoland/deno_std@0.221.0/csv/mod.ts?bundle&target=esnext"; -// @deno-types="https://deno.land/x/zipjs@v2.7.40/index.d.ts" -export {ZipReader, ZipWriter, Uint8ArrayReader, Uint8ArrayWriter} from "https://esm.sh/gh/gildas-lormeau/zip.js@v2.7.40/index.js?bundle&target=esnext"; +// @deno-types="https://deno.land/x/zipjs@v2.7.41/index.d.ts" +export {ZipReader, ZipWriter, Uint8ArrayReader, Uint8ArrayWriter} from "https://esm.sh/gh/gildas-lormeau/zip.js@v2.7.41/index.js?bundle&target=esnext"; -// @deno-types="https://cdn.sheetjs.com/xlsx-0.20.1/package/types/index.d.ts" -export {type WorkBook as RawWorkBook, type WorkSheet as RawWorkSheet, type CellObject as RawWorkCell, set_cptable, read as xlsxRead, write as xlsxWrite, utils as xlsxUtil} from "https://cdn.sheetjs.com/xlsx-0.20.1/package/xlsx.mjs"; -export * as xlsxcp from "https://cdn.sheetjs.com/xlsx-0.20.1/package/dist/cpexcel.full.mjs"; \ No newline at end of file +// @deno-types="https://cdn.sheetjs.com/xlsx-0.20.2/package/types/index.d.ts" +export {type WorkBook as RawWorkBook, type WorkSheet as RawWorkSheet, type CellObject as RawWorkCell, set_cptable, read as xlsxRead, write as xlsxWrite, utils as xlsxUtil} from "https://cdn.sheetjs.com/xlsx-0.20.2/package/xlsx.mjs"; +export * as xlsxcp from "https://cdn.sheetjs.com/xlsx-0.20.2/package/dist/cpexcel.full.mjs"; \ No newline at end of file diff --git a/src/pure/minipack.ts b/src/pure/minipack.ts index 634bf1f..7b1d236 100644 --- a/src/pure/minipack.ts +++ b/src/pure/minipack.ts @@ -1,7 +1,7 @@ import {u8Encode, u8Decode} from "./text.ts"; -const sizeName = 1; -const sizeBody = 4; +const MINIPACK_NAME = 1; +const MINIPACK_BODY = 4; /** * Simple name and data pair. @@ -25,17 +25,17 @@ export interface DataMap{ * ``` */ export function minipackEncode(files:DataMap[]):Uint8Array{ - const archive = new Uint8Array(files.reduce((size, {name, body}) => size + sizeName + sizeBody + u8Encode(name).byteLength + body.byteLength, 0)); + const archive = new Uint8Array(files.reduce((size, {name, body}) => size + MINIPACK_NAME + MINIPACK_BODY + u8Encode(name).byteLength + body.byteLength, 0)); let i = 0; for(const {name, body} of files){ const u8name = u8Encode(name); new DataView(archive.buffer, i).setUint8(0, u8name.byteLength); - i += sizeName; + i += MINIPACK_NAME; new DataView(archive.buffer, i).setUint32(0, body.byteLength); - i += sizeBody; + i += MINIPACK_BODY; archive.set(u8name, i); i += u8name.byteLength; @@ -65,10 +65,10 @@ export function minipackDecode(archive:Uint8Array):DataMap[]{ for(let i = 0; i < archive.byteLength;){ const ns = new DataView(archive.buffer, i).getUint8(0); - i += sizeName; + i += MINIPACK_NAME; const bs = new DataView(archive.buffer, i).getUint32(0); - i += sizeBody; + i += MINIPACK_BODY; files.push({ name: u8Decode(archive.subarray(i, i += ns)), diff --git a/src/pure/worker.ts b/src/pure/worker.ts index b19b108..f978f6a 100644 --- a/src/pure/worker.ts +++ b/src/pure/worker.ts @@ -3,7 +3,7 @@ import {u8Encode} from "./text.ts"; interface TaskMessage{ message: T; - transfers?: (Transferable | ArrayBufferView)[]; + transfers?: Transferable[]; } /** @@ -14,7 +14,7 @@ export type TaskAction = (message:T) => Ta /** * Run registered `TaskAction` in worker thread. */ -export type TaskContext = (message:T, transfers?:(Transferable | ArrayBufferView)[]) => Promise; +export type TaskContext = (message:T, transfers?:Transferable[]) => Promise; /** * Register `TaskAction` and return reusable task execution context. @@ -38,7 +38,7 @@ export function createTask(task:TaskAction globalThis.onmessage = async({data})=>{ const {message, transfers} = await(${task.toString()})(data); globalThis.postMessage(message, { - transfer: transfers?.map(v => "buffer" in v ? v.buffer : v) + transfer: transfers }); }; `; @@ -65,7 +65,7 @@ export function createTask(task:TaskAction }; worker.postMessage(message, { - transfer: transfers?.map(v => "buffer" in v ? v.buffer : v) + transfer: transfers }); }); }; diff --git a/test/pure/worker.test.ts b/test/pure/worker.test.ts index ffbfb93..3720e42 100644 --- a/test/pure/worker.test.ts +++ b/test/pure/worker.test.ts @@ -12,11 +12,11 @@ Deno.test({ return { message: result, - transfers: [result] + transfers: [result.buffer] }; }); - const result = await task(sample1, [sample1]); + const result = await task(sample1, [sample1.buffer]); assertEquals(result, sample2); }