Comments (2)
as noted in the readme of https://www.npmjs.com/package/buffer-factory, we can't just use Buffer.from
if we want to keep our tests green for pre-Node v4. So I think we should add buffer-factory
as a devDependency then change the tests to use them.
Locally, I have:
diff --git a/perf/common.js b/perf/common.js
index d08d6f5..00867bc 100644
--- a/perf/common.js
+++ b/perf/common.js
@@ -4,7 +4,7 @@ exports.createMsg = function(msgType, sz) {
var buf;
switch (msgType) {
case '--buffer':
- buf = new Buffer(sz);
+ buf = Buffer.alloc(sz);
buf.fill('o');
break;
case '--string':
diff --git a/test/send.js b/test/send.js
index c5993e8..2b1bcd9 100644
--- a/test/send.js
+++ b/test/send.js
@@ -54,7 +54,7 @@ test('send can take a buffer', function (t) {
var pub = nano.socket('pub');
var sub = nano.socket('sub');
var addr = 'inproc://some_address';
- var msg = new Buffer('hello');
+ var msg = Buffer.from('hello');
pub.bind(addr);
sub.connect(addr);
@@ -85,7 +85,7 @@ test('should not null terminate when sending strings', function (t) {
if (buf[buf.length - 1] === 0) {
t.fail();
}
- t.equal(buf.equals(new Buffer(msg)), true);
+ t.equal(buf.equals(Buffer.from(msg)), true);
t.equal(buf.length, msg.length);
pub.close();
sub.close();
diff --git a/test/transform.js b/test/transform.js
index 01fdbb4..c3e0acc 100644
--- a/test/transform.js
+++ b/test/transform.js
@@ -5,12 +5,12 @@ var nano = require('../');
var test = require('tape');
nano.Socket.prototype.transform = function (buf) {
- if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
- return Buffer.concat([new Buffer([0x00]), buf]);
+ if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
+ return Buffer.concat([Buffer.from([0x00]), buf]);
}
nano.Socket.prototype.restore = function (buf) {
- return Buffer.concat([new Buffer([0xFF]), buf]);
+ return Buffer.concat([Buffer.from([0xFF]), buf]);
}
test('inproc socket pub sub', function (t) {
but I think I would prefer the added dev dependency.
from node-nanomsg.
nvm, buffer-factory has a clear bug in it. prefer: https://www.npmjs.com/package/buffer-from
from node-nanomsg.
Related Issues (20)
- nn_send assert when IPv4only option was disabled, and try to connect with IPv4 address HOT 1
- add support for nng HOT 4
- Error handling HOT 3
- TypeError: Path must be a string. Received undefined HOT 2
- rfc links
- Compile error in Node V12.* HOT 6
- vulnerable dependencies HOT 1
- deprecation warning from Nan::Callback::call HOT 2
- remove package-lock.json from .gitignore HOT 2
- fallthrough warnings in nanomsg HOT 1
- are we handling scopes correctly? HOT 1
- How do i catch timeout on reqrep?
- Carsh When msg send 10K per second HOT 2
- Electron compatibility: "Loading non-context-aware native module in renderer" HOT 1
- node 14.15 compatability HOT 1
- (node:660) electron: The default of contextIsolation is deprecated and will be c hanging from false to true in a future release of Electron. HOT 2
- Double handle scope
- -Wcast-function-type in nodejs/src/node.h
- sub: filter by binary chan prefix? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-nanomsg.