import * as SourceMap from 'source-map' ; import * as _ from 'lodash' ; import * as ts from 'typescript' ; export function findCodePosition ( code , snippet ) { var lines = code . split ( /[\r\n]/ ) ; var lineNo = _ . findIndex ( lines , ( line ) => _ . includes ( line , snippet ) ) ; if ( lineNo > - 1 ) { var column = ( lineNo > - 1 ) && lines [ lineNo ] . indexOf ( snippet ) ; return { line : lineNo + 1 , column : column } ; } else { return null ; } } export function findCodeRange ( code , snippet ) { var pos = code . indexOf ( snippet ) ; return pos < 0 ? null : { pos , end : pos + snippet . length } ; }