A dictionary of file extensions and associated module loaders.
This is used by Liftoff to automatically require dependencies for configuration files, and by rechoir for registering module loaders.
Map file types to modules which provide a require.extensions loader.
{
'.babel.js': [
{
module: 'babel-register',
register: function (module) {
module({
// register on .js extension due to https://github.com/joyent/node/blob/v0.12.0/lib/module.js#L353
// which only captures the final extension (.babel.js -> .js)
extensions: '.js'
});
}
},
{
module: 'babel-core/register',
register: function (module) {
module({
extensions: '.js'
});
}
},
{
module: 'babel/register',
register: function (module) {
module({
extensions: '.js'
});
}
}
],
'.cirru': 'cirru-script/lib/register',
'.cjsx': 'node-cjsx/register',
'.co': 'coco',
'.coffee': ['coffee-script/register', 'coffee-script'],
'.coffee.md': ['coffee-script/register', 'coffee-script'],
'.csv': 'require-csv',
'.eg': 'earlgrey/register',
'.iced': ['iced-coffee-script/register', 'iced-coffee-script'],
'.iced.md': 'iced-coffee-script/register',
'.ini': 'require-ini',
'.js': null,
'.json': null,
'.json5': 'json5/lib/require',
'.jsx': [
{
module: 'babel-register',
register: function (module) {
module({
extensions: '.jsx'
});
}
},
{
module: 'babel-core/register',
register: function (module) {
module({
extensions: '.jsx'
});
}
},
{
module: 'babel/register',
register: function (module) {
module({
extensions: '.jsx'
});
},
},
{
module: 'node-jsx',
register: function (module) {
module.install({
extension: '.jsx',
harmony: true
});
}
}
],
'.litcoffee': ['coffee-script/register', 'coffee-script'],
'.liticed': 'iced-coffee-script/register',
'.ls': ['livescript', 'LiveScript'],
'.node': null,
'.toml': {
module: 'toml-require',
register: function (module) {
module.install();
}
},
'.ts': ['ts-node/register', 'typescript-node/register', 'typescript-register', 'typescript-require'],
'.tsx': ['ts-node/register', 'typescript-node/register'],
'.wisp': 'wisp/engine/node',
'.xml': 'require-xml',
'.yaml': 'require-yaml',
'.yml': 'require-yaml'
};
Same as above, but only include the extensions which are javascript variants.
Consumers should use the exported extensions
or jsVariants
object to determine which module should be loaded for a given extension. If a matching extension is found, consumers should do the following:
If the value is null, do nothing.
If the value is a string, try to require it.
If the value is an object, try to require the module
property. If successful, the register
property (a function) should be called with the module passed as the first argument.
If the value is an array, iterate over it, attempting step #2 or #3 until one of the attempts does not throw.
# 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 is used by [Liftoff](http://github.com/tkellen/node-liftoff) to automatically require dependencies for configuration files, and by [rechoir](http://github.com/tkellen/node-rechoir) for registering module loaders. ## API ### extensions Map file types to modules which provide a [require.extensions] loader. ```js { '.babel.js': [ { module: 'babel-register', register: function (module) { module({ // register on .js extension due to https://github.com/joyent/node/blob/v0.12.0/lib/module.js#L353 // which only captures the final extension (.babel.js -> .js) extensions: '.js' }); } }, { module: 'babel-core/register', register: function (module) { module({ extensions: '.js' }); } }, { module: 'babel/register', register: function (module) { module({ extensions: '.js' }); } } ], '.cirru': 'cirru-script/lib/register', '.cjsx': 'node-cjsx/register', '.co': 'coco', '.coffee': ['coffee-script/register', 'coffee-script'], '.coffee.md': ['coffee-script/register', 'coffee-script'], '.csv': 'require-csv', '.eg': 'earlgrey/register', '.iced': ['iced-coffee-script/register', 'iced-coffee-script'], '.iced.md': 'iced-coffee-script/register', '.ini': 'require-ini', '.js': null, '.json': null, '.json5': 'json5/lib/require', '.jsx': [ { module: 'babel-register', register: function (module) { module({ extensions: '.jsx' }); } }, { module: 'babel-core/register', register: function (module) { module({ extensions: '.jsx' }); } }, { module: 'babel/register', register: function (module) { module({ extensions: '.jsx' }); }, }, { module: 'node-jsx', register: function (module) { module.install({ extension: '.jsx', harmony: true }); } } ], '.litcoffee': ['coffee-script/register', 'coffee-script'], '.liticed': 'iced-coffee-script/register', '.ls': ['livescript', 'LiveScript'], '.node': null, '.toml': { module: 'toml-require', register: function (module) { module.install(); } }, '.ts': ['ts-node/register', 'typescript-node/register', 'typescript-register', 'typescript-require'], '.tsx': ['ts-node/register', 'typescript-node/register'], '.wisp': 'wisp/engine/node', '.xml': 'require-xml', '.yaml': 'require-yaml', '.yml': 'require-yaml' }; ``` ### jsVariants Same as above, but only include the extensions which are javascript variants. ## How to use it Consumers should use the exported `extensions` or `jsVariants` object to determine which module should be loaded for a given extension. If a matching extension is found, consumers should do the following: 1. If the value is null, do nothing. 2. If the value is a string, try to require it. 3. If the value is an object, try to require the `module` property. If successful, the `register` property (a function) should be called with the module passed as the first argument. 4. If the value is an array, iterate over it, attempting step #2 or #3 until one of the attempts does not throw. [require.extensions]: http://nodejs.org/api/globals.html#globals_require_extensions
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/interpret/README.md | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |