{"name":"insert-module-globals","version":"6.6.2","description":"insert implicit module globals into a module-deps stream","main":"index.js","bin":{"insert-module-globals":"bin/cmd.js"},"dependencies":{"JSONStream":"^1.0.3","combine-source-map":"~0.6.1","concat-stream":"~1.4.1","is-buffer":"^1.1.0","lexical-scope":"^1.2.0","process":"~0.11.0","through2":"^1.0.0","xtend":"^4.0.0"},"devDependencies":{"browser-pack":"^5.0.0","buffer":"^3.0.0","convert-source-map":"~1.1.0","module-deps":"^3.7.11","tape":"^4.2.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"git://github.com/substack/insert-module-globals.git"},"homepage":"https://github.com/substack/insert-module-globals","keywords":["__filename","__dirname","global","process","module-deps","browser-pack","browserify"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"license":"MIT","gitHead":"f20b1e1a7e9723d9506c37526176f73e68b56335","bugs":{"url":"https://github.com/substack/insert-module-globals/issues"},"_id":"insert-module-globals@6.6.2","_shasum":"d75745b79c78a7298edc73f735423e1e61aa2457","_from":".","_npmVersion":"3.3.2","_nodeVersion":"4.2.1","_npmUser":{"name":"substack","email":"substack@gmail.com"},"dist":{"shasum":"d75745b79c78a7298edc73f735423e1e61aa2457","tarball":"http://registry-npm.ywwl.com/insert-module-globals/download/insert-module-globals-6.6.2.tgz","integrity":"sha512-OKDofleT/+3cI2g2NPZn8R09JzRfEBKarRWAmdXYIy+MkvSEgeWt5FGDdURkmxEa+F1i8WqbzH6gD6ziWcO5Aw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICP0Y3TxjO1S/+kIxLFfwUqP8Hn4QqK6fd8+iPMBO2SiAiEAh1dO7ep1sAMNiuJOxScc/8vuS/xVfZOIXxDYkZiJ7hk="}],"size":7803,"noattachment":false,"key":"/insert-module-globals/-/insert-module-globals-6.6.2.tgz"},"maintainers":[{"name":"parshap","email":"parshap+npm@gmail.com"},{"name":"substack","email":"substack@gmail.com"},{"name":"zertosh","email":"zertosh@gmail.com"}],"directories":{},"readme":"# insert-module-globals\n\ninsert implicit module globals\n(`__filename`, `__dirname`, `process`, `global`, `setImmediate`, `clearImmediate` and `Buffer`)\nas a browserify-style transform\n\n[![build status](https://secure.travis-ci.org/browserify/insert-module-globals.png)](http://travis-ci.org/browserify/insert-module-globals)\n\n# example\n\n``` js\nvar mdeps = require('module-deps');\nvar bpack = require('browser-pack');\nvar insert = require('insert-module-globals');\nfunction inserter (file) {\n    return insert(file, { basedir: __dirname + '/files' });\n}\n\nvar files = [ __dirname + '/files/main.js' ];\nmdeps(files, { transform: inserter })\n    .pipe(bpack({ raw: true }))\n    .pipe(process.stdout)\n;\n```\n\n```\n$ node example/insert.js | node\nin main.js: {\"__filename\":\"/main.js\",\"__dirname\":\"/\"}\nin foo/index.js: {\"__filename\":\"/foo/index.js\",\"__dirname\":\"/foo\"}\n```\n\nor use the command-line scripts:\n\n```\n$ module-deps main.js | insert-module-globals | browser-pack | node\nin main.js: {\"__filename\":\"/main.js\",\"__dirname\":\"/\"}\nin foo/index.js: {\"__filename\":\"/foo/index.js\",\"__dirname\":\"/foo\"}\n```\n\nor use insert-module-globals as a transform:\n\n```\n$ module-deps main.js --transform insert-module-globals | browser-pack | node\nin main.js: {\"__filename\":\"/main.js\",\"__dirname\":\"/\"}\nin foo/index.js: {\"__filename\":\"/foo/index.js\",\"__dirname\":\"/foo\"}\n```\n\n# methods\n\n``` js\nvar insertGlobals = require('insert-module-globals')\n```\n\n## var inserter = insertGlobals(file, opts)\n\nReturn a transform stream `inserter` for the filename `file` that will accept a\njavascript file as input and will output the file with a closure around the\ncontents as necessary to define extra builtins.\n\nWhen `opts.always` is true, wrap every file with all the global variables\nwithout parsing. This is handy because parsing the scope can take a long time,\nso you can prioritize fast builds over saving bytes in the final output. When\n`opts.always` is truthy but not true, avoid parsing but perform a quick test to\ndetermine if wrapping should be skipped.\n\nUse `opts.vars` to override the default inserted variables, or set\n`opts.vars[name]` to `undefined` to not insert a variable which would otherwise\nbe inserted.\n\n`opts.vars` properties with a `.` in their name will be executed instead of the\nparent object if ONLY that property is used. For example, `\"Buffer.isBuffer\"`\nwill mask `\"Buffer\"` only when there is a `Buffer.isBuffer()` call in a file and\nno other references to `Buffer`.\n\nIf `opts.debug` is true, an inline source map will be generated to compensate\nfor the extra lines.\n\n# events\n\n## inserter.on('global', function (name) {})\n\nWhen a global is detected, the inserter stream emits a `'global'` event.\n\n# usage\n\n```\nusage: insert-module-globals {basedir}\n```\n\n# install\n\nWith [npm](https://npmjs.org), to get the library do:\n\n```\nnpm install insert-module-globals\n```\n\nand to get the bin script do:\n\n```\nnpm install -g insert-module-globals\n```\n\n# insert custom globals.\n\n`insert-module-globals` can also insert arbitary globals into files.\nPass in an object of functions as the `vars` option.\n\n``` js\nvar vars = {\n    process: function (file, basedir) {\n        return {\n            id: \"path/to/custom_process.js\",\n            source: customProcessContent\n        }\n    },\n    Buffer: function (file, basedir) {\n        return {\n            id: 'path/to/custom_buffer.js',\n            source: customProcessContent,\n            //suffix is optional\n            //it's used to extract the value from the module.\n            //it becomes: require(...).Buffer in this case.\n            suffix: '.Buffer'\n        }\n    },\n    Math: function () {\n        //if you return a string,\n        //it's simply set as the value.\n        return '{}'\n        //^ any attempt to use Math[x] will throw!\n    }\n}\n\nfunction inserter (file) {\n    return insert(file, { vars: vars });\n}\nmdeps(files, { transform: inserter })\n    .pipe(bpack({ raw: true }))\n    .pipe(process.stdout)\n```\n\n\n# license\n\nMIT\n","publish_time":1445160723398,"_cnpm_publish_time":1445160723398,"dist-tags":{"latest":"7.2.1"}}