finki-main
main
|
Last change
on this file since 81bc7da was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago |
|
Initial commit
|
-
Property mode
set to
100644
|
|
File size:
394 bytes
|
| Rev | Line | |
|---|
| [81bc7da] | 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.