Socket
Socket
Sign inDemoInstall

interpret

Package Overview
Dependencies
0
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

15

index.js

@@ -1,2 +0,2 @@

const known = {
exports.extensions = {
'.co': 'coco',

@@ -17,3 +17,3 @@ '.coffee': 'coffee-script',

const install = {
exports.register = {
'coffee-script': function (module) {

@@ -29,12 +29,1 @@ module.register();

};
module.exports = function (ext) {
var moduleName = known[ext];
if (moduleName) {
var compiler = require(moduleName);
var register = install[moduleName];
if (register) {
register(compiler);
}
}
};
{
"name": "interpret",
"description": "Require anything.",
"version": "0.1.0",
"description": "A dictionary of file extensions and associated module loaders.",
"version": "0.2.0",
"homepage": "https://github.com/tkellen/node-interpret",

@@ -24,21 +24,2 @@ "author": {

"main": "index.js",
"scripts": {
"test": "mocha -R spec test/index.js"
},
"engines": {
"node": ">= 0.10"
},
"devDependencies": {
"mocha": "~1.17.1",
"chai": "~1.9.0",
"coco": "^0.9.1",
"coffee-script": "^1.7.1",
"require-csv": "0.0.1",
"iced-coffee-script": "^1.7.1-b",
"require-ini": "0.0.1",
"toml-require": "^1.0.1",
"require-xml": "0.0.1",
"require-yaml": "0.0.1",
"LiveScript": "^1.2.0"
},
"keywords": [

@@ -45,0 +26,0 @@ "coco",

51

README.md

@@ -1,22 +0,47 @@

# interpret [![Build Status](https://secure.travis-ci.org/tkellen/node-interpret.png)](http://travis-ci.org/tkellen/node-interpret)
> Require anything.
# interpret
> A dictionary of file extensions and associated module loaders.
[![NPM](https://nodei.co/npm/interpret.png)](https://nodei.co/npm/interpret/)
## What is it?
This module will find, require and register any file type the npm ecosystem has a module loader for. Once this is done, you can require the provided file type natively.
## What is it
This is used by [rechoir](http://github.com/tkellen/node-rechoir) for registering module loaders.
**Currently supported extensions:**
.co, .coco, .coffee, .iced, .ini, .js, .json, .litcoffee, .ls, .toml, .xml, .yaml, .yml
## API
### learn(extension)
This method will look for a module loader associated with the provided extension and attempt to require it. If necessary, it will also run any setup required to register it with [http://nodejs.org/api/globals.html#globals_require_extensions]. If calling is successful (aka: it doesn't throw), you can now require files with the provided extension natively.
### extensions
Map file types to modules which provide a [require.extensions] loader.
```js
{
'.co': 'coco',
'.coffee': 'coffee-script',
'.csv': 'require-csv',
'.iced': 'iced-coffee-script',
'.ini': 'require-ini',
'.js': null,
'.json': null,
'.litcoffee': 'coffee-script',
'.ls': 'livescript',
'.toml': 'toml-require',
'.xml': 'require-xml',
'.yaml': 'require-yaml',
'.yml': 'require-yaml'
}
```
## Usage
### register
If a module does not automatically register itself with [require.extensions], use one of these methods.
```js
var interpret = require('interpret');
interpret('.coffee');
require('file.coffee');
{
'coffee-script': function (module) {
module.register();
},
'iced-coffee-script': function (module) {
module.register();
},
'toml-require': function (module) {
module.install();
}
}
```
[require.extensions]: http://nodejs.org/api/globals.html#globals_require_extensions

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc