Skip to content

eush77/range-lookup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm

range-lookup

Dependency Status

Find all matching DOM ranges for a given text string.

Demo.

Example

var rangeLookup = require('range-lookup');

var ranges = rangeLookup('some string');

ranges
//=> Array [ Range, Range, Range, Range ]

// Highlight ranges.
var selection = window.getSelection();
ranges.forEach(selection.addRange.bind(selection));

API

rangeLookup(query, [opts])

query — string to search for.

Returns array of matching ranges.

opts.ignoreCase

Whether to ignore case while attempting a match in a string. Defaults to false.

Limitations

  • This module is not capable of matching text that crosses text nodes boundaries.

Install

npm install range-lookup

License

MIT

About

Find matching DOM ranges for a given text string

Resources

License

Stars

Watchers

Forks

Packages

No packages published