Skip to content
Myr

fix(client): Fix issue awaiting RPC client (#1924)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* allow awaiting clients * update deno_dist * add test for awaiting client

authored by Eli Edds · committed by GitHub · parent 8de6059 · Browse files · 3 files+12 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+12 added−2 removed

  • tests:+10 added−0 removed
  • other:+2 added−2 removed

3 files+12 added−2 removed

modified:deno_dist/client/client.ts+1 added-1 removed
modified:src/client/client.test.ts+10 added
623 unmodified lines
624 const url = client.posts[':id'].comments.$url()625 expect(url.pathname).toBe('/posts/:id/comments')626 })627})628629describe('Client can be awaited', () => {630 it('Can be awaited without side effects', async () => {631 const client = hc('http://localhost')632633 const awaited = await client634635 expect(awaited).toEqual(client)636 })637})
modified:src/client/client.ts+1 added-1 removed
6 unmodified lines
78const createProxy = (callback: Callback, path: string[]) => {9 const proxy: unknown = new Proxy(() => {}, {10 get(_obj, key) {11 if (typeof key !== 'string') return undefined11 if (typeof key !== 'string' || key === 'then') return undefined12 return createProxy(callback, [...path, key])13 },14 apply(_1, _2, args) {15 return callback({
143 unmodified lines