Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jul 20, 2024
1 parent e623db1 commit 1da6369
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
44 changes: 40 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="release" id="unreleased">

## Unreleased (2024-07-13)
## Unreleased (2024-07-20)

<section class="packages">

Expand Down Expand Up @@ -698,6 +698,40 @@ This release closes the following issue:

<!-- /.package -->

<section class="package" id="string-truncate-unreleased">

#### [@stdlib/string/truncate](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/truncate)

<details>

<section class="bug-fixes">

##### Bug Fixes

- [`4345839`](https://github.com/stdlib-js/stdlib/commit/43458394fe65479fe3ae8edd7fe062e59c37ca27) - resolve bug in `string/truncate` [(#2635)](https://github.com/stdlib-js/stdlib/pull/2635)

</section>

<!-- /.bug-fixes -->

<section class="issues">

##### Closed Issues

This release closes the following issue:

[#2630](https://github.com/stdlib-js/stdlib/issues/2630)

</section>

<!-- /.issues -->

</details>

</section>

<!-- /.package -->

<section class="package" id="string-uncapitalize-unreleased">

#### [@stdlib/string/uncapitalize](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/uncapitalize)
Expand Down Expand Up @@ -828,9 +862,9 @@ This release closes the following issue:

### Closed Issues

A total of 5 issues were closed in this release:
A total of 6 issues were closed in this release:

[#1729](https://github.com/stdlib-js/stdlib/issues/1729), [##813](#813), [##814](#814), [##856 ](#856 ), [#812](https://github.com/stdlib-js/stdlib/issues/812)
[#1729](https://github.com/stdlib-js/stdlib/issues/1729), [#2630](https://github.com/stdlib-js/stdlib/issues/2630), [##813](#813), [##814](#814), [##856 ](#856 ), [#812](https://github.com/stdlib-js/stdlib/issues/812)

</section>

Expand All @@ -840,7 +874,7 @@ A total of 5 issues were closed in this release:

### Contributors

A total of 9 people contributed to this release. Thank you to the following contributors:
A total of 10 people contributed to this release. Thank you to the following contributors:

- Aditya Sapra
- Anudeep Sanapala
Expand All @@ -850,6 +884,7 @@ A total of 9 people contributed to this release. Thank you to the following cont
- Philipp Burckhardt
- Pranav
- Pratik
- Snehil Shah
- stdlib-bot

</section>
Expand All @@ -862,6 +897,7 @@ A total of 9 people contributed to this release. Thank you to the following cont

<details>

- [`4345839`](https://github.com/stdlib-js/stdlib/commit/43458394fe65479fe3ae8edd7fe062e59c37ca27) - **fix:** resolve bug in `string/truncate` [(#2635)](https://github.com/stdlib-js/stdlib/pull/2635) _(by Snehil Shah)_
- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - **feat:** improve type safety _(by Philipp Burckhardt)_
- [`659f752`](https://github.com/stdlib-js/stdlib/commit/659f752db18317bf5fc237fdbcad0d74b61e1ed9) - **style:** add missing spaces _(by Philipp Burckhardt)_
- [`a78f7d1`](https://github.com/stdlib-js/stdlib/commit/a78f7d1b859b6b1d7b0bc0ee4daf76789e3e0910) - **style:** add missing spaces _(by Philipp Burckhardt)_
Expand Down
4 changes: 2 additions & 2 deletions truncate/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ function truncate( str, len, ending ) {
ending = ending || '...';
endingLength = numGraphemeClusters( ending );
fromIndex = 0;
if ( len > numGraphemeClusters( str ) ) {
if ( len >= numGraphemeClusters( str ) ) {
return str;
}
if ( len - endingLength < 0 ) {
if ( len - endingLength <= 0 ) {
return ending.slice( 0, len );
}
nVisual = 0;
Expand Down
12 changes: 12 additions & 0 deletions truncate/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ tape( 'the function truncates a string to the specified length', function test(
actual = truncate( str, len );
t.strictEqual( actual, expected, 'returns expected value' );

str = 'beep boop';
len = 3;
expected = '...';
actual = truncate( str, len );
t.strictEqual( actual, expected, 'returns expected value' );

str = 'beep boop';
len = 9;
expected = 'beep boop';
actual = truncate( str, len );
t.strictEqual( actual, expected, 'returns expected value' );

str = '🐺 Wolf Brothers 🐺';
len = 6;
expected = '🐺 W...';
Expand Down

0 comments on commit 1da6369

Please sign in to comment.