Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

antena

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

antena

API to uniformely perform (a)synchronous http requests and websocket connections

  • 0.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

antena

Antena is an API to uniformely perform (a)synchronous http requests and websocket connections. The end points of an Antena communication channel are different: one is called receptor while the other is called emitter. To be operational, receptors must be attached to a node http server or a web worker. While emitters should receive information to connect to a receptor at their creation. Usage here, live demo here.

Handlers

handlers.onrequest(method, path, headers, body, callback)

  • handlers :: antena.Handlers
  • method :: string
  • path :: string
  • headers :: {string}
  • body :: string
  • callback(status, reason, headers, body)
    • status :: number
    • reason :: string
    • headers :: {string}
    • body :: string

handlers.onconnect(path, websocket)

  • handlers :: antena.Handlers
  • path :: string
  • websocket :: antena.Websocket

Receptor

antena.Receptor := antena.ReceptorServer | antena.ReceptorWorker

receptor = require("antena/receptor")(handlers)

  • handlers :: antena.Handlers
  • receptor :: antena.ReceptorServer

receptor = require("antena/receptor/worker")(handlers)

  • handlers :: antena.Handlers
  • receptor :: antena.ReceptorWorker

receptor2 = receptor1.merge(receptors)

  • receptor1 :: antena.Receptor
  • receptors :: {antena.Receptor}
  • receptor2 :: antena.Receptor

receptor2 = receptor1.trace(name)

  • receptor1 :: antena.Receptor
  • name :: string
  • receptor2 :: antena.Receptor

receptor.attach(server)

receptor :: antena.ReceptorServer server :: http.Server

worker = receptor.spawn(url)

  • receptor :: antena.ReceptorWorker
  • url :: string | object-url
  • worker :: EventTarget
    • terminate()
    • BrowserEvent error :: ErrorEvent
      • message :: string
      • filename :: string
      • lineno :: number
      • colno :: number

onrequest = receptor.handler("request")

  • receptor :: antena.ReceptorServer
  • onrequest(request, response)
    • request :: http.IncomingMessage
    • response :: http.ServerResponse

onupgrade = receptor.handler("upgrade")

  • receptor :: antena.ReceptorNode
  • onupgrade(request, socket, head)
    • request :: http.IncomingMessage
    • socket :: net.Socket
    • head :: Buffer

Emitter

emitter = require("antena/emitter/node")(host, secure)

  • host :: string
  • secure :: boolean
  • emitter :: antena.Emitter

emitter = require("antena/emitter/browser")(host, secure)

  • host :: string
  • secure :: boolean
  • emitter :: antena.Emitter

emitter = require("antena/emitter/worker")(size)

  • size :: number
  • emitter :: antena.Emitter

emitter = require("antena/emitter/mock")(receptor)

  • receptor :: antena.ReceptorNode | antena.ReceptorBrowser
  • emitter :: antena.Emitter

emitter.request(method, path, headers, body, callback)

  • emitter :: antena.Emitter
  • method :: string
  • path :: string
  • headers :: {string}
  • body :: string
  • callback(error, status, reason, headers, body)
    • error :: Error | null
    • status :: number | undefined
    • reason :: string | undefined
    • headers :: {string} | undefined
    • body :: string | undefined

[error2, status2, reason2, headers2, body2] = emitter.request(method1, path1, headers1, body1)

  • emitter :: antena.Emitter
  • method1 :: string
  • path1 :: string
  • headers1 :: {string}
  • body1 :: string
  • error2 :: Error | null
  • status2 :: number | undefined
  • reason2 :: string | undefined
  • headers2 :: {string} | undefined
  • body2 :: string | undefined

websocket = emitter.connect(path)

  • emitter :: antena.Emitter
  • path :: string
  • websocket :: antena.Websocket

emitter2 = emitter1.fork(splitter)

  • emitter1 :: antena.Emitter
  • splitter :: string
  • emitter2 :: antena.Emitter

emitters = emitter.split(splitters)

  • emitter :: antena.Emitter
  • splitter :: [string]
  • emitters :: {antena.Emitter}

emitter2 = emitter1.trace(name)

  • emitter1 :: antena.Emitter
  • name :: string
  • emitter2 :: antena.Emitter

Websocket

state = websocket.readyState

  • websocket :: antena.Websocket
  • state : number

Event: "open"

websocket.send(message)

  • websocket :: antena.Websocket
  • message :: string | ArrayBuffer

Event: "message"

  • message :: string | ArrayBuffer

websocket.close(code, reason)

  • websocket :: antena.Websocket
  • code(number)
  • reason(string)

Event: "close"

  • code :: number
  • reason :: string

Event: "error"

  • error :: Error

Keywords

FAQs

Package last updated on 09 Oct 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc