MCPcopy
hub / github.com/rollup/rollup / relative

Function relative

browser/src/path.ts:63–85  ·  view source on GitHub ↗
(from: string, to: string)

Source from the content-addressed store, hash-verified

61}
62
63export function relative(from: string, to: string): string {
64 const fromParts = from.split(ANY_SLASH_REGEX).filter(Boolean);
65 const toParts = to.split(ANY_SLASH_REGEX).filter(Boolean);
66
67 if (fromParts[0] === '.') fromParts.shift();
68 if (toParts[0] === '.') toParts.shift();
69
70 while (fromParts[0] && toParts[0] && fromParts[0] === toParts[0]) {
71 fromParts.shift();
72 toParts.shift();
73 }
74
75 while (toParts[0] === '..' && fromParts.length > 0) {
76 toParts.shift();
77 fromParts.pop();
78 }
79
80 while (fromParts.pop()) {
81 toParts.unshift('..');
82 }
83
84 return toParts.join('/');
85}
86
87export function resolve(...paths: string[]): string {
88 let parts: string[] = [];

Callers 13

getRelativePathFunction · 0.90
foo.jsFile · 0.90
main.jsFile · 0.90
main.jsFile · 0.90
transformFunction · 0.90
transformFunction · 0.90
main.jsFile · 0.90
getFileNameMethod · 0.90
relativeIdFunction · 0.90
getImportPathFunction · 0.90
collapseSourcemapsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…