npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tetherto/svc-facs-tcp

v1.0.1

Published

svc facility for tcp rpc client

Readme

svc-facs-tcp

This facility implements a promise based tcp client and a simple tcp rpc client with support of different encodings.

Config

This facility does not support config file and doesn't have any additional option beside default ones required by base facility.

API

fac.getClient

Initiates a tcp client instance for specific server.

Params:

  • host<string> - server host
  • port<int> - server port
  • encoding<string?> - optional, encoding, e.g. utf-8

Result:

  • TcpClient

Example:

const tcp = fac.getClient({
  host: '127.0.0.1',
  port: 7070,
  encoding: 'utf-8'
})

fac.getRPC

Initiates a RPC client instance for specific server.

Params:

  • tcp<TcpClient?> - tcp client instance, use either tcp or tcpOpts
  • tcpOpts<object> - new tcp client config
    • host<string> - server host
    • port<int> - server port
    • encoding<string?> - optional, encoding, e.g. utf-8
  • readStrategy<string?> - optional, response read strategy, default: TcpFacility.TCP_READ_STRATEGY.ON_DATA
  • json<boolean?> - optional, flag specifying that rpc requests/responses should be using json serialization, default: false
  • timeout<int?> - optional, rpc response timeout, default: 500ms
  • delay<int?>- optional, delay between two rpc requests, default: 50ms, useful when server closes connection on response

Result:

  • TcpRpcClient

Example:

const rpc1 = fac.getRPC({
  tcpOpts: {
    host: '127.0.0.1',
    port: 7070,
    encoding: 'utf-8'
  },
  readStrategy: TcpFacility.TCP_READ_STRATEGY.ON_DATA,
  json: true,
  timeout: 3000,
  delay: 50
})

// or with existing tcp client

const tcp2 = fac.getClient({
  host: '127.0.0.1',
  port: 7080,
  encoding: 'utf-8'
})
const rpc2 = fac.getRPC({
  tcp: tcp2,
  readStrategy: TcpFacility.TCP_READ_STRATEGY.ON_DATA,
  json: true,
  timeout: 3000,
  delay: 50
})

rpc.request

Performs a TCP request and waits for response.

Params:

  • payload<string|JSON|Buffer> - request payload

Result:

  • Promise<string|JSON|Buffer> - response from server

Example:

const rcp = fac.getRPC({ ... })
const res = await rpc.request({ ping: 1 })
console.log(res) // { pong: 2 }

tcp.write

Sends data to tcp server

Params:

  • data<string|Buffer> - data that will be sent to server

Reponse:

  • Promise<void>

Example:

const tcp = fac.getClient({ ... })
await tcp.write('{"ping":1}')

tcp.read

Waits and returns the data from the server

Params:

  • opts<Object>
    • strategy<int> - read strategy, 1 (TcpFacility.TCP_READ_STRATEGY.ON_DATA) - on('data') event, 2 (TcpFacility.TCP_READ_STRATEGY.ON_END) - on('end') event
    • timeout<int> - response timeout

Result:

  • Promise<string|Buffer>

Example:

const tcp = fac.getClient({ ... })
const res = await tcp.read({ strategy: TcpFacility.TCP_READ_STRATEGY.ON_DATA })
console.log(res) // '{"pong":2}'