Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

butter-require

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

butter-require

A lesser fork of 'olalonde/better-require' - lets you load JSON and YAML files using require syntax. For example: var config = require('./config.json'); Extensions available are: json, yaml.

  • 0.0.2
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-61.29%
Maintainers
1
Weekly downloads
 
Created
Source

A fork of better-require with less supported formats, mainly for usage in uRequire due to some issues and being too heavy.

Formats (& dependencies) removed:

  • xml: who needs that anymore ? It crashes on Windows anyway...
  • six

You can still manually install them of course...


Augments require() with support for multiple file formats.

Supported file formats

... which return a JSON represenation:

... which return a Javascript module:

... work in progress:

  • dynamic libraries
  • ruby
  • python

Behind the scenes, this module adds handlers to require.extensions.

Install

npm install better-require

Usage

/**
 * @param {String} optional - formats is a white space separated list of formats you would like require() to support.
 */
// support all available extensions
require('better-require')();
// support a subset of extensions
require('better-require')(formats);

Example

Enable support for all file types:

require('better-require')();

var config = require('./config.json');
console.log(config);

Enable support for only a subset of 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

Keywords

FAQs

Package last updated on 17 Jan 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc