Skip to content

Function.splitByLength

github-actions[bot] edited this page Jun 4, 2026 · 21 revisions

umt / splitByLength

Function: splitByLength()

splitByLength(string_, length): string[]

Defined in: String/splitByLength.ts:10

Splits a string into chunks of the specified length. Surrogate-pair safe, so characters outside the Basic Multilingual Plane are not split.

Parameters

string_

string

Input string

length

number

Maximum length of each chunk

Returns

string[]

Array of string chunks

Example

splitByLength("abcdefg", 3); // ["abc", "def", "g"]

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally