New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

varsize-string

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

varsize-string - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

8

index.js

@@ -161,3 +161,3 @@ function preparePaddingSet (characterLookup, width, process, padding, override, fallback) {

if (start > this._size || start === end) {
if (start > this._size) {
return {

@@ -185,6 +185,8 @@ string: '',

} else {
while (sizes[to] <= end) {
while (sizes[to] < end) {
++to
}
to -= 1
if (sizes[to] !== end) {
to -= 1
}
}

@@ -191,0 +193,0 @@

{
"name": "varsize-string",
"version": "2.2.1",
"version": "2.2.2",
"description": "A package for working with strings where the different characters have different sizes.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,2 +6,3 @@ var test = require('tape')

var str = String.fromCharCode(chr)
if (chr === 0) return 0
return ('あいうえおかきくけこさしすせそはひふへほ…'.indexOf(str) !== -1) ? 2 : 1

@@ -108,2 +109,3 @@ }

t.equal(substring('abcd', 3, 4), 'd', 'character at the end')
t.equal(substring('abcd', 5, 6), '', 'empty string beyond end')
t.equal(substring('あいうえお', 0, 1), '', 'double width getting half a character')

@@ -118,2 +120,9 @@ t.equal(substring('あいうえお', 0, 2), 'あ', 'double width getting a double character')

t.equal(substring('abあ\ndef', 2, 7), 'あ\nde', 'multiline, double width characters')
t.equal(substring('\x00abcd', 0, 2), '\x00ab', 'getting zero-width character at start of line')
t.equal(substring('ab\x00cd', 0, 2), 'ab', 'ignore zero-width character at end')
t.equal(substring('ab\x00cd', 2, 4), '\x00cd', 'getting zero-width character in start')
t.equal(substring('abcd\x00', 2, 4), 'cd\x00', 'get zero-width character at end of line')
t.equal(substring('\x00abcd', 0, 0), '', 'get no zero-width characters from an empty slice')
t.equal(substring('abcd\x00', 4, 4), '\x00', 'get zero-width characters from an empty end slice')
t.equal(substring('\x00', 0, 0), '\x00', 'get zero-width character from empty line')
t.end()

@@ -185,2 +194,3 @@ })

t.equal(wrap(' abcdefg de\nfgh ijklmnop\nqr st uv', 5), 'abcde\nfg de\nfgh\nijklm\nnop\nqr st\nuv', 'various linebreak and space combinations')
t.equal(wrap('\x00', 4), '\x00', 'leave zero-width characters alone')
t.end()

@@ -187,0 +197,0 @@ })

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