Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const findMatchOffsets = (speech, matches) => {
const speechOffsets = findSpeechOffsets(speech)
, tree = createIntervalTree(speechOffsets)
return matchesToIntervals(matches).map(([start, end]) => {
let matchOffsets = Map()
tree.queryInterval(start, end, (offset) => {
let i = speechOffsets.indexOf(offset)
matchOffsets = matchOffsets.set(i, List.of(
Math.max(0, start - offset[0]),
Math.min(offset[1] - offset[0], end - offset[0]))
)
})
return matchOffsets
})
}