mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
14 lines
290 B
TypeScript
14 lines
290 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
/**
|
|
* Gives the length of a string in Unicode code points
|
|
*
|
|
* ```
|
|
* codePointLength("🐱"); // 1
|
|
* "🐱".length; // 2
|
|
* ```
|
|
*/
|
|
export function codePointLength(s: string) {
|
|
return Array.from(s).length;
|
|
}
|