Negative indices count backwards from the beginning of the string.
Non-integer or out of bounds indices return the string unchanged. If the index equals the length of the string, then the string will be appended to the end.
import * as S from "flurp/string";const f = S.insert(2, "__");const g = S.insert(6, "__");const h = S.insert(-2, "__");f("weasel"); // "we__asel"g("weasel"); // "weasel__"h("weasel"); // "weas__el"
Negative indices count backwards from the beginning of the string.
Remarks
Non-integer or out of bounds indices return the string unchanged. If the index equals the length of the string, then the string will be appended to the end.
Example