How to use the jscpd/lib/tokenizer/TokenizerFactory.prototype function in jscpd

To help you get started, we’ve selected a few jscpd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xcatliu / cqc / src / JscpdChecker / getLanguageFromFilepath.js View on Github external
const path = require('path');

const TokenizerFactory = require('jscpd/lib/tokenizer/TokenizerFactory');

const languageToExtentionMap = TokenizerFactory.prototype.LANGUAGES;
const extensionToLanguageMap = {};

Object.keys(languageToExtentionMap).forEach((language) => {
    languageToExtentionMap[language].forEach((extention) => {
        extensionToLanguageMap[extention] = language;
    });
});

module.exports = function getLanguageFromFilepath(filepath) {
    const extension = path.extname(filepath).slice(1);
    const result = extensionToLanguageMap[extension];
    if (typeof result === 'undefined') {
        return 'js';
    }
    return result;
};

jscpd

detector of copy/paste in files

MIT
Latest version published 6 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages