New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

spp

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spp

My Simple Protocol Parser For Node, Built For Speed.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

Simple Protocol Parser

Actually, this is ssdb's network protocol, and I think it can be used on other projects.

Build Status

Support Engines

  • nodejs (>=v0.10.30)
  • iojs (>=v1.0.4)

Protocol

Packet := Block+ '\n'
Block  := Size '\n' Data '\n'
Size   := literal_integer
Data   := string_bytes

For example:

3
set
3
key
3
val

Install

npm install spp

Usage

This package only provides parser, because packing is easy to do.

Parsing example:

var spp = require('spp'),
    parser = new spp.Parser();

parser.feed('2\nok\n\n');

var res;
while((res = parser.get()) !== undefined) {
  console.log(res); // ['ok']
}

API Ref

  • parser.feed(buffer/string)
  • parser.get()
  • parser.clear()

Benchmark

$ node bench.js
spp parser: 500000 in 4.127s => 121153 ops
nodejs parser: 500000 in 6.143s => 81393 ops

License

MIT (c) 2014, hit9 (Chao Wang).

FAQs

Package last updated on 05 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts