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

bufrw

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufrw - npm Package Compare versions

Comparing version 0.9.19 to 0.9.20

2

package.json
{
"name": "bufrw",
"version": "0.9.19",
"version": "0.9.20",
"description": "Buffer Reading and Writing",

@@ -5,0 +5,0 @@ "keywords": [],

@@ -37,2 +37,7 @@ // Copyright (c) 2015 Uber Technologies, Inc.

self.encoding = encoding || 'utf8';
// istanbul ignore else
if (self.encoding === 'utf8') {
self.writeInto = self.writeUtf8Into;
self.readFrom = self.readUtf8From;
}
VariableBufferRW.call(self, sizerw);

@@ -55,2 +60,3 @@ }

// istanbul ignore next
StringRW.prototype.writeInto = function writeInto(str, buffer, offset) {

@@ -70,2 +76,22 @@ var self = this;

StringRW.prototype.writeUtf8Into = function writeInto(str, buffer, offset) {
var self = this;
var start = offset + self.sizerw.width;
var length = 0;
if (typeof str === 'string') {
// istanbul ignore else
if (buffer.parent) {
length = buffer.parent.utf8Write(str, buffer.offset + start, buffer.length - start);
} else {
length = buffer.write(str, start, self.encoding);
}
} else if (str !== null && str !== undefined) {
return WriteResult.error(errors.expected(str, 'string, null, or undefined'), offset);
}
var res = self.sizerw.writeInto(length, buffer, offset);
if (res.err) return res;
return new WriteResult(null, start + length);
};
// istanbul ignore next
StringRW.prototype.readFrom = function readFrom(buffer, offset) {

@@ -86,1 +112,22 @@ var self = this;

};
StringRW.prototype.readUtf8From = function readFrom(buffer, offset) {
var self = this;
var res = self.sizerw.readFrom(buffer, offset);
if (res.err) return res;
var length = res.value;
var remain = buffer.length - res.offset;
if (remain < length) {
return ReadResult.shortError(length, remain, offset, res.offset);
} else {
offset = res.offset;
var end = offset + length;
var str = '';
if (buffer.parent) {
str = buffer.parent.utf8Slice(buffer.offset + offset, buffer.offset + end);
} else {
str = buffer.toString(self.encoding, offset, end);
}
return new ReadResult(null, end, str);
}
};
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