Socket
Book a DemoInstallSign in
Socket

@elementbound/nlon

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elementbound/nlon

Reference implementation of the nlon protocol

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

nlon

This package is the reference implementation of the nlon protocol.

Install

  • pnpm: pnpm add @elementbound/nlon
  • npm: npm i @elementbound/nlon
  • yarn: yarn add @elementbound/nlon

Usage

For a more detailed explanation, see the nlon documentation

Server

import { createSocketServer } from '@elementbound/nlon-socket'

const nlonServer = createSocketServer({
  host: 'localhost',
  port: 63636
})

nlonServer.handle('greet', (peer, correspondence) => {
  correspondence.finish('Bye!')
})

Peer

import { Message, MessageHeader } from '@elementbound/nlon'
import { createSocketPeer } from '@elementbound/nlon-socket'

async function getGreeting () {
  const nlonPeer = createSocketPeer({
    host: 'localhost',
    port: 63636
  })

  const correspondence = nlonPeer.send(new Message({
    header: new MessageHeader({
      subject: 'greet'
    }),

    body: 'Hello!'
  }))

  const response = await correspondence.next()
  console.log('Received response:', response)

  correspondence.finish()
}

Documentation

  • API docs
    • Or generate your own with JSDoc: pnpm doc

License

This package is under the MIT License.

Keywords

nlon

FAQs

Package last updated on 01 May 2023

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