{"size": 613, "ext": "js", "max_stars_repo_path": "src/program/types/WithStatement.js", "max_stars_repo_name": "znck/buble", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/program/types/WithStatement.js", "max_issues_repo_name": "znck/buble", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/program/types/WithStatement.js", "max_forks_repo_name": "znck/buble", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.2631578947, "max_line_length": 73, "alphanum_fraction": 0.6574225122}
import Node from '../Node.js'

export default class WithStatement extends Node {
  transpile (code, transforms) {
    if (transforms.stripWith) {
      this.program.inWith = (this.program.inWith || 0) + 1
      // remove surrounding with block
      const context = code.slice(this.object.start, this.object.end)
      code.remove(this.start, this.body.start + 1)
      code.remove(this.end - 1, this.end)
      code.insertRight(this.start, `const __vue_context__ = ${context};`)
      super.transpile(code, transforms)
      this.program.inWith--
    } else {
      super.transpile(code, transforms)
    }
  }
}
