Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor truncate string package #1097

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: update package description and update benchmark
steff456 committed Nov 10, 2023
commit 5f56e1decc783afcf80ecae9614148d392657689
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ var truncateCodePoints = require( '@stdlib/string/base/truncate-code-points' );

#### truncateCodePoints( str, len, ending )

Truncates the code points of a provided string in order to return a string having a specified length.
Truncates the Unicode code points of a provided string in order to return a string having a specified length.

```javascript
var out = truncateCodePoints( 'beep boop', 7, '...' );
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ bench( pkg, function benchmark( b ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = truncate( values[ i%values.length ], 1, '...' );
out = truncate( values[ i%values.length ], 7, '...' );
if ( typeof out !== 'string' ) {
b.fail( 'should return a string' );
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{{alias}}( str, len, ending )
Truncate the code points of a provided string in order to return a string
having a specified length.
Truncate the Unicode code points of a provided string in order to return a
string having a specified length.

Parameters
----------
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
// TypeScript Version: 2.0

/**
* Truncate the code points of a provided string in order to return a string having a specified length.
* Truncate the Unicode code points of a provided string in order to return a string having a specified length.
*
* @param str - input string
* @param len - output string length (including ending)
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
'use strict';

/**
* Truncate the code points of a provided string in order to return a string having a specified length.
* Truncate the Unicode code points of a provided string in order to return a string having a specified length.
*
* @module @stdlib/string/base/truncate-code-points
*
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pk
// MAIN //

/**
* Truncates the code points of a provided string in order to return a string having a specified length.
* Truncates the Unicode code points of a provided string in order to return a string having a specified length.
*
* @param {string} str - input string
* @param {NonNegativeInteger} len - output string length (including ending)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@stdlib/string/base/truncate-code-points",
"version": "0.0.0",
"description": "Truncate the code points of a provided string in order to return a string having a specified length.",
"description": "Truncate the Unicode code points of a provided string in order to return a string having a specified length.",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",