{
  "name": "with",
  "version": "3.0.1",
  "description": "Compile time `with` for strict mode JavaScript",
  "main": "index.js",
  "scripts": {
    "test": "mocha -R spec"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/ForbesLindesay/with.git"
  },
  "author": {
    "name": "ForbesLindesay"
  },
  "license": "MIT",
  "dependencies": {
    "uglify-js": "~2.4.12"
  },
  "devDependencies": {
    "mocha": "~1.12.0"
  },
  "readme": "# with\r\n\r\nCompile time `with` for strict mode JavaScript\r\n\r\n[![build status](https://secure.travis-ci.org/ForbesLindesay/with.png)](http://travis-ci.org/ForbesLindesay/with)\r\n[![Dependency Status](https://img.shields.io/gemnasium/ForbesLindesay/with.svg)](https://gemnasium.com/ForbesLindesay/with)\r\n[![NPM version](https://img.shields.io/npm/v/with.svg)](http://badge.fury.io/js/with)\r\n\r\n## Installation\r\n\r\n    $ npm install with\r\n\r\n## Usage\r\n\r\n```js\r\nvar addWith = require('with')\r\n\r\naddWith('obj', 'console.log(a)')\r\n// => ';(function (console, a) {\r\n//       console.log(a)\r\n//     }(\"console\" in obj ? obj.console :\r\n//                          typeof console!==\"undefined\" ? console : undefined,\r\n//       \"a\" in obj ? obj.a :\r\n//                    typeof a !== \"undefined\" ? a : undefined));'\r\n\r\naddWith('obj', 'console.log(a)', ['console'])\r\n// => ';(function (console, a) {\r\n//       console.log(a)\r\n//     }(\"a\" in obj ? obj.a :\r\n//                    typeof a !== \"undefined\" ? a : undefined));'\r\n```\r\n\r\n## API\r\n\r\n### addWith(obj, src[, exclude])\r\n\r\nThe idea is that this is roughly equivallent to:\r\n\r\n```js\r\nwith (obj) {\r\n  src\r\n}\r\n```\r\n\r\nThere are a few differences though.  For starters, assignments to variables will always remain contained within the with block.\r\n\r\ne.g.\r\n\r\n```js\r\nvar foo = 'foo'\r\nwith ({}) {\r\n  foo = 'bar'\r\n}\r\nassert(foo === 'bar')// => This fails for compile time with but passes for native with\r\n\r\nvar obj = {foo: 'foo'}\r\nwith ({}) {\r\n  foo = 'bar'\r\n}\r\nassert(obj.foo === 'bar')// => This fails for compile time with but passes for native with\r\n```\r\n\r\nIt also makes everything be declared, so you can always do:\r\n\r\n```js\r\nif (foo === undefined)\r\n```\r\n\r\ninstead of\r\n\r\n```js\r\nif (typeof foo === 'undefined')\r\n```\r\n\r\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.\r\n\r\nIt is also safe to use in strict mode (unlike `with`) and it minifies properly (`with` disables virtually all minification).\r\n\r\n## License\r\n\r\n  MIT",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/ForbesLindesay/with/issues"
  },
  "_id": "with@3.0.1",
  "_from": "with@~3.0.0"
}
