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

muworker-socket

v0.1.7

Published

Run mudb server in Web Worker

Downloads

1

Readme

muworker-socket

Web Worker made available to mudb. Suitable for creating games with a single-player mode by running the server in a separate thread to allow better user experience.

example

Both browserify and webworkify are required to run the example.

worker.js

const { createWorkerSocketServer } = require('muworker-socket/server')
const { MuServer } = require('mudb/server')

// source of worker should go into `module.exports`
module.exports = () => {
    const socketServer = createWorkerSocketServer()
    const muServer = new MuServer(socketServer)

    socketServer.listen()
    muServer.start(/* listeners */)
}

client.js

// `webworkify` enables workers to `require()`
const work = require('webworkify')
const { createWorkerSocket } = require('muworker-socket/socket')
const { MuClient } = require('mudb/client')

const serverWorker = work(require('./worker.js'))
const socket = createWorkerSocket({
    sessionId: Math.random().toString(36).substr(2),
    serverWorker: serverWorker,
})
const muClient = new MuClient(socket)

muClient.start(/* listeners */)

table of contents

1 install

npm i muworker-socket

2 api

2.1 interfaces

Purely instructive types used to describe the API:

  • SessionId: string

2.2 createWorkerSocketServer()

A factory returning a new instance of MuWorkerSocketServer.

2.3 createWorkerSocket(spec)

A factory returning a new instance of MuWorkerSocket.

  • spec:object
    • sessionId:SessionId: a unique session id used to identify a client
    • serverWorker:Worker: the worker in which the server is running

2.4 MuWorkerSocketServer

A MuWorkerSocketServer is a pseudo socket server that can be used to instantiate a MuServer.

2.4.1 listen()

Starts the socket server listening for connections.

2.5 MuWorkerSocket

A MuLocalSocket is a pseudo client-side socket that can be used to instantiate a MuClient.

credits

Copyright (c) 2018 He Diyi, Shenzhen Dianmao Technology Company Limited