MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / getRelativePath

Function getRelativePath

benchmark/data.js:172–185  ·  view source on GitHub ↗
(from, to)

Source from the content-addressed store, hash-verified

170 return new Array(min + 1).join(' ');
171}
172function getRelativePath(from, to) {
173 const fromParts = from.split(/[/\\]/);
174 const toParts = to.split(/[/\\]/);
175 fromParts.pop();
176 while (fromParts[0] === toParts[0]) {
177 fromParts.shift();
178 toParts.shift();
179 }
180 if (fromParts.length) {
181 let i = fromParts.length;
182 while (i--) fromParts[i] = '..';
183 }
184 return fromParts.concat(toParts).join('/');
185}
186const toString = Object.prototype.toString;
187function isObject(thing) {
188 return toString.call(thing) === '[object Object]';

Callers 2

generateDecodedMapMethod · 0.70
generateDecodedMapMethod · 0.70

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected