(path: string)
| 320 | }; |
| 321 | |
| 322 | const dirname = function dirname(path: string) { |
| 323 | assertPath(path); |
| 324 | if (path.length === 0) { |
| 325 | return '.'; |
| 326 | } |
| 327 | let code = path.charCodeAt(0); |
| 328 | const hasRoot = code === 47; /*/*/ |
| 329 | let end = -1; |
| 330 | let matchedSlash = true; |
| 331 | for (let i = path.length - 1; i >= 1; --i) { |
| 332 | code = path.charCodeAt(i); |
| 333 | if (code === 47 /*/*/) { |
| 334 | if (!matchedSlash) { |
| 335 | end = i; |
| 336 | break; |
| 337 | } |
| 338 | } else { |
| 339 | // We saw the first non-path separator |
| 340 | matchedSlash = false; |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | if (end === -1) { |
| 345 | return hasRoot ? '/' : '.'; |
| 346 | } |
| 347 | if (hasRoot && end === 1) { |
| 348 | return '//'; |
| 349 | } |
| 350 | return path.slice(0, end); |
| 351 | }; |
| 352 | |
| 353 | const basename = function basename(path: string, ext: string) { |
| 354 | if (ext !== undefined && typeof ext !== 'string') { |
no test coverage detected
searching dependent graphs…