string_decoder
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -0,4 +1,28 @@ | ||
// Copyright Joyent, Inc. and other Node contributors. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a | ||
// copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to permit | ||
// persons to whom the Software is furnished to do so, subject to the | ||
// following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included | ||
// in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
// USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
'use strict'; | ||
/*<replacement>*/ | ||
var Buffer = require('safe-buffer').Buffer; | ||
/*</replacement>*/ | ||
@@ -115,6 +139,6 @@ var isEncoding = Buffer.isEncoding || function (encoding) { | ||
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a | ||
// continuation byte. | ||
// continuation byte. If an invalid byte is detected, -2 is returned. | ||
function utf8CheckByte(byte) { | ||
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; | ||
return -1; | ||
return byte >> 6 === 0x02 ? -1 : -2; | ||
} | ||
@@ -133,3 +157,3 @@ | ||
} | ||
if (--j < i) return 0; | ||
if (--j < i || nb === -2) return 0; | ||
nb = utf8CheckByte(buf[j]); | ||
@@ -140,3 +164,3 @@ if (nb >= 0) { | ||
} | ||
if (--j < i) return 0; | ||
if (--j < i || nb === -2) return 0; | ||
nb = utf8CheckByte(buf[j]); | ||
@@ -155,3 +179,3 @@ if (nb >= 0) { | ||
// one, we "replace" the validated continuation bytes we've seen so far with | ||
// UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding | ||
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding | ||
// behavior. The continuation byte check is included three times in the case | ||
@@ -164,3 +188,3 @@ // where all of the continuation bytes for a character exist in the same buffer. | ||
self.lastNeed = 0; | ||
return '\ufffd'.repeat(p); | ||
return '\ufffd'; | ||
} | ||
@@ -170,3 +194,3 @@ if (self.lastNeed > 1 && buf.length > 1) { | ||
self.lastNeed = 1; | ||
return '\ufffd'.repeat(p + 1); | ||
return '\ufffd'; | ||
} | ||
@@ -176,3 +200,3 @@ if (self.lastNeed > 2 && buf.length > 2) { | ||
self.lastNeed = 2; | ||
return '\ufffd'.repeat(p + 2); | ||
return '\ufffd'; | ||
} | ||
@@ -208,7 +232,7 @@ } | ||
// For UTF-8, a replacement character for each buffered byte of a (partial) | ||
// character needs to be added to the output. | ||
// For UTF-8, a replacement character is added when ending on a partial | ||
// character. | ||
function utf8End(buf) { | ||
var r = buf && buf.length ? this.write(buf) : ''; | ||
if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed); | ||
if (this.lastNeed) return r + '\ufffd'; | ||
return r; | ||
@@ -215,0 +239,0 @@ } |
{ | ||
"name": "string_decoder", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "The string_decoder module from Node core", | ||
@@ -11,6 +11,9 @@ "main": "lib/string_decoder.js", | ||
"babel-polyfill": "^6.23.0", | ||
"core-util-is": "^1.0.2", | ||
"inherits": "^2.0.3", | ||
"tap": "~0.4.8" | ||
}, | ||
"scripts": { | ||
"test": "tap test/parallel/*.js && node test/verify-dependencies" | ||
"test": "tap test/parallel/*.js && node test/verify-dependencies", | ||
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js" | ||
}, | ||
@@ -17,0 +20,0 @@ "repository": { |
# string_decoder | ||
***Node-core v7.0.0 string_decoder for userland*** | ||
***Node-core v8.9.4 string_decoder for userland*** | ||
@@ -14,7 +14,7 @@ | ||
***Node-core string_decoderstring_decoder for userland*** | ||
***Node-core string_decoder for userland*** | ||
This package is a mirror of the string_decoder implementation in Node-core. | ||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v7.8.0/docs/api/). | ||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.9.4/docs/api/). | ||
@@ -30,1 +30,20 @@ As of version 1.0.0 **string_decoder** uses semantic versioning. | ||
The *build/* directory contains a build script that will scrape the source from the [nodejs/node](https://github.com/nodejs/node) repo given a specific Node version. | ||
## Streams Working Group | ||
`string_decoder` is maintained by the Streams Working Group, which | ||
oversees the development and maintenance of the Streams API within | ||
Node.js. The responsibilities of the Streams Working Group include: | ||
* Addressing stream issues on the Node.js issue tracker. | ||
* Authoring and editing stream documentation within the Node.js project. | ||
* Reviewing changes to stream subclasses within the Node.js project. | ||
* Redirecting changes to streams from the Node.js project to this | ||
project. | ||
* Assisting in the implementation of stream providers within Node.js. | ||
* Recommending versions of `readable-stream` to be included in Node.js. | ||
* Messaging about the future of streams to give the community advance | ||
notice of changes. | ||
See [readable-stream](https://github.com/nodejs/readable-stream) for | ||
more details. |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
15296
272
48
0
4