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 🙏

© 2024 – Pkg Stats / Ryan Hefner

intersock

v0.0.6

Published

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

Downloads

3

Readme

InterSock

Table of Contents generated with DocToc

InterSock

facilitate communication and remote procedure calls (RPC) between browser and server

Elementary Exchanges (EXes)

  • In contrast to (classical) HTTP(S) (where each elementary conversation has to be initiated by the client), WebSocket communication is normally bidirectional (both client and server can send messages) but not conversational (there's no built-in mechanism to deal with request / response patterns). InterSock implements this capability to enable remote procedure calls (RPCs) with results.

  • An elementary conversation always consists of one 🠉request together with its corresponding 🠋response.

  • WebSocket communication is asynchronous, so any message may be sent from either side at any time; therefore, sending a request and then waiting for 'the' response is not possible as with HTTP(S) since the next message arriving from the other side could be the response to some other request from the client, or be an RP call, or a data transmission. To sort out the right piece of data from the stream of messages, IDs are used.

  • Each 🠉request must have a Message ID (MID) which is controlled at the discretion of the sender; each 🠋response by the receiving side must use the same property key as the 🠉request's MID with the same value in its payload so the request can be properly recognized by the 🠉request sender.

  • The ID schema allows for any number of 🠋responses for any 🠉request; this is useful e.g. for streaming an indeterminate number of data items in response to a single request. Foundational principles:

    • An elementary conversation has always exactly one 🠉request and one 🠋response. Even FYI and error messages will be recepted with an ACK message.

    • The 🠋response may indicate that it is the leader of a stream, i.e. an indeterminate number of follow-up messages that may or may not arrive in the future.

    • In case of streaming:

      • Follow-up messages to a streaming 🠋response should get their own name and / or type.

      • The sender of the original 🠉request may call streaming off by sending an appropriate message (format TBD; might be standardized, must contain MID; might be specialized property value of the 🠋response).

      • The sender of the streaming data may indicate end-of-stream (EOS) by sending an appropriate message (as above, format TBD).

    • Also possible to initiate 🠉request-streaming, that is, one side sends a message that tells the receiver to prepare for an indeterminate number of follow-ups.

RPC Message Format

  • exid: Elementary eXchange ID (text):

    • Has three fields:
      • a producer ID: c for the client (browser), s for the server,
      • a float representing a UNIX epoch-based UTC timestamp in milliseconds with zero-padded microsecond resolution (ex. 1693992062544.400), and
      • a three-digit, zero-left-padded, zero-based counter (which will be 000 or 001 in almost all realistic cases).
      • The two last fields are produced by webguy.time.stamp_and_count()
    • fields are separated by colons, ex. c:1693924247557.709:001
    • Advantage of this format is that even after restarting, EXIDs will continue to be sortable by time and will remain free of collisions. Since UTC is used rather than local time, EXIDs are not affected by time zone changes (daylight saving time, travel). It will even be possible to sort events from both participants (client and server) in a single table, either under the assumption that both had sufficiently synchronized clocks, or based on a measured delta between the two.

    When the client initiates a conversation, the client must set the CMID; when the server sends back a result or an ack, the server must use the same CMID under the same key, cmid; an SMID is not to be set in either message. Vice versa when the server starts a conversation: the server has to obtain a new SMID and set the smid property, and so forth.

  • type

    • Informational:

      🠉 'fyi': For Your Information; a package of expected or unsolicited data. No result is expected.

      🠋 'ack': Acknowledge. Sent by the receiver of an fyi message. The message is there so senders have something to await for before proceding; 'ack' tells the sender that the listener has seen and processed the data to the point where it is ready, e.g. to receive the next piece of data.

    • Call Method:

      🠉 'call': Call a method

      🠋 'result': Result of a call.

    • Error:

      🠉 'error': Error. Ex.: { cmid: 234, type: 'error', key: 'division-by-zero', value: { lnr: 24, ..., }, }

      🠋 An error message from either side should be acknowledged with an ack message. This is mainly so that behavior remains consistent with fyi (i.e. all messages will be acknowledged or replied to by either side).

  • key (text): The application-dependent key.

    • In case of type: 'error', the key should spell out the application-dependent type name of the error.
  • value (any): The application-dependent value.

    • In case of type: 'call', the value should spell out the arguments for the method call.

      (list, object, or null): Parameters. If prms is a list, it will be applied with the spread operator to the receiving method. If it is an object, it will be used as the only argument (i.e. as if it was the sole element in a list). If prms is missing or null, it will be treated as an empty list (i.e. the method will be called without arguments).

      In most cases, passing a single object with named keys should be preferred over sending a list of positional values. Specifically, when type is 'error', the value should have a property message that gives details about the error's cause.

    • In case of type: 'error', the optional value may contain additional details such as filename, linenumber, offending value, &c.

RPC API

  • send: () ->: Sends a message of type fyi, may await an ack.
  • call: () ->: Initiates a remote procedure call (RPC), may await the result.
  • err: () ->: Sends a message of type error, may await an ack.

To Do

  • [–] define format and resolution for UTC timestamp