text-decoder
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -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 = '' |
@@ -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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16717
141
1
+ Addedb4a@^1.6.4
+ Addedb4a@1.6.7(transitive)