0.0.1 • Published 8 years ago
interpreting v0.0.1
interpreting
Require any file extension of interpret dictionary.
Require using the dictionary of file extensions and associated module loaders from interpret dictionary. Useful, for example, to allow config files in any supported file extension, like requiring webpack config file just doing interpreting('./webpack.config').
Available file extensions and the associated module loader:
.js: none.babel.js:babel-register.buble.js:buble.cirru:cirru-script.cjsx:node-cjsx.co:coco.coffee:coffee-script.coffee.md:coffee-script.csv:require-csv.eg:earlgrey.iced:iced-coffee-script.iced.md:iced-coffee-script.ini:require-ini.json: none.json5:json5.jsx:babel-register.litcoffee:coffee-script.liticed:iced-coffee-script.ls:livescript.node: none.toml:toml-require.ts:ts-node.tsx:ts-node.wisp:wisp.xml:require-xml.yaml:require-yaml.yml:require-yaml
Install
npm
npm install --save interpretingyarn
yarn add interpretingUsage
const interpreting = require('interpreting')
// or
import interpreting from 'interpreting'Examples
// config.babel.js
export const value = 1interpreting('./config')
// { value: 1 }API
interpreting(path, options)
If path or path.* not exists, returns null or throws a error if options.required is true.
path
- Type:
stringstring[]
File or list of files to require.
options
required
- Type:
boolean - Default:
false
If true, at least one file must be found.
multiple
- Type:
boolean - Default:
false
If false returns the first found file. Otherwise, returns an array with all files founded.
join
- Type:
boolean - Default:
false
If true and multiple is true, returns the Object.assign() result for all files.
Resources
- interpret - A dictionary of file extensions and associated module loaders.
Authors
- Ricardo Ferro ricardo.ferro@gmail.com
License
MIT
0.0.1
8 years ago