File tree Expand file tree Collapse file tree 1 file changed +1
-7
lines changed
lib/node_modules/@stdlib/string/first/lib Expand file tree Collapse file tree 1 file changed +1
-7
lines changed Original file line number Diff line number Diff line change @@ -66,16 +66,10 @@ function first( str, n ) {
6666 if ( ! isString ( str ) ) {
6767 throw new TypeError ( format ( 'invalid argument. First argument must be a string. Value: `%s`.' , str ) ) ;
6868 }
69- if ( str . length === 0 ) {
70- return '' ;
71- }
7269 if ( arguments . length > 1 ) {
7370 if ( ! isNonNegativeInteger ( n ) ) {
7471 throw new TypeError ( format ( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.' , n ) ) ;
7572 }
76- if ( str . length <= n ) {
77- return str ;
78- }
7973 nextBreak = 0 ;
8074 while ( n > 0 ) {
8175 nextBreak = nextGraphemeClusterBreak ( str , nextBreak ) ;
@@ -84,7 +78,7 @@ function first( str, n ) {
8478 } else {
8579 nextBreak = nextGraphemeClusterBreak ( str ) ;
8680 }
87- // If `nextBreak` equals -1, it means that `str` is a string with a single grapheme cluster. In that case, we return `str` itself:
81+ // Value of `nextBreak` will be -1 if and only if `str` is an empty string or `str` has only 1 extended grapheme cluster...
8882 if ( str === '' || nextBreak === - 1 ) {
8983 return str ;
9084 }
You can’t perform that action at this time.
0 commit comments