MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / parseArgs

Function parseArgs

scripts/fungrim/artifact-freshness.ts:35–52  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

33const DEFAULT_SAMPLE = 25;
34
35function parseArgs(argv: string[]): { sample: number } {
36 const args = { sample: DEFAULT_SAMPLE };
37 for (let i = 2; i < argv.length; i++) {
38 switch (argv[i]) {
39 case '--sample':
40 args.sample = Number(argv[++i]);
41 if (!Number.isInteger(args.sample) || args.sample < 2) {
42 console.error('--sample must be an integer >= 2');
43 process.exit(2);
44 }
45 break;
46 default:
47 console.error(`Unknown argument: ${argv[i]}`);
48 process.exit(2);
49 }
50 }
51 return args;
52}
53
54/** Evenly spaced deterministic sample of `k` indices over [0, n). */
55function strideSample(n: number, k: number): number[] {

Callers 1

mainFunction · 0.70

Calls 2

errorMethod · 0.65
isIntegerMethod · 0.45

Tested by

no test coverage detected