Skip to content

Commit

Permalink
refactor: remove useless spread (#3600)
Browse files Browse the repository at this point in the history
* refactor: remove useless spread

* refactor: remove useless spread fallback

* refactor(adapter/lambda-edge): remove unneeded ternary operators

* refactor: remove useless fallback

---------

Co-authored-by: EdamAmex <[email protected]>
  • Loading branch information
exoego and EdamAme-x authored Nov 1, 2024
1 parent 1af7e58 commit ae99d86
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/adapter/lambda-edge/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const createResult = async (res: Response): Promise<CloudFrontResult> => {
status: res.status.toString(),
headers: convertHeaders(res.headers),
body,
...(isBase64Encoded ? { bodyEncoding: 'base64' } : {}),
...(isBase64Encoded && { bodyEncoding: 'base64' }),
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,8 @@ class ClientRequestImpl {
let methodUpperCase = this.method.toUpperCase()

const headerValues: Record<string, string> = {
...(args?.header ?? {}),
...(typeof opt?.headers === 'function'
? await opt.headers()
: opt?.headers
? opt.headers
: {}),
...args?.header,
...(typeof opt?.headers === 'function' ? await opt.headers() : opt?.headers),
}

if (args?.cookie) {
Expand Down Expand Up @@ -201,7 +197,7 @@ export const hc = <T extends Hono<any, any, any>>(
const req = new ClientRequestImpl(url, method)
if (method) {
options ??= {}
const args = deepMerge<ClientRequestOptions>(options, { ...(opts.args[1] ?? {}) })
const args = deepMerge<ClientRequestOptions>(options, { ...opts.args[1] })
return req.fetch(opts.args[0], args)
}
return req
Expand Down
3 changes: 2 additions & 1 deletion src/middleware/jsx-renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const createRenderer =
? jsx(
(props: any) => component(props, c),
{
...{ Layout, ...(props as any) },
Layout,
...(props as any),
},
children as any
)
Expand Down

0 comments on commit ae99d86

Please sign in to comment.