string-convert-indexes
v6.2.5
Published
Convert between native JS string character indexes and grapheme-count-based indexes
Maintainers
Readme
Powered by unicode-segmenter. No other dependencies.
Install
This package is pure ESM. If you're not ready yet, install an older version of this program, 4.1.0 (npm i [email protected]).
npm i string-convert-indexesQuick Take
import { strict as assert } from "node:assert";
import { nativeToUnicode } from "string-convert-indexes";
// CONVERTING NATIVE JS INDEXES TO UNICODE-CHAR-COUNT-BASED
// 𝌆 - \uD834\uDF06
// at index 1, we have low surrogate, that's still grapheme index zero
assert.equal(nativeToUnicode("\uD834\uDF06aa", "1"), "0");
// notice it's retained as string. The same type as input is retained!Documentation
Please visit codsen.com for a full description of the API. For Changelog, see raw md on GitHub or the website.
Contributing
To report bugs or request features or assistance, raise an issue on GitHub.
Licence
MIT License
Copyright © 2010-2026 Roy Revelt and other contributors
