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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nzsc/clownkit

v0.6.1

Published

A microlibrary for interacting with an nzsc2p Cloud Firestore database.

Readme

clownkit

A microlibrary for interacting with an nzsc2p Cloud Firestore database.

Usage

npm install --save @nzsc/clownkit

# If you haven't already installed firebase, install it now:
npm install --save firebase
import { Clownkit } from '@nzsc/clownkit';

import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';

firebase.initializeApp(yourConfig);

const clownkit = new Clownkit(firebase);

// Do stuff with `clownkit`.
// See Docs for more.

Docs

Classes:

Clownkit

Instance methods (non-static):
listOpen()

Returns an array of open room names.

const namesOfRoomsICanJoin = await clownkit.listOpen();
listClosed()

Returns an array of closed room names.

const namesOfRoomsICannotJoin = await clownkit.listClosed();
cleanUp()

Completely destroys every game room that is older than an hour.

try {
  await clownkit.cleanUp();
} catch (e) {
  console.log('Something went wrong.');
}
join(roomName)

Attempts to join the given room.

If the room is full or nonexistent, it will throw an error with isExpected: true.

Example:

try {
  await clownkit.join('my_awesome_room');
  console.log('Joined!');
} catch (e) {
  if (e.isExpected) {
    console.log('Cannot join. The room is probably full or nonexistent.');
  } else {
    console.log('Something went wrong.');
  }
}
create(roomName)

Attempts to create the given room.

If the room already exists, it will throw an error with isExpected: true.

Example:

try {
  await clownkit.create('my_awesome_room');
  console.log('Created!');
} catch (e) {
  if (e.isExpected) {
    console.log('Cannot join. The room is probably full or nonexistent.');
  } else {
    console.log('Something went wrong.');
  }
}
waitForRoomToBeFull(roomName)

Returns a Promise that will resolve when the given room is full.

If you call this method when the room is already full, it will immediately resolve.

If the room does not exist, this method will have undefined behavior. Because of this, we strongly encourage only calling this method on rooms that you created (which are therefore certainly existent).

Example:

clownkit.waitForRoomToBeFull('my_awesome_room').then(() => {
  console.log('Your room is full! You\'re ready to start playing.');
});
onTurnEnd(roomName, callback: function(aPayload, bPayload))

Calls the given callback at the end of every turn.

If the room does not exist, this method will have undefined behavior. Because of this, we strongly encourage only calling this method on rooms that you created or joined (which are therefore certainly existent).

Example:

clownkit.onTurnEnd('my_awesome_room', (aPayload, bPayload) => {
  if (iAmPlayerA) {
    console.log('You chose ' + aPayload);
    console.log('Your opponent chose '+ bPayload);
  } else {
    console.log('You chose ' + bPayload);
    console.log('Your opponent chose '+ aPayload);
  }
});
acceptResults(roomName, aOrB)

Notifies the server you have successfully read the results.

The server will not accept deposits for the next turn until both players have called this method. Consequently, you must always call this method in the callback you provide to onTurnEnd so the server will permit the next turn to begin.

Example:

try {
  await clownkit.acceptResults('my_awesome_room', 'A');
} catch {
  console.log('Something went wrong.');
}
deposit(roomName, aOrB, payload)

Deposits the payload in the appropriate vault, and then seals the vault.

If you try to make a second deposit on the same turn, it will throw an error with isExpected: true.

Example:

try {
  await clownkit.deposit('my_awesome_room', 'B', 'ShadowFireball');
  console.log('Deposited!');
} catch (e) {
  if (e.isExpected) {
    console.log('You already deposited something this turn.');
  } else {
    console.log('Something went wrong.');
  }
}
destroy(roomName, aOrB)

Destroys the room to the best of its ability.

That is, if you are the last person in the game room, this will destroy both the guardian and your vault. If somebody else is still in the game room it will only destroy your vault, and then proceed to throw an error with isExpected: true.

Example:

try {
  await clownkit.destroy('my_awesome_room', 'A');
  console.log('Completely destroyed the game room.');
} catch (e) {
  if (e.isExpected) {
    console.log('Destroyed your vault, but not the guardian.');
  } else {
    console.log('Something went wrong.');
  }
}
login()

Logs in anonymously to Firebase (firebase.auth().signInAnonymously() under the hood).

Most backends will require authentication, so you will usually need to call this method before being able to call any of the other methods.

Example:

try {
  await clownkit.login();
  isLoggedIn = true;
} catch {
  console.log('Something went wrong.');
}

if (isLoggedIn) {
  await clownkit.create('im_logged_in_now_so_i_can_do_stuff_like_this');
  //...
}