diff --git a/lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/lib/main.js b/lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/lib/main.js index 5395038e6e4c..4f556eb4512f 100644 --- a/lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/lib/main.js +++ b/lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/lib/main.js @@ -63,6 +63,8 @@ var emojiProperty = grapheme.emojiProperty; * // returns -1 */ function prevGraphemeClusterBreak( str, fromIndex ) { + var regexEmojiMatching; + var regexEmoji; var breaks; var emoji; var ans; @@ -74,6 +76,17 @@ function prevGraphemeClusterBreak( str, fromIndex ) { if ( !isString( str ) ) { throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); } + + regexEmoji = /\p{Extended_Pictographic}/u; + regexEmojiMatching = str.match(regexEmoji); + if ( + regexEmoji.test(str) && + regexEmojiMatching && + regexEmojiMatching.length === 1 + ) { + str = regexEmojiMatching[0]; + } + len = str.length; if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { diff --git a/lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/test/test.js b/lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/test/test.js index e0811d476245..b4cdd800a3ca 100644 --- a/lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/test/test.js +++ b/lib/node_modules/@stdlib/string/prev-grapheme-cluster-break/test/test.js @@ -245,3 +245,12 @@ tape( 'the function returns -1 if provided an empty string', function test( t ) t.end(); }); + +tape( 'the function returns -1 if provided a skin tone emoji', function test( t ) { + var out; + + out = prevGraphemeClusterBreak( '👉🏿' ); + t.strictEqual( out, -1, 'returns expected value' ); + + t.end(); +});