better-require
v0.0.3
Published
require('better-require')('json yaml') lets you load JSON and YAML files using require syntax. For example: var config = require('./config.json'); Extensions available are: json, yaml.
Downloads
241
Readme
Adds file formats supported by require(). Will always return a JSON representation.
Supported file types are: json
, yaml
, csv
, xml
, ini
.
Install
npm install better-require
Example
require('better-require')('json');
var config = require('./config.json');
console.log(config);
Enable support for mutliple file types:
require('better-require')('json yaml xml');
// we can now require .xml, .yaml and .xml files!
var config = require('./config.yaml');
console.log(config);
Dependencies
Reference
http://nodejs.org/api/all.html#all_require_extensions