Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

prevOpen Source→str-indexes-of-plusnext

str-indexes-of-plus5.2.1

Like indexOf but returns array and counts per-grapheme

Downloads per monthChangelogMIT Licenselibera manifesto
  • the top
  • Installation
  • Quick Take
  • Examples
  • COMPARED TO…
  • API — STRINDEXESOFP…
  • API — VERSION
  • TRIVIA
  • Changelog

Installation

Quick Take

Examples

  • Search for an empty string
  • Report overlapping matches
  • Start searching from a given index
  • Emoji count as single characters

Compared to Others

method / programreturnsindex system based on
String.prototype.indexOf()opens in a new tab
String.prototype.indexOf()opens in a new tabindex where the first finding startscode point count
str-indexes-ofopens in a new tab
str-indexes-ofopens in a new tabarray of indexes where each finding startscode point count
📦 This package,
str-indexes-of-plus
📦 This package,
str-indexes-of-plus
array of indexes where each finding startsgrapheme count

See thisopens in a new tab article about Unicode, graphemes and code points.

API — strIndexesOfPlus()

The main function strIndexesOfPlus() is imported like this:

It’s a function which takes three input arguments:

Input argumentTypeObligatoryDescription
str
Type: string
Obligatory: yes
strstringyesSource string, where to search.
searchValue
Type: string
Obligatory: yes
searchValuestringyesWhat to search for.
fromIndex
Type: natural number or zero
Obligatory: no
fromIndexnatural number or zeronoIf set, the searching will start from this index.

Function will return an array of zero or more numbers, each indicating the index of each finding’s first character. Unicode astral characters are counted, as one character-long.

API — version

You can import version:

Trivia

Roy asked ~Shinnnopens in a new tab is it all right to create grapheme-count-based-index alternative of his str-indexes-ofopens in a new tab and he said it’s OK.

Changelog

Open Changelog
↑ back to top
prev next

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab