@stdlib/string-base-remove-last-code-point
v0.2.2
Published
Remove the last Unicode code point of a string.
Downloads
13
Readme
removeLastCodePoint
Remove the last
n
Unicode code points of a string.
Installation
npm install @stdlib/string-base-remove-last-code-point
Usage
var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' );
removeLastCodePoint( str, n )
Removes the last n
Unicode code points of a string.
var out = removeLastCodePoint( 'last man standing', 1 );
// returns 'last man standin'
out = removeLastCodePoint( 'Hidden Treasures', 1 );
// returns 'Hidden Treasure'
out = removeLastCodePoint( 'foo bar', 5 );
// returns 'fo'
out = removeLastCodePoint( 'foo bar', 10 );
// returns ''
Examples
var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' );
var str = removeLastCodePoint( 'presidential election', 1 );
// returns 'presidential electio'
str = removeLastCodePoint( 'JavaScript', 1 );
// returns 'JavaScrip'
str = removeLastCodePoint( 'The Last of the Mohicans', 5 );
// returns 'The Last of the Moh'
str = removeLastCodePoint( 'अनुच्छेद', 1 );
// 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
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.