{"name":"with","version":"7.0.2-canary-3","description":"Compile time `with` for strict mode JavaScript","main":"lib/index.js","scripts":{"build":"tsc","postbuild":"rimraf lib/**/__tests__","lint":"tslint './src/**/*.{ts,tsx}' -t verbose -p .","prettier:write":"prettier --ignore-path .gitignore --write './**/*.{md,json,yaml,js,jsx,ts,tsx}'","prettier:check":"prettier --ignore-path .gitignore --list-different './**/*.{md,json,yaml,js,jsx,ts,tsx}'","pretest":"yarn build","test":"mocha test/index.js -R spec"},"repository":{"type":"git","url":"git+https://github.com/pugjs/with.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","dependencies":{"@babel/parser":"^7.9.6","@babel/types":"^7.9.6","assert-never":"^1.2.1","babel-walk":"3.0.0-canary-5"},"devDependencies":{"@forbeslindesay/tsconfig":"^2.0.0","@types/node":"^14.0.5","mocha":"*","prettier":"^2.0.5","rimraf":"^3.0.2","tslint":"^6.1.2","typescript":"^3.9.3","uglify-js":"^2.6.2"},"engines":{"node":">= 10.0.0"},"readme":"# with\n\nCompile time `with` for strict mode JavaScript\n\n[![Build Status](https://img.shields.io/github/workflow/status/pugjs/with/Publish%20Canary/master?style=for-the-badge)](https://github.com/pugjs/with/actions?query=workflow%3A%22Publish+Canary%22)\n[![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen?style=for-the-badge)](https://rollingversions.com/pugjs/with)\n[![NPM version](https://img.shields.io/npm/v/with?style=for-the-badge)](https://www.npmjs.com/package/with)\n\n## Installation\n\n    $ npm install with\n\n## Usage\n\n```js\nvar addWith = require('with');\n\naddWith('obj', 'console.log(a)');\n// => ';(function (console, a) {\n//       console.log(a)\n//     }(\"console\" in obj ? obj.console :\n//                          typeof console!==\"undefined\" ? console : undefined,\n//       \"a\" in obj ? obj.a :\n//                    typeof a !== \"undefined\" ? a : undefined));'\n\naddWith('obj', 'console.log(a)', ['console']);\n// => ';(function (console, a) {\n//       console.log(a)\n//     }(\"a\" in obj ? obj.a :\n//                    typeof a !== \"undefined\" ? a : undefined));'\n```\n\n## API\n\n### addWith(obj, src[, exclude])\n\nThe idea is that this is roughly equivallent to:\n\n```js\nwith (obj) {\n  src;\n}\n```\n\nThere are a few differences though. For starters, assignments to variables will always remain contained within the with block.\n\ne.g.\n\n```js\nvar foo = 'foo';\nwith ({}) {\n  foo = 'bar';\n}\nassert(foo === 'bar'); // => This fails for compile time with but passes for native with\n\nvar obj = {foo: 'foo'};\nwith ({}) {\n  foo = 'bar';\n}\nassert(obj.foo === 'bar'); // => This fails for compile time with but passes for native with\n```\n\nIt also makes everything be declared, so you can always do:\n\n```js\nif (foo === undefined)\n```\n\ninstead of\n\n```js\nif (typeof foo === 'undefined')\n```\n\nThis is not the case if foo is in `exclude`. If a variable is excluded, we ignore it entirely. This is useful if you know a variable will be global as it can lead to efficiency improvements.\n\nIt is also safe to use in strict mode (unlike `with`) and it minifies properly (`with` disables virtually all minification).\n\n#### Parsing Errors\n\nwith internally uses babylon to parse code passed to `addWith`. If babylon throws an error, probably due to a syntax error, `addWith` returns an error wrapping the babylon error, so you can\nretrieve location information. `error.component` is `\"src\"` if the error is in the body or `\"obj\"` if it's in the object part of the with expression. `error.babylonError` is\nthe error thrown from babylon.\n\n## License\n\nMIT\n","readmeFilename":"README.md","gitHead":"fcae468cb1ca7205a2a07dc9680f390a453b4e49","bugs":{"url":"https://github.com/pugjs/with/issues"},"homepage":"https://github.com/pugjs/with#readme","_id":"with@7.0.2-canary-3","_nodeVersion":"12.16.3","_npmVersion":"6.14.4","dist":{"integrity":"sha512-wKAbH+1M3TN0fmss16Xj0W9V6lwPL1XayJwH6lzznwi623aor2eQvHhVg5mVYIqsBe6nVMrHSODtsJQtPc/PZg==","shasum":"0cf24192010d56e750e8b5a02678c42be28f93e1","tarball":"http://registry-npm.ywwl.com/with/download/with-7.0.2-canary-3.tgz","fileCount":22,"unpackedSize":40297,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe0OmPCRA9TVsSAnZWagAAEJQQAIu9KdxSXcRIZIXpdj/T\n38ZLur/JC3OxDyxcfrVGnR4cAhyKPQRCTJvAg/qt8gFl4U4iLvquUXh/hu4v\nF7iJ0M3tfXiQKKfjsviO6Sd69VLmtJqXJJqs16tKD7K4iR0FQiTqrt0WV87I\nr3DOdeupzPTlqaLM66skwFsAMd8Et31Q3NlWMXaNeIXbzGlELf2snY7syFCn\nYrZYl3xZjdHCMnnE+Wdu+yDZrXZ05cuBaNrvrpbkI9a77/3Fv9L2WuszGw6B\nl9nIVC7uWD3Ha+HCm10SZRYAzXMsNw2GT+qToBzXNuVhPfX62Oku6diMVxgb\n6HvTyLeVLQ9Mj4Yz5S+Nm5uTkUPRt1R9OMVV82gaKvl0V7iNtPRIg5frWJof\ntCDA7rXTDezB9siVznXMIfkKFS+ayWobiWTkos4ZEcXwE+TXyfkkUUG1q0kh\n0Cb11jT685ozqfCGeorpsVz4EWoOpi4qFiiFxPDiLeG7vVxXuqEbcbAO1x39\n5f7QvOgtSNP/w/XM+LGGnGjdWb2IICuhtbMFSIiaN2fe8CuTq/1/vKuYeqM1\nQtG4MIq+8VFWaBo1E+skfe1xZ+Ub5qIVHl4H1l/kDCicB0rbo4PH5YZ0CZeq\njAgFsE8bKEBIDH9C3eZPsMJM049mAihgn3eMzZOasAaoOe+s5FHm1iTmEytV\nSh2h\r\n=Afbf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDdBShTv17kzAMICdgv7imEVoUmUbKaIwCfl1OK87oovAIhALFkhBjj5eYmBy5B169Bu6ALQjPUgadw8VAE5aczvsR8"}],"size":11715,"noattachment":false,"key":"/with/-/with-7.0.2-canary-3.tgz"},"maintainers":[{"email":"forbes@lindesay.co.uk","name":"forbeslindesay"},{"email":"with-bot@rollingversions.com","name":"with-bot"}],"_npmUser":{"name":"with-bot","email":"with-bot@rollingversions.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/with_7.0.2-canary-3_1590749582886_0.21731864787719046"},"_hasShrinkwrap":false,"publish_time":1590749583025,"_cnpm_publish_time":1590749583025,"dist-tags":{"canary":"7.0.2-canary-3","latest":"7.0.2"}}