Home
Pronounced neigh-lon.
A bidirectional communication protocol that can be used over raw sockets, WebSockets or any other method of transmission.
Its main use case is situations where you have a transport layer without any structure, e.g. TCP sockets where you stream arbitrary bytes. The role of nlon here is to provide a convenient layer on top of the transport to give shape to the data being transmitted.
This repository includes the protocol specification and a reference implementation in JavaScript.
Features
- ๐ฆ Almost no dependencies
- The core uses 3 dependencies: pino, nanoid, ndjson
- ๐ฉ Protocol-agnostic
- Works the same over TCP as WebSockets by using Adapters
- โก Simple specification
- The whole spec is a ~5 min read
- ๐ Express-inspired API for writing Servers
- Register (route) handlers to respond to incoming messages
- ๐จ Streaming supported by design
- Protocol permits transmitting data in multiple chunks
Adapters
- nlon-socket for TCP sockets
- nlon-websocket for the browser
Install
- pnpm:
pnpm add @elementbound/nlon
- npm:
npm i @elementbound/nlon
- yarn:
yarn add @elementbound/nlon
Usage
See the reference implementation.
Documentation
- Protocol specification
- Example flow
- API docs
- Or generate your own with JSDoc:
pnpm -r doc
- Or generate your own with JSDoc:
- Tutorials
- Examples
License
This package is under the MIT License.