Skip to content

Commit

Permalink
fix: JSON.stringify(...) throwing an error (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-elicx authored Aug 27, 2023
1 parent 0b7bfb2 commit 8527c95
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-bobcats-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'cf-bindings-proxy': patch
---

Fix using `JSON.stringify(...)` throwing an error.
2 changes: 2 additions & 0 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ const createResponseProxy = <T extends object>(
return data[Number(prop)];
}

if (['toJSON'].includes(prop as string)) return data;

// eslint-disable-next-line @typescript-eslint/no-use-before-define
const newProxy = createBindingProxy<BindingRequest>(bindingId, true);

Expand Down
2 changes: 2 additions & 0 deletions tests/proxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ suite('bindings', () => {
{ key: 'json-key' },
{ key: 'second-key' },
]);

expect(JSON.stringify(list.truncated)).toEqual('false');
});

test('head', async () => {
Expand Down

0 comments on commit 8527c95

Please sign in to comment.