0.1.0 • Published 1 month ago

@stdlib/string-base-last-code-point v0.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 month ago

lastCodePoint

NPM version Build Status Coverage Status

Return the last n Unicode code points of a string.

Installation

npm install @stdlib/string-base-last-code-point

Usage

var lastCodePoint = require( '@stdlib/string-base-last-code-point' );

lastCodePoint( str, n )

Returns the last n Unicode code points of a string.

var s = lastCodePoint( 'JavaScript', 1 );
// returns 't'

s = lastCodePoint( 'Hello World', 5 );
// returns 'World'

s = lastCodePoint( 'Good Evening', 9 );
// returns 'd Evening'

s = lastCodePoint( 'foo bar', 10 );
// returns 'foo bar'

Examples

var lastCodePoint = require( '@stdlib/string-base-last-code-point' );

var str = lastCodePoint( 'Hello World', 1 );
// returns 'd'

str = lastCodePoint( 'JavaScript', 6 );
// returns 'Script'

str = lastCodePoint( 'ASCII', 2 );
// returns 'II'

str = lastCodePoint( 'index', 10 );
// returns 'index'

str = lastCodePoint( 'अनुच्छेद', 1 );
// returns 'द'

str = lastCodePoint( '六书/六書', 3 );
// returns '/六書'

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

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.