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

text-decoder

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

text-decoder - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

5

index.js

@@ -25,2 +25,7 @@ const PassThroughDecoder = require('./lib/pass-through-decoder')

// For Node.js compatibility
write (data) {
return this.push(data)
}
end (data) {

@@ -27,0 +32,0 @@ let result = ''

4

lib/pass-through-decoder.js

@@ -0,1 +1,3 @@

const b4a = require('b4a')
module.exports = class PassThroughDecoder {

@@ -7,3 +9,3 @@ constructor (encoding) {

decode (tail) {
return tail.toString(this.encoding)
return b4a.toString(tail, this.encoding)
}

@@ -10,0 +12,0 @@

@@ -0,1 +1,3 @@

const b4a = require('b4a')
/**

@@ -14,2 +16,13 @@ * https://encoding.spec.whatwg.org/#utf-8-decoder

decode (data) {
// If we have a fast path, just sniff if the last part is a boundary
if (this.bytesNeeded === 0) {
let isBoundary = true
for (let i = Math.max(0, data.byteLength - 4), n = data.byteLength; i < n && isBoundary; i++) {
isBoundary = data[i] <= 0x7f
}
if (isBoundary) return b4a.toString(data, 'utf8')
}
let result = ''

@@ -16,0 +29,0 @@

{
"name": "text-decoder",
"version": "1.0.1",
"version": "1.1.0",
"description": "Streaming text decoder that preserves multibyte Unicode characters",

@@ -23,2 +23,5 @@ "main": "index.js",

"homepage": "https://github.com/holepunchto/text-decoder#readme",
"dependencies": {
"b4a": "^1.6.4"
},
"devDependencies": {

@@ -25,0 +28,0 @@ "brittle": "^3.3.2",

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