How to use interval-tree-1d - 1 common examples

To help you get started, we’ve selected a few interval-tree-1d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github contours / react-transcript-player / src / search.js View on Github external
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
  })
}

interval-tree-1d

1D interval tree data structure

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular interval-tree-1d functions