{"name":"insert-module-globals","version":"7.0.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.7.1","concat-stream":"~1.5.1","is-buffer":"^1.1.0","lexical-scope":"^1.2.0","process":"~0.11.0","through2":"^2.0.0","xtend":"^4.0.0"},"devDependencies":{"browser-pack":"^6.0.0","buffer":"^3.0.0","convert-source-map":"~1.1.0","module-deps":"^4.0.2","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":"42466847e7a4218f2c7f631c4178402a32c2a98a","bugs":{"url":"https://github.com/substack/insert-module-globals/issues"},"_id":"insert-module-globals@7.0.2","_npmVersion":"5.7.1","_nodeVersion":"9.6.1","_npmUser":{"name":"goto-bus-stop","email":"rene@kooi.me"},"dist":{"integrity":"sha512-p3s7g96Nm62MbHRuj9ZXab0DuJNWD7qcmdUXCOQ/ZZn42DtDXfsLill7bq19lDCx3K3StypqUnuE3H2VmIJFUw==","shasum":"012c56baa7d3307a8b417d4ec5270cf9741c18f4","tarball":"http://registry-npm.ywwl.com/insert-module-globals/download/insert-module-globals-7.0.2.tgz","fileCount":37,"unpackedSize":27137,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCGzPEQLZcRBlLiUTHvnHmVGlW3rSwHU1tD3dByEcIC/wIhAPIO+/bhWrV0V5fQeKKVZEdHHAB2ZGVLZSa0KxREKSlr"}],"size":8445,"noattachment":false,"key":"/insert-module-globals/-/insert-module-globals-7.0.2.tgz"},"maintainers":[{"email":"michael.williams@enspiral.com","name":"ahdinosaur"},{"email":"vestibule@anandthakker.net","name":"anandthakker"},{"email":"darawk@gmail.com","name":"ashaffer88"},{"email":"b@lupton.cc","name":"balupton"},{"email":"post.ben.here@gmail.com","name":"bpostlethwaite"},{"email":"bcomnes@gmail.com","name":"bret"},{"email":"calvin.metcalf@gmail.com","name":"cwmma"},{"email":"npm@dcousens.com","name":"dcousens"},{"email":"dominic.tarr@gmail.com","name":"dominictarr"},{"email":"contact@elnounch.net","name":"elnounch"},{"email":"github@tixz.dk","name":"emilbayes"},{"email":"feross@feross.org","name":"feross"},{"email":"forbes@lindesay.co.uk","name":"forbeslindesay"},{"email":"pereira.filype@gmail.com","name":"fpereira1"},{"email":"garann@gmail.com","name":"garann"},{"email":"me@gkatsev.com","name":"gkatsev"},{"email":"rene@kooi.me","name":"goto-bus-stop"},{"email":"hughskennedy@gmail.com","name":"hughsk"},{"email":"fedor@indutny.com","name":"indutny"},{"email":"npm-public@jessemccarthy.net","name":"jmm"},{"email":"jprichardson@gmail.com","name":"jprichardson"},{"email":"jryans@gmail.com","name":"jryans"},{"email":"martin.heidegger@gmail.com","name":"leichtgewicht"},{"email":"mathiasbuus@gmail.com","name":"mafintosh"},{"email":"dave.des@gmail.com","name":"mattdesl"},{"email":"max@maxogden.com","name":"maxogden"},{"email":"palmermebane@gmail.com","name":"mellowmelon"},{"email":"parshap+npm@gmail.com","name":"parshap"},{"email":"peteris.krumins@gmail.com","name":"pkrumins"},{"email":"sethvincent@gmail.com","name":"sethvincent"},{"email":"maochenyan@gmail.com","name":"stevemao"},{"email":"substack@gmail.com","name":"substack"},{"email":"me@JoshDuff.com","name":"tehshrike"},{"email":"terinjokes@gmail.com","name":"terinjokes"},{"email":"thlorenz@gmx.de","name":"thlorenz"},{"email":"ungoldman@gmail.com","name":"ungoldman"},{"email":"yerko.palma@usach.cl","name":"yerkopalma"},{"email":"yoshuawuyts@gmail.com","name":"yoshuawuyts"},{"email":"zertosh@gmail.com","name":"zertosh"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/insert-module-globals_7.0.2_1519835940134_0.4003580390982011"},"_hasShrinkwrap":false,"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":1519835940286,"_cnpm_publish_time":1519835940286,"dist-tags":{"latest":"7.2.1"}}