lang-map
Get the language associated with a file extension or the extensions associated with a language using the data from GitHub's Linguist YAML file
Heads up! API Changes in 0.4.0
The API changed in v0.4.0. Please see the documentation below for details on the new API. Don't hesitate to create an issue if you have any questions.
Install
Install with npm
$ npm i lang-map --save
Usage
var map = ;
Get language by extension
Returns the language that is associated with the given file extension (with or without .
):
var map = ; map;//=> [ 'coffeescript' ]map;//=> [ 'handlebars' ]map;//=> [ 'handlebars' ]map;//=> [ 'javascript' ]map;//=> [ 'javascript' ]map;//=> [ 'markdown' ]map;//=> [ 'markdown' ]
Why is an array of languages returned?
In some (rare) cases an extension maps to multiple languages.
map;//=> [ 'c', 'c++', 'objective-c' ]
Get extensions by language
Returns the list of file extensions associated with the given language:
var map = ; map;//=> [ 'coffee', '_coffee', 'cjsx', 'cson', 'iced' ]map;//=> [ 'handlebars', 'hbs' ]map;//=> [ 'md', 'markdown', 'mkd', 'mkdn', 'mkdown', 'ron' ]map;//=> [ 'md', 'markdown', 'mkd', 'mkdn', 'mkdown', 'ron' ]map;//=> [ 'c', 'cats', 'h', 'idc', 'w' ]
Get the object of entensions
var map = ;var extensions = extensions;
Get the object of languages
var map = ;var languages = languages;
Related projects
language-map: GitHub's Linguist YAML language map provided as JSON
Updating languages
Update the .json
language files in lib/.
$ npm run update
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on August 18, 2015.