Comments (5)
Well, it's 32 bytes. You may either #slice(offset, offset+32)
it or read it sequentially through calling #readUint8(offset++)
successively.
You might also want to take a look at the API docs.
from bytebuffer.js.
Sorry, I still don't get it. I currently need to write it. It's actually a string. Let us say
UINT8 data[16]
UINT8 data[16]
Could be
42 75 66 66 65 72 00 00 00 00 00 00 00 00 00 00 4d 61 74 74 65 72 00 00 00 00 00 00 00 00 00 00
If I try to
writeString('Buffer', 16) // suggestion
writeString('Matter', 16) // suggestion
from bytebuffer.js.
- Remember the current offset
- Write the string
- While 16 bytes are not reached, write 0
var s = "Buffer",
o = bb.offset;
bb.writeString(s);
while (bb.offset < o + 16)
bb.writeUint8(0);
...
from bytebuffer.js.
Would love to see this get supported with bytebuffer. Cheers, great as always.
from bytebuffer.js.
You may also extend the prototype with your use case specific code for comfort and a bit of speed:
mybytebuffer.js
var ByteBuffer = require("bytebuffer");
ByteBuffer.prototype.writeStringPadded = function(s, len) {
var end = this.offset + len;
this.ensureCapacity(end);
this.writeString(s);
while (this.offset < end)
this.writeUint8(0);
return this;
};
module.exports = ByteBuffer;
var ByteBuffer = require("mybytebuffer.js");
var bb = new ByteBuffer();
bb.writeStringPadded("Buffer", 16);
...
from bytebuffer.js.
Related Issues (20)
- Message.decode ignores `length` argument HOT 1
- bytebuffer.js in Android WebView throws TypeError HOT 4
- Could not resolve memcpy when trying to roll-up a bundle HOT 1
- Uncaught TypeError: buf.readUint64 is not a function HOT 2
- how to use for browser,where can i find a example code HOT 1
- why is happend
- ByteBuffer.js used from TypeScript HOT 2
- Passing Long.js to writeInt64 Fails with Type Error HOT 3
- toBuffer() docs wrong? HOT 3
- Support for ArrayBuffer/Buffer pooling
- Comparing two ByteBuffers i.e. equal method HOT 2
- npm run build - Error: ENOENT: no such file or directory, open 'bytebuffer.js/src/ByteBuffer.js' in meta program of 'bytebuffer.js/src/wrap-node.js':
- Prepend does not include the zero bytes
- hex_encode error HOT 2
- Add Support for Bigint
- Create ByteBuffer from existing ArrayBuffer? HOT 2
- Remove usages of deprecated Buffer() HOT 2
- Can we cut a new release, and update npmjs?
- Can't resolve 'memcpy' in '/vercel/xxxxx/node_modules/bytebuffer/dist' HOT 3
- Not released for a long time - so not available as a versioned package from npm
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 bytebuffer.js.