MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / getLineNumber

Function getLineNumber

ses.cjs:5714–5726  ·  view source on GitHub ↗

* Find the first occurence of the given pattern and return * the location as the approximate line number. * * @param {string} src * @param {RegExp} pattern * @returns {number}

(src, pattern)

Source from the content-addressed store, hash-verified

5712 * @returns {number}
5713 */
5714function getLineNumber(src, pattern) {
5715 const index= stringSearch(src, pattern);
5716 if( index< 0) {
5717 return -1;
5718 }
5719
5720 // The importPattern incidentally captures an initial \n in
5721 // an attempt to reject a . prefix, so we need to offset
5722 // the line number in that case.
5723 const adjustment= src[index]=== '\n'? 1: 0;
5724
5725 return stringSplit(stringSlice(src, 0, index), '\n').length+ adjustment;
5726 }
5727
5728// /////////////////////////////////////////////////////////////////////////////
5729

Callers 3

rejectHtmlCommentsFunction · 0.85
rejectImportExpressionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected