|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
464 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
|---|
| 3 | Author Tobias Koppers @sokra
|
|---|
| 4 | */
|
|---|
| 5 | "use strict";
|
|---|
| 6 |
|
|---|
| 7 | exports.getNumberOfLines = function getNumberOfLines(str) {
|
|---|
| 8 | let nr = -1;
|
|---|
| 9 | let idx = -1;
|
|---|
| 10 | do {
|
|---|
| 11 | nr++
|
|---|
| 12 | idx = str.indexOf("\n", idx + 1);
|
|---|
| 13 | } while(idx >= 0);
|
|---|
| 14 | return nr;
|
|---|
| 15 | };
|
|---|
| 16 |
|
|---|
| 17 | exports.getUnfinishedLine = function getUnfinishedLine(str) {
|
|---|
| 18 | const idx = str.lastIndexOf("\n");
|
|---|
| 19 | if(idx === -1)
|
|---|
| 20 | return str.length;
|
|---|
| 21 | else
|
|---|
| 22 | return str.length - idx - 1;
|
|---|
| 23 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.