123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- "use strict";
- const Graphemer = require("graphemer").default;
- const ASCII_REGEX = /^[\u0000-\u007f]*$/u;
- let splitter;
- function upperCaseFirst(string) {
- if (string.length <= 1) {
- return string.toUpperCase();
- }
- return string[0].toUpperCase() + string.slice(1);
- }
- function getGraphemeCount(value) {
- if (ASCII_REGEX.test(value)) {
- return value.length;
- }
- if (!splitter) {
- splitter = new Graphemer();
- }
- return splitter.countGraphemes(value);
- }
- module.exports = {
- upperCaseFirst,
- getGraphemeCount
- };
|