interpreting
v0.0.1
Published
Require any file extension of interpret dictionary.
Downloads
1
Maintainers
Readme
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 interpreting
yarn
yarn add interpreting
Usage
const interpreting = require('interpreting')
// or
import interpreting from 'interpreting'
Examples
// config.babel.js
export const value = 1
interpreting('./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:
string
string[]
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 [email protected]
License
MIT