linguist-js
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -10,2 +10,3 @@ "use strict"; | ||
const glob_to_regexp_1 = __importDefault(require("glob-to-regexp")); | ||
const node_cache_1 = __importDefault(require("node-cache")); | ||
const convertToRegex = (path) => glob_to_regexp_1.default('**/' + path, { globstar: true, extended: true }); | ||
@@ -15,3 +16,13 @@ const last = (arr) => arr[arr.length - 1]; | ||
const dataUrl = (file) => `https://raw.githubusercontent.com/github/linguist/HEAD/lib/linguist/${file}`; | ||
const loadFile = async (file) => await cross_fetch_1.default(dataUrl(file)).then(data => data.text()); | ||
const cache = new node_cache_1.default({}); | ||
async function loadFile(file) { | ||
// Return cache if it exists | ||
const cachedContent = cache.get(file); | ||
if (cachedContent) | ||
return cachedContent; | ||
// Otherwise cache the request | ||
const fileContent = await cross_fetch_1.default(dataUrl(file)).then(data => data.text()); | ||
cache.set(file, fileContent); | ||
return fileContent; | ||
} | ||
function pcre(regex) { | ||
@@ -18,0 +29,0 @@ let finalRegex = regex; |
{ | ||
"name": "linguist-js", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.", | ||
@@ -11,3 +11,3 @@ "main": "dist/index.js", | ||
"prepublish": "tsc", | ||
"perf": "node test/perf", | ||
"perf": "tsc && node test/perf", | ||
"test": "tsc && node test/test" | ||
@@ -40,2 +40,3 @@ }, | ||
"js-yaml": "^4.1.0", | ||
"node-cache": "^5.1.2", | ||
"tiny-glob": "^0.2.9" | ||
@@ -48,3 +49,6 @@ }, | ||
"typescript": "~4.3.5" | ||
}, | ||
"engines": { | ||
"node": "^12 || ^14 || >=16" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25423
385
6
+ Addednode-cache@^5.1.2
+ Addedclone@2.1.2(transitive)
+ Addednode-cache@5.1.2(transitive)