-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
190 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import languageList from './language-list'; | ||
|
||
/** | ||
* 通过 extname 配合 filename 获取对应的语言 | ||
* @param {string} extname | ||
* @param {string} filename | ||
*/ | ||
export const getLanguageIdByExtnameAndFilename = (extname, filename) => { | ||
// 先用 filename 去查找 | ||
let result = languageList.find(language => Array.isArray(language.filenames) && language.filenames.includes(filename)); | ||
if (!result) { | ||
result = languageList.find(language => Array.isArray(language.extensions) && language.extensions.includes(extname)); | ||
} | ||
return result; | ||
}; | ||
|
||
/** | ||
* 是否存在对应的 language id | ||
* @param {string} languageId | ||
* @returns boolean | ||
*/ | ||
export const hasLanguageId = (languageId) => { | ||
return languageList.findIndex(language => language.id === languageId) > -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const languageList = require('./language-list'); | ||
|
||
/** | ||
* 通过 extname 配合 filename 获取对应的语言 | ||
* @param {string} extname | ||
* @param {string} filename | ||
*/ | ||
exports.getLanguageIdByExtnameAndFilename = (extname, filename) => { | ||
// 先用 filename 去查找 | ||
let result = languageList.find(language => Array.isArray(language.filenames) && language.filenames.includes(filename)); | ||
if (!result) { | ||
result = languageList.find(language => Array.isArray(language.extensions) && language.extensions.includes(extname)); | ||
} | ||
return result; | ||
}; | ||
|
||
/** | ||
* 是否存在对应的 language id | ||
* @param {string} languageId | ||
* @returns boolean | ||
*/ | ||
exports.hasLanguageId = (languageId) => { | ||
return languageList.findIndex(language => language.id === languageId) > -1; | ||
} |