{"_id":"@arve.knudsen/brfs","_rev":"3-7d1e5d6718faddde511de9fdd5891182","name":"@arve.knudsen/brfs","dist-tags":{"latest":"1.5.1"},"versions":{"1.5.0":{"name":"@arve.knudsen/brfs","version":"1.5.0","description":"browserify fs.readFileSync() static asset inliner","main":"index.js","bin":{"brfs":"bin/cmd.js"},"dependencies":{"quote-stream":"^1.0.1","resolve":"^1.1.5","@arve.knudsen/static-module":"^2.2.0","through2":"^2.0.0"},"devDependencies":{"browserify":"^4.2.0","concat-stream":"^1.6.0","tap":"~0.4.8","through":"^2.3.4"},"scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"git://github.com/aknuds1/brfs.git"},"homepage":"https://github.com/aknuds1/brfs","keywords":["browserify","browserify-transform","fs","readFileSync","plugin","static","asset","bundle","base64"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"license":"MIT","gitHead":"f747f65f74e5813049ef3c66fa666465d826b79f","bugs":{"url":"https://github.com/aknuds1/brfs/issues"},"_id":"@arve.knudsen/brfs@1.5.0","_npmVersion":"5.8.0","_nodeVersion":"9.11.1","_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"dist":{"integrity":"sha512-5VbVJ7PL2hWNElruPQ7Z43yfBz8UybC3c/1x27SbZLUiemRWTEiaxYos5Wqq+qyLWApEHqrV85fsSy7cpCbLGw==","shasum":"771b9b7cd6aa6feb3148525797e7b33afc9fc623","tarball":"https://registry.npmjs.org/@arve.knudsen/brfs/-/brfs-1.5.0.tgz","fileCount":60,"unpackedSize":28718,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDBiNfIls/g+ihrDnt9WKPlAzIea1rGPk8zwOdzOaaDwAIgOQKKXoCM4laRtR/0ff+1DBMiQvSuJNcLBXXwK7L5uYY="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/brfs_1.5.0_1523368714505_0.5405325081489716"},"_hasShrinkwrap":false},"1.5.1":{"name":"@arve.knudsen/brfs","version":"1.5.1","description":"browserify fs.readFileSync() static asset inliner","main":"index.js","bin":{"brfs":"bin/cmd.js"},"dependencies":{"quote-stream":"^1.0.1","resolve":"^1.1.5","@arve.knudsen/static-module":"^2.2.0","through2":"^2.0.0"},"devDependencies":{"browserify":"^4.2.0","concat-stream":"^1.6.0","tap":"~0.4.8","through":"^2.3.4"},"scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"git://github.com/aknuds1/brfs.git"},"homepage":"https://github.com/aknuds1/brfs","keywords":["browserify","browserify-transform","fs","readFileSync","plugin","static","asset","bundle","base64"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"license":"MIT","gitHead":"a9fcb71e77cae680e08354102568b840de88fa12","bugs":{"url":"https://github.com/aknuds1/brfs/issues"},"_id":"@arve.knudsen/brfs@1.5.1","_npmVersion":"5.8.0","_nodeVersion":"9.11.1","_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"dist":{"integrity":"sha512-BC7JCsjZQEiCAqTFgVQrn4GSocRXf+uztrBzt2AQNrAdppfrT4NbkUPLRq9+3f0RwWJB8zOVu4WFNwhuLAG5Qg==","shasum":"145623d96ea6c535dc6c0665d0543ed453db4c88","tarball":"https://registry.npmjs.org/@arve.knudsen/brfs/-/brfs-1.5.1.tgz","fileCount":60,"unpackedSize":28680,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGLKC/OjsImsGFGNAjZNtdBjZIdtqIwYi4a+isvOwMnFAiBmbqQbWWdVVwZhWtGRdYw0CLGQ6n39dXe/hovA5tppEg=="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/brfs_1.5.1_1523369374823_0.18258257559154267"},"_hasShrinkwrap":false}},"time":{"created":"2018-04-10T13:58:34.449Z","1.5.0":"2018-04-10T13:58:34.590Z","modified":"2022-04-04T15:41:13.308Z","1.5.1":"2018-04-10T14:09:34.873Z"},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"description":"browserify fs.readFileSync() static asset inliner","homepage":"https://github.com/aknuds1/brfs","keywords":["browserify","browserify-transform","fs","readFileSync","plugin","static","asset","bundle","base64"],"repository":{"type":"git","url":"git://github.com/aknuds1/brfs.git"},"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"bugs":{"url":"https://github.com/aknuds1/brfs/issues"},"license":"MIT","readme":"# brfs\n\nfs.readFileSync() and fs.readFile() static asset browserify transform\n\n[![build status](https://secure.travis-ci.org/browserify/brfs.png)](http://travis-ci.org/browserify/brfs)\n\nThis module is a plugin for [browserify](http://browserify.org) to parse the AST\nfor `fs.readFileSync()` calls so that you can inline file contents into your\nbundles.\n\nEven though this module is intended for use with browserify, nothing about it is\nparticularly specific to browserify so it should be generally useful in other\nprojects.\n\n# example\n\nfor a main.js:\n\n``` js\nvar fs = require('fs');\nvar html = fs.readFileSync(__dirname + '/robot.html', 'utf8');\nconsole.log(html);\n```\n\nand a robot.html:\n\n``` html\n<b>beep boop</b>\n```\n\nfirst `npm install brfs` into your project, then:\n\n## on the command-line\n\n```\n$ browserify -t brfs example/main.js > bundle.js\n```\n\nnow in the bundle output file,\n\n``` js\nvar html = fs.readFileSync(__dirname + '/robot.html', 'utf8');\n```\n\nturns into:\n\n``` js\nvar html = \"<b>beep boop</b>\\n\";\n```\n\n## or with the api\n\n``` js\nvar browserify = require('browserify');\nvar fs = require('fs');\n\nvar b = browserify('example/main.js');\nb.transform('brfs');\n\nb.bundle().pipe(fs.createWriteStream('bundle.js'));\n```\n\n## async\n\nYou can also use `fs.readFile()`:\n\n``` js\nvar fs = require('fs');\nfs.readFile(__dirname + '/robot.html', 'utf8', function (err, html) {\n    console.log(html);\n});\n```\n\nWhen you run this code through brfs, it turns into:\n\n``` js\nvar fs = require('fs');\nprocess.nextTick(function () {(function (err, html) {\n    console.log(html);\n})(null,\"<b>beep boop</b>\\n\")});\n```\n\n# methods\n\nbrfs looks for:\n\n* `fs.readFileSync(pathExpr, enc=null)`\n* `fs.readFile(pathExpr, enc=null, cb)`\n* `fs.readdirSync(pathExpr)`\n* `fs.readdir(pathExpr, cb)`\n\nInside of each `pathExpr`, you can use\n[statically analyzable](http://npmjs.org/package/static-eval) expressions and\nthese variables and functions:\n\n* `__dirname`\n* `__filename`\n* `path` if you `var path = require('path')` first\n* `require.resolve()`\n\nJust like node, the default encoding is `null` and will give back a `Buffer`.\nIf you want differently-encoded file contents for your inline content you can\nset `enc` to `'utf8'`, `'base64'`, or `'hex'`.\n\nIn async mode when a callback `cb` is given, the contents of `pathExpr` are\ninlined into the source inside of a `process.nextTick()` call.\n\nWhen you use a `'file'`-event aware watcher such as\n[watchify](https://npmjs.org/package/watchify), the inlined assets will be\nupdated automatically.\n\nIf you want to use this plugin directly, not through browserify, the api\nfollows.\n\n``` js\nvar brfs = require('brfs')\n```\n\n## var tr = brfs(file, opts)\n\nReturn a through stream `tr` inlining `fs.readFileSync()` file contents\nin-place.\n\nOptionally, you can set which `opts.vars` will be used in the\n[static argument evaluation](https://npmjs.org/package/static-eval)\nin addition to `__dirname` and `__filename`.\n\n# events\n\n## tr.on('file', function (file) {})\n\nFor every file included with `fs.readFileSync()` or `fs.readFile()`, the `tr`\ninstance emits a `'file'` event with the `file` path.\n\n# usage\n\nA tiny command-line program ships with this module to make debugging easier.\n\n```\nusage:\n\n  brfs file\n \n    Inline `fs.readFileSync()` calls from `file`, printing the transformed file\n    contents to stdout.\n\n  brfs\n  brfs -\n \n    Inline `fs.readFileSync()` calls from stdin, printing the transformed file\n    contents to stdout.\n\n```\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install brfs\n```\n\nthen use `-t brfs` with the browserify command or use `.transform('brfs')` from\nthe browserify api.\n\n# gotchas\n\nSince `brfs` evaluates your source code *statically*, you can't use dynamic expressions that need to be evaluated at run time. For example:\n\n```js\n// WILL NOT WORK!\nvar file = window.someFilePath;\nvar str = require('fs').readFileSync(file, 'utf8');\n```\n\nInstead, you must use simpler expressions that can be resolved at build-time:\n\n```js\nvar str = require('fs').readFileSync(__dirname + '/file.txt', 'utf8');\n```\n\nAnother gotcha: `brfs` does not yet support ES module `import` statements. See [brfs-babel](https://github.com/Jam3/brfs-babel) for an experimental replacement that supports this syntax.\n\n# license\n\nMIT\n","readmeFilename":"readme.markdown"}