@stdlib/string-num-code-points
v0.1.1
Published
Return the number of code points in a string.
Readme
numCodePoints
Return the number of Unicode code points in a string.
Installation
npm install @stdlib/string-num-code-pointsUsage
var numCodePoints = require( '@stdlib/string-num-code-points' );numCodePoints( str )
Returns the number of code points in a string.
var out = numCodePoints( 'last man standing' );
// returns 17
out = numCodePoints( 'Hidden Treasures' );
// returns 16
out = numCodePoints( '👋👋👋' );
// returns 3Examples
var numCodePoints = require( '@stdlib/string-num-code-points' );
console.log( numCodePoints( 'last man standing' ) );
// => 17
console.log( numCodePoints( '六书/六書' ) );
// => 5
console.log( numCodePoints( '🐶🐮🐷🐰🐸' ) );
// => 5
console.log( numCodePoints( 'Hello 👋 World' ) );
// => 13See Also
@stdlib/string-num-code-points-cli: CLI package for use as a command-line utility.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
