Input Buffer and Output Buffer,
just like Java ByteBuffer.
Install
$ npm install byte --save
Usage
All methods just like Java ByteBuffer,
you find them out here.
var ByteBuffer = require('byte');var bb = ByteBuffer.allocate(1024);bb.order(ByteBuffer.BIG_ENDIAN); // default is BIG_ENDIAN, you can change it to LITTLE_ENDIAN.bb.put(0);bb.put(new Buffer([0, 1, 2]));bb.put(new Buffer([255, 255, 255, 255]), 10, 3);bb.put(21, 100);bb.putChar
Benchmark
$ node benchmark/put.jsnode version: v0.11.12, date: Mon May 12 2014 18:25:35 GMT+0800 (CST)Starting...20 tests completed.put() x 29,971,599 ops/sec ±4.10% (96 runs sampled)putChar("a") x 27,950,189 ops/sec ±6.22% (80 runs sampled)putChar(61) x 34,798,492 ops/sec ±5.08% (81 runs sampled)putShort() x 25,264,781 ops/sec ±2.90% (88 runs sampled)putInt() x 21,368,588 ops/sec ±6.07% (85 runs sampled)putFloat() x 12,324,148 ops/sec ±2.04% (
Copyright (c) 2013 - 2014 fengmk2 <fengmk2@gmail.com> and other 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.