MCPcopy Create free account
hub / github.com/R-js/libRmath.js / verifyPaths

Function verifyPaths

scripts/helpers.mjs:6–31  ·  view source on GitHub ↗
(paths)

Source from the content-addressed store, hash-verified

4
5
6export function verifyPaths(paths) {
7 if (Object.keys(paths).length === 0){
8 return true;
9 }
10 // must end with '*' or not have '*' at all
11 const errors = []
12 for (const path of Object.keys(paths)){
13 const stars = path.match(/\*/g);
14 if (stars?.length > 1){
15 errors.push(`Path has more then one "*" token: ${paths}`);
16 continue;
17 } else if (stars?.length === 1){
18 if (!path.endsWith('*')){
19 errors.push(`Path "*" token not at the end of path: ${path}`);
20 continue;
21 }
22 } else {
23 // exact paths must have only one entry
24 if (paths[path].length !== 1){
25 errors.push(`exact path aliases must have only one value: [${path}] has ${paths[path].length} values`);
26 }
27 }
28
29 }
30 return errors.length ? errors : true;
31}
32
33function sortOnStringLengthDescending(a, b){
34 return b.length - a.length;

Callers 1

createCompilerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected