Skip to content

Commit

Permalink
refactor: make ctor immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowtime2000 committed Dec 5, 2020
1 parent 317513b commit 3a0cd3f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ export type TemplateFunction = (data: object, config: EtaConfig, cb?: CallbackFn

export default function compile(str: string, config?: PartialConfig): TemplateFunction {
const options: EtaConfig = getConfig(config || {})
let ctor // constructor

/* ASYNC HANDLING */
// The below code is modified from mde/ejs. All credit should go to them.
if (options.async) {
ctor = getAsyncFunctionConstructor() as FunctionConstructor
} else {
ctor = Function
}
const ctor = options.async ? getAsyncFunctionConstructor() as FunctionConstructor : Function
/* END ASYNC HANDLING */

try {
return new ctor(
options.varName,
Expand Down

0 comments on commit 3a0cd3f

Please sign in to comment.