diff --git a/lib/node_modules/@stdlib/string/next-code-point-index/README.md b/lib/node_modules/@stdlib/string/next-code-point-index/README.md index 7de508d90598..970341192f4f 100644 --- a/lib/node_modules/@stdlib/string/next-code-point-index/README.md +++ b/lib/node_modules/@stdlib/string/next-code-point-index/README.md @@ -91,8 +91,8 @@ var out = nextCodePointIndex( 'last man standing', 4 ); out = nextCodePointIndex( 'presidential election', 8 ); // returns 9 -out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 1 ); -// returns 3 +out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 0 ); +// returns 2 out = nextCodePointIndex( '๐ŸŒท', 0 ); // returns -1 @@ -145,15 +145,15 @@ Options: ### Examples ```bash -$ next-code-point-index --from=1 ๐’ป๐“Ÿ๐’ป๐“Ÿ -3 +$ next-code-point-index --from=0 ๐’ป๐“Ÿ๐’ป๐“Ÿ +2 ``` To use as a [standard stream][standard-streams], ```bash -$ echo -n '๐’ป๐“Ÿ๐’ป๐“Ÿ' | next-code-point-index --from=1 -3 +$ echo -n '๐’ป๐“Ÿ๐’ป๐“Ÿ' | next-code-point-index --from=0 +2 ``` diff --git a/lib/node_modules/@stdlib/string/next-code-point-index/docs/repl.txt b/lib/node_modules/@stdlib/string/next-code-point-index/docs/repl.txt index de9089c2c045..15203eb6068a 100644 --- a/lib/node_modules/@stdlib/string/next-code-point-index/docs/repl.txt +++ b/lib/node_modules/@stdlib/string/next-code-point-index/docs/repl.txt @@ -22,8 +22,8 @@ 5 > out = {{alias}}( 'presidential election', 8 ) 9 - > out = {{alias}}( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 1 ) - 3 + > out = {{alias}}( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 0 ) + 2 > out = {{alias}}( '๐ŸŒท' ) -1 diff --git a/lib/node_modules/@stdlib/string/next-code-point-index/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/next-code-point-index/docs/types/index.d.ts index 4507b77c900d..986bcf2539d0 100644 --- a/lib/node_modules/@stdlib/string/next-code-point-index/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/string/next-code-point-index/docs/types/index.d.ts @@ -28,8 +28,8 @@ * @returns next code point position * * @example -* var out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 1 ); -* // returns 3 +* var out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 0 ); +* // returns 2 * * out = nextCodePointIndex( '๐ŸŒท' ); * // returns -1 diff --git a/lib/node_modules/@stdlib/string/next-code-point-index/examples/index.js b/lib/node_modules/@stdlib/string/next-code-point-index/examples/index.js index bd5f7d7361da..a034f6f7b746 100644 --- a/lib/node_modules/@stdlib/string/next-code-point-index/examples/index.js +++ b/lib/node_modules/@stdlib/string/next-code-point-index/examples/index.js @@ -26,8 +26,8 @@ console.log( nextCodePointIndex( 'last man standing', 4 ) ); console.log( nextCodePointIndex( 'presidential election', 8 ) ); // => 9 -console.log( nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 1 ) ); -// => 3 +console.log( nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 0 ) ); +// => 2 console.log( nextCodePointIndex( '๐ŸŒท', 0 ) ); // => -1 diff --git a/lib/node_modules/@stdlib/string/next-code-point-index/lib/index.js b/lib/node_modules/@stdlib/string/next-code-point-index/lib/index.js index b45fabdf28cc..716736f8ac9c 100644 --- a/lib/node_modules/@stdlib/string/next-code-point-index/lib/index.js +++ b/lib/node_modules/@stdlib/string/next-code-point-index/lib/index.js @@ -26,8 +26,8 @@ * @example * var nextCodePointIndex = require( '@stdlib/string/next-code-point-index' ); * -* var out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 1 ); -* // returns 3 +* var out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 0 ); +* // returns 2 * * out = nextCodePointIndex( '๐ŸŒท', 0 ); * // returns -1 diff --git a/lib/node_modules/@stdlib/string/next-code-point-index/lib/main.js b/lib/node_modules/@stdlib/string/next-code-point-index/lib/main.js index 8e4d80d7896c..d0ffffc10860 100644 --- a/lib/node_modules/@stdlib/string/next-code-point-index/lib/main.js +++ b/lib/node_modules/@stdlib/string/next-code-point-index/lib/main.js @@ -40,7 +40,7 @@ var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pk * @param {integer} [fromIndex=0] - position * @throws {TypeError} first argument must be a string * @throws {TypeError} second argument must be an integer -* @returns {Integer} position of the next Unicode code point +* @returns {integer} position of the next Unicode code point * * @example * var out = nextCodePointIndex( 'last man standing', 4 ); @@ -51,8 +51,8 @@ var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pk * // returns 9 * * @example -* var out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 1 ); -* // returns 3 +* var out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 0 ); +* // returns 2 * * @example * var out = nextCodePointIndex( '๐ŸŒท' ); @@ -95,7 +95,7 @@ function nextCodePointIndex( str, fromIndex ) { // Check whether the high surrogate is paired with a low surrogate... if ( RE_UTF16_LOW_SURROGATE.test( str[ i ] ) ) { // We found a surrogate pair: - return ( j === lastIndex ) ? -1 : j; + return ( j >= lastIndex ) ? -1 : j; } return i; } diff --git a/lib/node_modules/@stdlib/string/next-code-point-index/test/test.js b/lib/node_modules/@stdlib/string/next-code-point-index/test/test.js index 129885905b1f..7a95ca27c23a 100644 --- a/lib/node_modules/@stdlib/string/next-code-point-index/test/test.js +++ b/lib/node_modules/@stdlib/string/next-code-point-index/test/test.js @@ -151,8 +151,8 @@ tape( 'the function supports providing an index from which to begin searching', out = nextCodePointIndex( 'เค…เคจเฅเคšเฅเค›เฅ‡เคฆ', 1 ); t.strictEqual( out, 2, 'returns expected value' ); - out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 1 ); - t.strictEqual( out, 3, 'returns expected value' ); + out = nextCodePointIndex( '๐’ป๐“Ÿ๐’ป๐“Ÿ', 0 ); + t.strictEqual( out, 2, 'returns expected value' ); out = nextCodePointIndex( 'a\uDBFFaaaaaaa', 0 ); // unpaired high surrogate t.strictEqual( out, 1, 'returns expected value' );