{"_id":"babel-plugin-transform-with","_rev":"786186","name":"babel-plugin-transform-with","description":"Convert \"with\" statements to strict mode-compatible JavaScript","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"timothygu","email":"timothygu99@gmail.com"}],"time":{"modified":"2024-07-01T23:01:01.000Z","created":"2016-09-10T05:19:32.958Z","1.0.0":"2016-09-10T05:19:32.958Z"},"users":{"chocolateboy":true},"author":{"name":"Timothy Gu","email":"timothygu99@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/pugjs/babel-plugin-transform-with.git"},"versions":{"1.0.0":{"name":"babel-plugin-transform-with","version":"1.0.0","description":"Convert \"with\" statements to strict mode-compatible JavaScript","main":"lib/index.js","files":["lib"],"scripts":{"prepublish":"babel -d lib src","test":"babel-node test"},"repository":{"type":"git","url":"git+https://github.com/pugjs/babel-plugin-transform-with.git"},"keywords":["babel","with"],"author":{"name":"Timothy Gu","email":"timothygu99@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/pugjs/babel-plugin-transform-with/issues"},"homepage":"https://github.com/pugjs/babel-plugin-transform-with#readme","dependencies":{"babel-runtime":"^6.11.6"},"devDependencies":{"babel-cli":"^6.14.0","babel-core":"^6.14.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-parser-opts":"^1.0.1","babel-plugin-transform-runtime":"^6.15.0","babel-preset-es2015":"^6.14.0","testit":"^2.1.2"},"gitHead":"390ae7f138a335e34d3a9a96c29686105d7cea6d","_id":"babel-plugin-transform-with@1.0.0","_shasum":"00dd254022fa587c381bfa66ce7538124cc3ae25","_from":".","_npmVersion":"3.10.7","_nodeVersion":"6.4.0","_npmUser":{"name":"timothygu","email":"timothygu99@gmail.com"},"dist":{"shasum":"00dd254022fa587c381bfa66ce7538124cc3ae25","tarball":"http://registry-npm.ywwl.com/babel-plugin-transform-with/download/babel-plugin-transform-with-1.0.0.tgz","integrity":"sha512-zrWh8E1MB/POcTWxyiB8Pgv7L0g4hMwJAp/5rc8zxvKWiQqhxq3FFmpUFXdbw82p4BFeVLH507MPCcRfSWkkAQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHICoK4xSlzzz5fkxPIICXGKA4nZVA3G6u0PXhhrvTYXAiAOSbme4L5A51Ck1sR85O8tRM+kRwTY9oI6YWkXaTRnQg=="}],"size":6596,"noattachment":false,"key":"/babel-plugin-transform-with/-/babel-plugin-transform-with-1.0.0.tgz"},"maintainers":[{"name":"timothygu","email":"timothygu99@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/babel-plugin-transform-with-1.0.0.tgz_1473484772718_0.25127698108553886"},"directories":{},"publish_time":1473484772958,"_cnpm_publish_time":1473484772958}},"readme":"# babel-plugin-transform-with\n\nBabel plugin that turns `with` statements into strict-mode JS.\n\n- [x] Alternative strict-mode-compatible syntax\n- [x] Falls back to global variables if a variable is not available in the object\n- [x] Supports [`this` references][this]\n- [x] Supports [nesting]\n- [x] Supports [`return`], [`break`], [`continue`]\n- [x] Supports [`yield`], [`await`]\n- [ ] Supports `arguments` (unlikely to be supported)\n\n[![Build Status](https://img.shields.io/travis/pugjs/babel-plugin-transform-with/master.svg)](https://travis-ci.org/pugjs/babel-plugin-transform-with)\n[![Dependency Status](https://img.shields.io/david/pugjs/babel-plugin-transform-with.svg)](https://david-dm.org/pugjs/babel-plugin-transform-with)\n[![NPM version](https://img.shields.io/npm/v/babel-plugin-transform-with.svg)](https://www.npmjs.org/package/babel-plugin-transform-with)\n\n[this]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/this\n[nesting]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/nested\n[`return`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/return\n[`break`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/loop-outside-single\n[`continue`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/loop-outside-multiple\n[`yield`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/generator-function\n[`await`]: https://github.com/pugjs/babel-plugin-transform-with/tree/master/test/fixtures/with/async-function\n\n## Alternative syntax\n\nBabel errors out on any `with` statements during parsing by default, which can be frustrating when eventually the code will be converted anyway. This plugin implements an escape hatch using comments:\n\n```js\nwith (obj || {}) {\n  console.log(str);\n}\n\n// The `with` block above is equivalent to the following:\n\n// @with\n{\n  obj || {};\n  console.log(str);\n}\n```\n\nThis feature is enabled by default, but you could set `alternative` option to `false` to disable it.\n\n## Example output\n\n```js\nwith (obj || {}) {\n  console.log(str);\n}\n```\n\n```js\nvar _ref = obj || {};\n\n(function (console, str) {\n  console.log(str);\n})(\"console\" in _ref ?\n     _ref.console :\n     typeof console !== \"undefined\" ?\n       console :\n       undefined,\n   \"str\" in _ref ?\n     _ref.str :\n     typeof str !== \"undefined\" ?\n       a :\n       undefined);\n```\n\n## Exclude variables\n\nIf there are certain variables that should be regarded as globals and excluded from the closure, there are two ways to make this possible.\n\nThe plugin accepts an `exclude` option that takes an array of excluded variable names. This option applies to all `with`s compiled, so it is usually more suitable to be used when the variable is a global, like `Array`, `Object`, `process`, or `console`.\n\nIf you want to tweak the excluded variables on a per-instance basis, you can use `@with ignore` annotation (which works for both `with () {}` construct and the alternative syntax):\n\n```js\nvar i = 0, j = 0, k = 0;\nvar obj = { i: 1, j: 1, k: 0 };\n\n// @with exclude: i\nwith (obj) {\n  console.log(i, j);\n}\n\n// @with exclude: i, j\nwith (obj) {\n  console.log(i, j);\n}\n```\n\nresults in\n\n```js\nvar i = 0, j = 0, k = 0;\nvar obj = { i: 1, j: 1, k: 0 };\n\n(function (console, j) {\n  console.log(i, j);\n})(\"console\" in obj ? obj.console : typeof console !== \"undefined\" ? console : undefined, \"j\" in obj ? obj.j : typeof j !== \"undefined\" ? j : undefined);\n\n(function (console) {\n  console.log(i, j);\n})(\"console\" in obj ? obj.console : typeof console !== \"undefined\" ? console : undefined);\n```\n","_attachments":{},"homepage":"https://github.com/pugjs/babel-plugin-transform-with#readme","bugs":{"url":"https://github.com/pugjs/babel-plugin-transform-with/issues"},"license":"MIT"}