Skip to content

Commit

Permalink
Use parentheses to force evaluation of class statement as expression …
Browse files Browse the repository at this point in the history
…in pool.js
  • Loading branch information
mfripp committed Jul 23, 2018
1 parent 2636e73 commit fc5f07c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/mixins/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = class Pool {
const Singular = capitalize(singular)
const Plural = capitalize(plural)

const source = `class ${Plural}Pool extends Mixin {
const source = `(class ${Plural}Pool extends Mixin {
init${Plural}Pool (${plural}Class, ${plural}Container) {
this.${plural}Class = ${plural}Class
this.${plural}Container = ${plural}Container
Expand Down Expand Up @@ -56,13 +56,10 @@ module.exports = class Pool {
this.used${Plural} = []
return this.unused${Plural} = []
}
}
${Plural}Pool`
})`

const sandbox = {Mixin, atom, console}
const context = vm.createContext(sandbox)

const mixin = vm.runInContext(source, context, `${plural}-pool.vm`)
const mixin = vm.runInNewContext(source, sandbox, `${plural}-pool.vm`)
mixin.includeInto(this)
}
}

0 comments on commit fc5f07c

Please sign in to comment.