source: trip-planner-front/node_modules/source-list-map/lib/helpers.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • 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
7exports.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
17exports.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.