You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
5.2 KiB
JSON
93 lines
5.2 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "rfile@~1.0.0",
|
|
"scope": null,
|
|
"escapedName": "rfile",
|
|
"name": "rfile",
|
|
"rawSpec": "~1.0.0",
|
|
"spec": ">=1.0.0 <1.1.0",
|
|
"type": "range"
|
|
},
|
|
"/Users/MB/git/pdfkit/node_modules/umd"
|
|
]
|
|
],
|
|
"_from": "rfile@>=1.0.0 <1.1.0",
|
|
"_id": "rfile@1.0.0",
|
|
"_inCache": true,
|
|
"_location": "/rfile",
|
|
"_npmUser": {
|
|
"name": "forbeslindesay",
|
|
"email": "forbes@lindesay.co.uk"
|
|
},
|
|
"_npmVersion": "1.2.10",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "rfile@~1.0.0",
|
|
"scope": null,
|
|
"escapedName": "rfile",
|
|
"name": "rfile",
|
|
"rawSpec": "~1.0.0",
|
|
"spec": ">=1.0.0 <1.1.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/ruglify",
|
|
"/umd"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/rfile/-/rfile-1.0.0.tgz",
|
|
"_shasum": "59708cf90ca1e74c54c3cfc5c36fdb9810435261",
|
|
"_shrinkwrap": null,
|
|
"_spec": "rfile@~1.0.0",
|
|
"_where": "/Users/MB/git/pdfkit/node_modules/umd",
|
|
"author": {
|
|
"name": "ForbesLindesay"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/ForbesLindesay/rfile/issues"
|
|
},
|
|
"dependencies": {
|
|
"callsite": "~1.0.0",
|
|
"resolve": "~0.3.0"
|
|
},
|
|
"description": "Require a plain text or binary file in node.js",
|
|
"devDependencies": {
|
|
"mocha": "~1.8"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"shasum": "59708cf90ca1e74c54c3cfc5c36fdb9810435261",
|
|
"tarball": "https://registry.npmjs.org/rfile/-/rfile-1.0.0.tgz"
|
|
},
|
|
"gitHead": "d82e3088d06d2a8ce94f51fa7536555c3947e74f",
|
|
"homepage": "https://github.com/ForbesLindesay/rfile#readme",
|
|
"keywords": [
|
|
"require",
|
|
"file",
|
|
"text",
|
|
"relative",
|
|
"module"
|
|
],
|
|
"license": "MIT",
|
|
"main": "index.js",
|
|
"maintainers": [
|
|
{
|
|
"name": "forbeslindesay",
|
|
"email": "forbes@lindesay.co.uk"
|
|
}
|
|
],
|
|
"name": "rfile",
|
|
"optionalDependencies": {},
|
|
"readme": "# rfile\r\n\r\n[![Build Status](https://secure.travis-ci.org/ForbesLindesay/rfile.png)](http://travis-ci.org/ForbesLindesay/rfile)\r\n[![Dependency Status](https://gemnasium.com/ForbesLindesay/rfile.png)](https://gemnasium.com/ForbesLindesay/rfile)\r\n\r\nrequire a plain text or binary file in node.js\r\n\r\n## Installation\r\n\r\n $ npm install rfile\r\n\r\n## Usage\r\n\r\n```javascript\r\nvar rfile = require('rfile');\r\n\r\nvar text = rfile('./my-text-file.txt');\r\nvar mochaReadme = rfile('mocha/readme.md');\r\nvar mochaSource = rfile('mocha');\r\nvar image = rfile('image.png', {binary: true});\r\n```\r\n\r\n## API\r\n\r\n### rfile(pkg, options)\r\n\r\n Uses `rfile.resolve` (see below) to look up your file `pkg`. This means it supports all the same options as `rfile.resolve`. Having found the file, it does the following:\r\n\r\n```javascript\r\nreturn options.binary ? read(path) : fixup(read(path).toString());\r\n```\r\n\r\n `options.binary` defaults to `false` and `fixup` removes the UTF-8 BOM if present and removes any `\\r` characters (added to newlines on windows only).\r\n\r\n### rfile.resolve(pkg, options)\r\n\r\n Internally, [resolve](https://npmjs.org/package/resolve) is used to lookup your package, so it supports all the same options as that. In addition t defaults `basedir` to the directory of the function which called `rfile` or `rfile.resolve`.\r\n\r\n The additional option `exclude` is useful if you wanted to create a wrapper arround this. It specifies the filenames not to consider for `basedir` paths. For example, you could create a module called `ruglify` for requiring and minifying JavaScript in one go.\r\n\r\n ruglify.js\r\n```javascript\r\nvar rfile = require('rfile');\r\nvar uglify require('uglify-js').minify;\r\n\r\nmodule.exports = ruglify;\r\nfunction ruglify(path, options) {\r\n return minify(rfile.resolve(path, {exclude: [__filename]}), options).code;\r\n}\r\n```\r\n\r\n#### From `resolve`\r\n\r\n - opts.basedir - directory to begin resolving from (defaults to `__dirname` of the calling module for `rfile`)\r\n - opts.extensions - array of file extensions to search in order (defaults to `['.js', '.json']` for `rfile`)\r\n - opts.readFile - how to read files asynchronously\r\n - opts.isFile - function to asynchronously test whether a file exists\r\n - opts.packageFilter - transform the parsed package.json contents before looking at the \"main\" field (useful for browserify etc.)\r\n - opts.paths - require.paths array to use if nothing is found on the normal node_modules recursive walk (probably don't use this)\r\n\r\n## Notes\r\n\r\nOne of the interesting features of this is that it respects the `main` field of package.json files. Say you had a module called `foo`, you could have a package.json like:\r\n\r\n```json\r\n{\r\n \"name\": \"foo\",\r\n \"version\": \"1.0.0\",\r\n \"main\": \"./foo\"\r\n}\r\n```\r\n\r\nYou might then have a `foo.js` file, containing the JavaScript code of the module, and a `foo.css` file containing the stylesheet for the module when used in the browser. Using `rfile` you could load the css by simply calling:\r\n\r\n```javascript\r\nrfile('foo', {extensions: ['.css']});\r\n```\r\n\r\n## License\r\n\r\n MIT",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/ForbesLindesay/rfile.git"
|
|
},
|
|
"scripts": {
|
|
"test": "mocha -R spec"
|
|
},
|
|
"version": "1.0.0"
|
|
}
|