Gathering detailed insights and metrics for packet-reader
Gathering detailed insights and metrics for packet-reader
Gathering detailed insights and metrics for packet-reader
Gathering detailed insights and metrics for packet-reader
npm install packet-reader
100
Supply Chain
95.7
Quality
75.5
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
11 Stars
27 Commits
8 Forks
3 Watching
2 Branches
5 Contributors
Updated on 26 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-29.4%
356,581
Compared to previous day
Last week
-5.5%
2,474,314
Compared to previous week
Last month
2.8%
10,632,343
Compared to previous month
Last year
-11.4%
162,313,862
Compared to previous year
1
Handy little well tested module for reading length-prefixed binary packets.
Since buffers come off a socket in randomly sized chunks you can't expect them to cleanly break on packet boundaries. This module allows you to push buffers in and read full packets out the other side, so you can get to parsing right away and not have to manage concatenating partial buffers and searching through them for packets.
$ npm install packet-reader
1var Reader = require('packet-reader') 2 3var reader = new Reader() 4//assuming you have a socket emitting `data` events 5socket.on('data', function(buffer) { 6 reader.addChunk(buffer) 7 var packet = reader.read() 8 while(packet) { 9 //do something with fully parsed packet 10 } 11})
here's a more full featured example:
let's assume our "packet" for our protocol is 32-bit Big Endian length-prefixed strings
so a "hello world" packet would look something like [length, string]
[0, 0, 0 0x0B, h, e, l, l, o, w, o, r, l, d]
1var Transform = require('stream').Transform 2var Reader = require('packet-reader') 3var reader = new Reader() 4var parser = new Transform() 5parser._transform = function(chunk, encoding, cb) { 6 reader.addChunk(chunk) 7 var packet = reader.read() 8 while(packet) { 9 this.push(packet.toString('utf8')) 10 packet = reader.read() 11 } 12 cb() 13} 14 15var server = net.createServer(function(socket) { 16 socket.pipe(parser).pipe(stdout) 17}) 18
There are a few config options for setting optional pre-length padding byte. Read the tests for details.
MIT
Copyright 2015 Brian M. Carlson All rights reserved.
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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 4/17 approved changesets -- score normalized to 2
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
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
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 More