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.15.0 to 0.16.0

28

lib/unicode.js

@@ -70,3 +70,3 @@ /*

unicode.toCells = ( Cell , str , tabWidth = 4 , linePosition = 0 , ... extraCellArgs ) => {
var char , code , fillSize ,
var char , code , fillSize , width ,
output = [] ;

@@ -83,14 +83,16 @@

fillSize = tabWidth - ( linePosition % tabWidth ) - 1 ;
output.push( new Cell( '\t' , ... extraCellArgs ) ) ;
//output.push( new Cell( '\t' , ... extraCellArgs ) ) ;
output.push( new Cell( '\t' , 1 , ... extraCellArgs ) ) ;
linePosition += 1 + fillSize ;
while ( fillSize -- ) { output.push( new Cell( null , ... extraCellArgs ) ) ; }
// Add a filler cell
while ( fillSize -- ) { output.push( new Cell( ' ' , -2 , ... extraCellArgs ) ) ; }
}
else {
output.push( new Cell( char , ... extraCellArgs ) ) ;
linePosition ++ ;
width = unicode.codePointWidth( code ) ,
output.push( new Cell( char , width , ... extraCellArgs ) ) ;
linePosition += width ;
if ( unicode.codePointWidth( code ) === 2 ) {
output.push( new Cell( null , ... extraCellArgs ) ) ;
linePosition ++ ;
}
// Add an anti-filler cell (a cell with 0 width, following a wide char)
while ( -- width > 0 ) { output.push( new Cell( ' ' , -1 , ... extraCellArgs ) ) ; }
}

@@ -105,3 +107,9 @@ }

unicode.fromCells = ( cells ) => {
return cells.map( cell => cell.filler ? '' : cell.char ).join( '' ) ;
var cell , str = '' ;
for ( cell of cells ) {
if ( ! cell.filler ) { str += cell.char ; }
}
return str ;
} ;

@@ -108,0 +116,0 @@

{
"name": "string-kit",
"version": "0.15.0",
"version": "0.16.0",
"engines": {

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

@@ -43,5 +43,5 @@ /*

function Cell( char ) {
this.char = char || ' ' ;
this.filler = char === null ;
function Cell( char , special ) {
this.char = char ;
this.filler = special < 0 ;
}

@@ -135,4 +135,8 @@

expect( string.unicode.toCells( Cell , '🔴' ).map( cell => cell.filler ? null : cell.char ) ).to.be.like( [ '🔴' , null ] ) ;
expect( string.unicode.toCells( Cell , '🔴' ).map( cell => cell.char ) ).to.be.like( [ '🔴' , ' ' ] ) ;
// Tabs
expect( string.unicode.toCells( Cell , '\ta' ).map( cell => cell.filler ? null : cell.char ) ).to.be.like( [ '\t' , null , null , null , 'a' ] ) ;
expect( string.unicode.toCells( Cell , '\ta' ).map( cell => cell.char ) ).to.be.like( [ '\t' , ' ' , ' ' , ' ' , 'a' ] ) ;
expect( string.unicode.toCells( Cell , '\ta' ).map( cell => cell.filler ? null : cell.char ) ).to.be.like( [ '\t' , null , null , null , 'a' ] ) ;

@@ -155,2 +159,3 @@ expect( string.unicode.toCells( Cell , 'a\ta' ).map( cell => cell.filler ? null : cell.char ) ).to.be.like( [ 'a' , '\t' , null , null , 'a' ] ) ;

expect( string.unicode.fromCells( string.unicode.toCells( Cell , '備\ta' ) ) ).to.be( '備\ta' ) ;
expect( string.unicode.fromCells( string.unicode.toCells( Cell , '🔴' ) ) ).to.be( '🔴' ) ;
} ) ;

@@ -157,0 +162,0 @@

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