Code Monkey home page Code Monkey logo

Comments (2)

feross avatar feross commented on August 20, 2024

Thanks for the bug report. I'll fix this as soon as I have a free moment.

On Tuesday, September 9, 2014, Brett Jackson [email protected]
wrote:

The following will work:

var number = "1003";

var nodeBuf = new Buffer(64);

// Succeeds
nodeBuf.writeUInt16LE(number, 0);
console.log("Written to buffer: " + nodeBuf.readUInt16LE(0));

The following will not:

var NEWBuffer = require('buffer/').Buffer;

var newBuffer = new NEWBuffer(64);

// Fails
newBuffer.writeUInt16LE(number, 0);

Node's internal buffer handles this case and parses the integer, but this
buffer implementation fails in Node and throws this error:

$ node bufferDebug.js

d:_\node_modules\buffer\index.js:1168
if (!test) throw new Error(message || 'Failed assertion')
^
Error: cannot write a non-number as a number
at assert (d:*
_
_\node_modules\buffer\index.js:1168:20)
at verifuint (d:*
_
_\node_modules\buffer\index.js:1148:3)
at writeUInt16 (d:*
_
_\node_modules\buffer\index.js:744:5)
at Uint8Array.Buffer.writeUInt16LE (d:*
_
**_\node_modules\buffer\index.js:760:10)
at Object. (d:*
_*****\server\utilities\bufferDebug.js:19:11
)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)


Reply to this email directly or view it on GitHub
#41.

Feross | blog http://feross.org/ | webtorrent http://webtorrent.io/ |
studynotes http://www.apstudynotes.org/

from buffer.

feross avatar feross commented on August 20, 2024

Fixed in 2.6.0.

from buffer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.