import { reshapeInput } from "./utils/prepare" ; /**
 * This represents test options. You can specify if the source string should be
 * lower cased or not (wether you want the test to be case-sensitive or not).
 */ export interface TestOptions { caseSensitive ? : boolean ; } param query param source param opts returns export function test ( query , source , opts = { } ) { const [ reshapedQuery , reshapedSource ] = reshapeInput ( query , source , opts ) ; if ( ! reshapedSource . length ) { return ! query . length ; } if ( ! reshapedQuery . length ) { return true ; } if ( reshapedQuery . length > reshapedSource . length ) { return false ; } let queryPos = 0 ; let sourcePos = 0 ; while ( sourcePos < source . length ) { const actualSourceCharacter = reshapedSource [ sourcePos ] ; const queryCharacterWaitingForMatch = reshapedQuery [ queryPos ] ; if ( actualSourceCharacter === queryCharacterWaitingForMatch ) { queryPos += 1 ; } sourcePos += 1 ; } return queryPos === reshapedQuery . length ; }