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

clearthru

v0.6.0

Published

clearthru

Downloads

10

Readme

ClearThru

This is a communication library that provides remote procedure calls (RPC) and events over websocket.

Features:

  • Use Promises
  • Wrap Js Classes (extends clearthru.API) server-side and expose its methods that will be callable from the client.
  • Server Methods can instantiate new clearthru.API Objects that could be returned to the client. This allows scoped APIs in an Object-Oriented pattern.
  • Scalable. Server could be shutted off and the client would keep its state and try to resume connection. On a successful connection, even with a new server instance, the client objects APIs will restore their context and resume normal operation.

Documentation

Server

//require the server
var clearthru = require('clearthru').server

//Define an API
class MyAPI extends clearthru.API {
  method2() {
  }
}
// This register an object
clearthru.register(MyAPI)

class Boot extends clearthru.API {
  method1() {
    return this.create("MyAPI")
  }
}
// This register the bootstrap object 
clearthru.bootstrap(Boot)

...

//Create a http server
var server = http.createServer(app)
//Attach clearthru to the server
clearthru.attach(server, SECRETKEY)

Client

// Require the client
var client = require('clearthru').client

// Connect to the server
var boot = await client.init('ws://localhost:3082')
// boot is now mapped to an instance of Boot on the server

// Call a method as a Promise
var api = await boot.method1()
// In this example, api will map to an instance of MyAPI on the server

await api.method2()

Connect/Express middleware

// Server
var connect = require('connect')
var app = connect()
var clearthru = require("clearthru")
// Allow the browser to download the client script. URL: /clearthru-client
app.use(clearthru.browserClient())
<!--This will provide the 'require()' function-->
<script src="/clearthru-client"></script>
<script>

var client = require('clearthru').client

//...

</script>

Example

Look in the example folder. First, run npm install in the root folder and in example folder.

cd example
node svr.js # This will start a server demo
# Either you browse http://localhost:3082 or you run:
node cli.js # a client demo