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

prevOpen Source→ranges-iteratenext

ranges-iterate4.2.0

Iterate a string and any changes within given string index ranges

Downloads per monthChangelogMIT Licenselibera manifesto
  • the top
  • Installation
  • Quick Take
  • Examples
  • API — RITERATE()
  • API — VERSION
  • API — TYPES
  • Changelog

Installation

Quick Take

Examples

  • Skip characters covered by a deletion range
  • Iterate text inserted at the end of a string
  • Iterate the result of multiple replacements
  • Iterate the original string when there are no ranges
  • Start iteration at an existing output offset

API — rIterate()

The main function rIterate() is imported like this:

It’s a function which takes four input arguments:

Input argumentTypeObligatoryDescription
str
Type: string
Obligatory: yes
strstringyesThe input string to operate on
ranges
Type: null or array of zero or more arrays (ranges)
Obligatory: yes
rangesnull or array of zero or more arrays (ranges)yesThe ranges gathered so far
cb
Type: Something falsy or a function
Obligatory: yes
cbSomething falsy or a functionyesCallback function to be able to consume the indexes and character values
offset
Type: String index, a natural number
Obligatory: no
offsetString index, a natural numbernoSimilar to second argument of String.prototype.indexOf(), start to process the string only after this position

It’s a callback-based API so the function returns undefined.

API — version

You can import version:

API — types

This package is written in TypeScript and exports the following types:

TypeDescription
Callback
Type: Callback
CallbackThe signature of the third input argument — called once per character with an Obj.
Obj
Type: Obj
ObjWhat the callback receives — the index i and the character val at it.
import type { Callback, Obj } from "ranges-iterate";

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