Détail du package

better-require

olalonde130BSD0.0.3

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.

require, json, yaml, yml

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