Skip to content

Commit

Permalink
fix(deno): Change buffer_paths from Array<string> to `Array<Array…
Browse files Browse the repository at this point in the history
…<string>>` (#797)
  • Loading branch information
manzt authored Feb 14, 2025
1 parent 53bdb60 commit 7c2ce88
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-glasses-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@anywidget/deno": patch
---

Change `buffer_paths` from `Array<string>` to `Array<Array<string>>`
6 changes: 3 additions & 3 deletions packages/deno/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ export function remove_buffers<T extends Record<string, unknown>>(
): {
state: { [K in keyof T]: T[K] extends Uint8Array ? null : T[K] };
buffers: Array<Uint8Array>;
buffer_paths: Array<string>;
buffer_paths: Array<[string]>;
} {
let buffers: Array<Uint8Array> = [];
let buffer_paths: Array<string> = [];
let buffer_paths: Array<[string]> = [];
let out: Record<string, unknown> = {};
for (let key in state) {
if (state[key] instanceof Uint8Array) {
out[key] = null;
buffers.push(state[key]);
buffer_paths.push(key);
buffer_paths.push([key]);
} else {
out[key] = state[key];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ Deno.test("remove_buffers extracts buffers from message", () => {
},
},
buffers: [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])],
buffer_paths: ["a", "c"],
buffer_paths: [["a"], ["c"]],
});
});

0 comments on commit 7c2ce88

Please sign in to comment.