@stdlib/string-base-slice-code-points
v0.1.1
Published
Slice a string based on Unicode code points.
Downloads
33
Readme
sliceCodePoints
Slice a string based on Unicode code point indices.
Installation
npm install @stdlib/string-base-slice-code-pointsUsage
var sliceCodePoints = require( '@stdlib/string-base-slice-code-points' );sliceCodePoints( str, start, end )
Slices a string based on Unicode code point indices.
var out = sliceCodePoints( 'Hello 👋 World', 0, 7 );
// returns 'Hello 👋'
out = sliceCodePoints( '👋👋👋', 1, 2 );
// returns '👋'The function accepts the following arguments:
- str: input string.
- start: the
ithUnicode code point to start a slice (inclusive). - end: the
jthUnicode code point to end a slice (exclusive).
Examples
var sliceCodePoints = require( '@stdlib/string-base-slice-code-points' );
console.log( sliceCodePoints( 'Hello 👋 World', 0, 7 ) );
// => 'Hello 👋'
console.log( sliceCodePoints( 'last man standing', 1, 17 ) );
// => 'ast man standing'
console.log( sliceCodePoints( '六书/六書', 1, 14 ) );
// => '书/六書'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.
