Skip to content

Commit

Permalink
perf: freeze backup object
Browse files Browse the repository at this point in the history
  • Loading branch information
molvqingtai committed Feb 15, 2025
1 parent 8447fe8 commit cf35c35
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ const provideProxy = <T extends Record<string, any>>(context: () => T, options:
const injectProxy = <T extends Record<string, any>>(context: () => T, options: Required<Options>) => {
let target: T
return <M extends Message = Message>(adapter: Adapter<M>) =>
(target ??= createInject(options.backup ? context() : ({} as unknown as T), adapter as unknown as Adapter, options))
(target ??= createInject(
options.backup ? Object.freeze(context()) : ({} as unknown as T),
adapter as unknown as Adapter,
options
))
}

/**
Expand Down

0 comments on commit cf35c35

Please # to comment.