[add] implement vulnerability checking and advisory fetching, enhance repo processing, and add utility functions
This commit is contained in:
26
src_vuln/lib.mjs
Normal file
26
src_vuln/lib.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
import assert from "assert";
|
||||
|
||||
/**
|
||||
* Bifurcate an array into two arrays based on a predicate function.
|
||||
* @template T
|
||||
* @param {T[]} arr
|
||||
* @param {(T)=>boolean} predicate
|
||||
* @returns {[T[], T[]]}
|
||||
*/
|
||||
export function bifurcateArray(arr, predicate) {
|
||||
const truthy = [];
|
||||
const falsy = [];
|
||||
for (const item of arr) {
|
||||
if (predicate(item)) {
|
||||
truthy.push(item);
|
||||
} else {
|
||||
falsy.push(item);
|
||||
}
|
||||
}
|
||||
return [truthy, falsy];
|
||||
}
|
||||
export function getGithubTokenFromEnvironment() {
|
||||
assert(process.env.GITHUB_TOKEN, "No token :(");
|
||||
const githubToken = process.env.GITHUB_TOKEN;
|
||||
return githubToken;
|
||||
}
|
Reference in New Issue
Block a user