Input Buffer and Output Buffer, just like Java ByteBuffer
Installations
npm install byte
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>= 8.0.0
Node Version
8.4.0
NPM Version
5.5.1
Score
95
Supply Chain
99.1
Quality
81
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (94.53%)
Java (5.47%)
Developer
node-modules
Download Statistics
Total Downloads
10,054,303
Last Day
3,114
Last Week
20,413
Last Month
109,307
Last Year
1,377,182
GitHub Statistics
76 Stars
135 Commits
10 Forks
17 Watching
6 Branches
21 Contributors
Bundle Size
38.05 kB
Minified
11.91 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.0.0
Package Id
byte@2.0.0
Size
8.88 kB
NPM Version
5.5.1
Node Version
8.4.0
Publised On
16 May 2018
Total Downloads
Cumulative downloads
Total Downloads
10,054,303
Last day
-24.4%
3,114
Compared to previous day
Last week
-27.4%
20,413
Compared to previous week
Last month
0.6%
109,307
Compared to previous month
Last year
-40.5%
1,377,182
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
byte
Input Buffer and Output Buffer,
just like Java ByteBuffer
.
Install
1$ npm install byte --save
Usage
All methods just like Java ByteBuffer, you find them out here.
1var ByteBuffer = require('byte'); 2 3var bb = ByteBuffer.allocate(1024); 4bb.order(ByteBuffer.BIG_ENDIAN); // default is BIG_ENDIAN, you can change it to LITTLE_ENDIAN. 5bb.put(0); 6bb.put(new Buffer([0, 1, 2])); 7bb.put(new Buffer([255, 255, 255, 255]), 10, 3); 8bb.put(21, 100); 9 10bb.putChar('a'); 11bb.putChar(10, 'b'); 12 13bb.putInt(1024); 14bb.putInt(-100); 15 16bb.putFloat(100.9); 17 18bb.putLong(10000100009099); 19bb.putLong('1152921504606847000'); 20 21bb.putShort(65535); 22bb.putShort(-50000); 23 24bb.putDouble(99.99999); 25 26// wrap for read 27var rb = ByteBuffer.wrap(new Buffer(100)); 28rb.getInt(); 29rb.getLong(); 30rb.getChar(); 31rb.get(); 32rb.getDouble(); 33rb.getFloat();
Benchmark
1$ node benchmark/put.js 2 3node version: v0.11.12, date: Mon May 12 2014 18:25:35 GMT+0800 (CST) 4Starting... 520 tests completed. 6 7put() x 29,971,599 ops/sec ±4.10% (96 runs sampled) 8putChar("a") x 27,950,189 ops/sec ±6.22% (80 runs sampled) 9putChar(61) x 34,798,492 ops/sec ±5.08% (81 runs sampled) 10putShort() x 25,264,781 ops/sec ±2.90% (88 runs sampled) 11putInt() x 21,368,588 ops/sec ±6.07% (85 runs sampled) 12putFloat() x 12,324,148 ops/sec ±2.04% (93 runs sampled) 13putDouble() x 13,374,686 ops/sec ±1.41% (92 runs sampled) 14putLong(100000) x 17,754,878 ops/sec ±5.16% (86 runs sampled) 15putSmallSLong("10000") x 7,732,989 ops/sec ±2.07% (92 runs sampled) 16putBigNumLong(34359738368) x 3,580,231 ops/sec ±2.58% (93 runs sampled) 17putSafeStrLong("34359738368") x 2,443,560 ops/sec ±2.04% (97 runs sampled) 18putStrLong("9223372036854775808") x 760,908 ops/sec ±2.42% (92 runs sampled) 19ByteBuffer.allocate(100).putString(0, str) x 608,403 ops/sec ±11.46% (70 runs sampled) 20putString(0, str) x 1,362,412 ops/sec ±8.55% (85 runs sampled) 21bytes.putString(str) x 1,506,610 ops/sec ±2.31% (94 runs sampled) 22putString(0, buf) x 5,947,594 ops/sec ±4.16% (90 runs sampled) 23bytes.putString(buf) x 5,741,251 ops/sec ±1.69% (95 runs sampled) 24putRawString(0, str) x 2,908,161 ops/sec ±1.81% (95 runs sampled) 25bytes.putRawString(str) x 1,527,089 ops/sec ±4.98% (86 runs sampled) 26bytes.putRawString(str).array() x 1,009,026 ops/sec ±2.38% (91 runs sampled) 27 28$node benchmark/get.js 29 30node version: v0.11.12, date: Mon May 12 2014 19:14:26 GMT+0800 (CST) 31Starting... 3215 tests completed. 33 34get(0, 1) => copy Buffer x 2,059,464 ops/sec ±9.18% (69 runs sampled) 35get(0, 100) => copy Buffer x 2,124,455 ops/sec ±4.98% (75 runs sampled) 36get(0, 4096) => copy Buffer x 356,927 ops/sec ±9.43% (56 runs sampled) 37get() => byte x 15,477,897 ops/sec ±3.05% (89 runs sampled) 38getChar(0) x 52,541,591 ops/sec ±1.04% (95 runs sampled) 39getShort(0) x 26,297,086 ops/sec ±2.46% (89 runs sampled) 40getInt(0) x 18,772,003 ops/sec ±6.27% (71 runs sampled) 41getFloat(0) x 13,132,298 ops/sec ±1.68% (97 runs sampled) 42getDouble(0) x 10,968,594 ops/sec ±1.27% (94 runs sampled) 43getLong(0) x 11,849,374 ops/sec ±2.63% (96 runs sampled) 44getString(0) x 2,358,382 ops/sec ±5.78% (76 runs sampled) 45getCString(0) x 1,618,356 ops/sec ±8.41% (72 runs sampled) 46readRawString(4, 100) x 4,790,991 ops/sec ±9.25% (79 runs sampled) 47readRawString(100) x 5,434,663 ops/sec ±1.32% (95 runs sampled) 48getRawString(0, 100) x 5,497,325 ops/sec ±1.02% (98 runs sampled)
Number
methods
putShort / putInt16
putUInt16
putInt / putInt32
putUInt / putUInt32
putInt64
putFloat
putDouble
getShort / getInt16
getUInt16
getInt / getInt32
getUInt / getUInt32
getInt64
getFloat
getDouble
String
methods
Java String format: | length (4 bytes int) | string bytes |
C String format: | length + 1 (4 bytes int) | string bytes | \0 |
Row String format: string bytes
putString()
and putCString()
and putRawString()
1bb.putString('foo'); 2bb.putString(new Buffer('foo')); 3 4bb.putCString('foo'); 5bb.putCString(new Buffer('foo')); 6 7bb.putRawString('foo');
getString()
and getCString()
and getRawString(), readRawString()
1bb.getString(); 2bb.getString(10); 3 4bb.getCString(); 5bb.getCString(10); 6 7bb.getRawString(0, 10); 8bb.readRawString(10);
License
(The MIT License)
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.
Stable Version
Stable Version
2.0.0
MODERATE
1
0/10
Summary
Out-of-bounds Read in byte
Affected Versions
< 1.4.1
Patched Versions
1.4.1
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE.txt:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
Found 9/27 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 13 are checked with a SAST tool
Score
3.9
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to byte
array-buffer-byte-length
Get the byte length of an ArrayBuffer, even in engines without a `.byteLength` method.
typed-array-byte-offset
Robustly get the byte offset of a Typed Array
typed-array-byte-length
Robustly get the byte length of a Typed Array
bytes
Utility to parse a string bytes to bytes and vice-versa