Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
394 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | // warning: extremely hot code path.
|
---|
| 2 | // This has been meticulously optimized for use
|
---|
| 3 | // within npm install on large package trees.
|
---|
| 4 | // Do not edit without careful benchmarking.
|
---|
| 5 | module.exports = str => {
|
---|
| 6 | let i = str.length - 1
|
---|
| 7 | let slashesStart = -1
|
---|
| 8 | while (i > -1 && str.charAt(i) === '/') {
|
---|
| 9 | slashesStart = i
|
---|
| 10 | i--
|
---|
| 11 | }
|
---|
| 12 | return slashesStart === -1 ? str : str.slice(0, slashesStart)
|
---|
| 13 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.