Package Exports
- quickly-count-substrings
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (quickly-count-substrings) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
quickly-count-substrings
Fast module for counting the number of occurrences of a substring inside a string.
Installation
npm install quickly-count-substrings --saveUsage
const count = require('quickly-count-substrings')
const str = 'The quick brown fox jumps over the lazy dog'
count(str, 'o') // => 4API
result = count(str, substr[, options])
Returns number of occurrences of substr in str.
Arguments:
str- The string to search insubstr- The string to search foroptions- Optional. If{overlap: true}, overlapping substrings will be counted (default:{overlap: false})
Benchmark
Counting substrings in a 24MB string:
# quickly-count-substrings
ok ~44 ms (0 s + 43676071 ns)
# count-substring
ok ~134 ms (0 s + 133563148 ns)
# string-occurrence
ok ~184 ms (0 s + 183978927 ns)
# needle-string
ok ~116 ms (0 s + 115521420 ns)
# regex-occurrence
ok ~169 ms (0 s + 169180879 ns)
# count-strings
ok ~491 ms (0 s + 490783663 ns)License
MIT