Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

string-kit

Package Overview
Dependencies
Maintainers
1
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-kit - npm Package Compare versions

Comparing version 0.14.3 to 0.15.0

82

lib/unicode.js

@@ -199,3 +199,3 @@ /*

// Check if a character is a full-width char or not.
// Check if a character is a full-width char or not
unicode.isFullWidth = char => unicode.isFullWidthCodePoint( char.codePointAt( 0 ) ) ;

@@ -210,6 +210,7 @@

Check if a codepoint represent a full-width char or not.
Borrowed from Node.js source, from readline.js.
*/
unicode.codePointWidth = code => {
// Assuming all emoji are wide here
if ( unicode.isEmojiCodePoint( code ) ) { return 2 ; }
// Code points are derived from:

@@ -219,29 +220,30 @@ // http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt

code <= 0x115f || // Hangul Jamo
0x2329 === code || // LEFT-POINTING ANGLE BRACKET
0x232a === code || // RIGHT-POINTING ANGLE BRACKET
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
( 0x2e80 <= code && code <= 0x3247 && code !== 0x303f ) ||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
0x3250 <= code && code <= 0x4dbf ||
// CJK Unified Ideographs .. Yi Radicals
0x4e00 <= code && code <= 0xa4c6 ||
// Hangul Jamo Extended-A
0xa960 <= code && code <= 0xa97c ||
// Hangul Syllables
0xac00 <= code && code <= 0xd7a3 ||
// CJK Compatibility Ideographs
0xf900 <= code && code <= 0xfaff ||
// Vertical Forms
0xfe10 <= code && code <= 0xfe19 ||
// CJK Compatibility Forms .. Small Form Variants
0xfe30 <= code && code <= 0xfe6b ||
// Halfwidth and Fullwidth Forms
0xff01 <= code && code <= 0xff60 ||
0xffe0 <= code && code <= 0xffe6 ||
// Kana Supplement
0x1b000 <= code && code <= 0x1b001 ||
// Enclosed Ideographic Supplement
0x1f200 <= code && code <= 0x1f251 ||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
0x20000 <= code && code <= 0x3fffd ) ) {
code === 0x2329 || // LEFT-POINTING ANGLE BRACKET
code === 0x232a || // RIGHT-POINTING ANGLE BRACKET
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
( 0x2e80 <= code && code <= 0x3247 && code !== 0x303f ) ||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
( 0x3250 <= code && code <= 0x4dbf ) ||
// CJK Unified Ideographs .. Yi Radicals
( 0x4e00 <= code && code <= 0xa4c6 ) ||
// Hangul Jamo Extended-A
( 0xa960 <= code && code <= 0xa97c ) ||
// Hangul Syllables
( 0xac00 <= code && code <= 0xd7a3 ) ||
// CJK Compatibility Ideographs
( 0xf900 <= code && code <= 0xfaff ) ||
// Vertical Forms
( 0xfe10 <= code && code <= 0xfe19 ) ||
// CJK Compatibility Forms .. Small Form Variants
( 0xfe30 <= code && code <= 0xfe6b ) ||
// Halfwidth and Fullwidth Forms
( 0xff01 <= code && code <= 0xff60 ) ||
( 0xffe0 <= code && code <= 0xffe6 ) ||
// Kana Supplement
( 0x1b000 <= code && code <= 0x1b001 ) ||
// Enclosed Ideographic Supplement
( 0x1f200 <= code && code <= 0x1f251 ) ||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
( 0x20000 <= code && code <= 0x3fffd )
) ) {
return 2 ;

@@ -266,1 +268,21 @@ }

// Check if a character is an emoji or not
unicode.isEmoji = char => unicode.isEmojiCodePoint( char.codePointAt( 0 ) ) ;
// Some doc found here: https://stackoverflow.com/questions/30470079/emoji-value-range
unicode.isEmojiCodePoint = code =>
// Miscellaneous symbols
( 0x2600 <= code && code <= 0x26ff ) ||
// Dingbats
( 0x2700 <= code && code <= 0x27bf ) ||
// Emoji
( 0x1f000 <= code && code <= 0x1f1ff ) ||
( 0x1f300 <= code && code <= 0x1f3fa ) ||
( 0x1f400 <= code && code <= 0x1faff ) ;
// Emoji modifier (Fitzpatrick): https://en.wikipedia.org/wiki/Miscellaneous_Symbols_and_Pictographs#Emoji_modifiers
unicode.isEmojiModifier = char => unicode.isEmojiModifierCodePoint( char.codePointAt( 0 ) ) ;
unicode.isEmojiModifierCodePoint = code => 0x1f3fb <= code && code <= 0x1f3ff ;
{
"name": "string-kit",
"version": "0.14.3",
"version": "0.15.0",
"engines": {

@@ -5,0 +5,0 @@ "node": ">=14.15.0"

@@ -171,2 +171,3 @@ /*

it( "unicode.isFullWidth() should return true if the char is full-width" , () => {
expect( string.unicode.isFullWidth( '…' ) ).to.be( false ) ;
expect( string.unicode.isFullWidth( 'a' ) ).to.be( false ) ;

@@ -178,2 +179,4 @@ expect( string.unicode.isFullWidth( 'aa' ) ).to.be( false ) ;

expect( string.unicode.isFullWidth( '䷆' ) ).to.be( false ) ;
expect( string.unicode.isFullWidth( '🔴' ) ).to.be( true ) ;
expect( string.unicode.isFullWidth( '😀' ) ).to.be( true ) ;

@@ -185,2 +188,12 @@ expect( string.unicode.isFullWidth( '@@' ) ).to.be( true ) ;

it( "unicode.isEmoji() should return true if the char is an emoji" , () => {
expect( string.unicode.isEmoji( 'a' ) ).to.be( false ) ;
expect( string.unicode.isEmoji( '@' ) ).to.be( false ) ;
expect( string.unicode.isEmoji( '𝌆' ) ).to.be( false ) ;
expect( string.unicode.isEmoji( '備' ) ).to.be( false ) ;
expect( string.unicode.isEmoji( '䷆' ) ).to.be( false ) ;
expect( string.unicode.isEmoji( '🔴' ) ).to.be( true ) ;
expect( string.unicode.isEmoji( '😀' ) ).to.be( true ) ;
} ) ;
it( ".toFullWidth() should transform a character to its full-width variant, if it exist" , () => {

@@ -187,0 +200,0 @@ expect( string.unicode.toFullWidth( '@' ) ).to.be( '@' ) ;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc