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

gnode-api

v0.2.18

Published

Node.js G-Earth extension API

Readme

G-Node

Node.js G-Earth extension API Requires Node.js V15.0.0+ Docs: https://wiredspast.github.io/G-Node/modules.html

How to install

Using npm:

$ npm install gnode-api

Using yarn:

$ yarn add gnode-api

How to run selfmade extension

$ node [filename] -p [port]

Example

$ node extension.js -p 9092

Example

import { Extension, HPacket, HDirection } from 'gnode-api';

// Use package.json as extensionInfo or create an object including 'name', 'description', 'version' and 'author'
import { readFile } from 'fs/promises';
const extensionInfo = JSON.parse(
    await readFile(
        new URL('./package.json', import.meta.url)
    )
);

// Create new extension with extensionInfo
let ext = new Extension(extensionInfo);

// Start connection to G-Earth
ext.run();

Listeners

Do on connection to G-Earth

ext.on('init', () => {
  console.log("Connected to G-Earth");
});

Do on connection to hotel

ext.on('start', () => {
  console.log("Connected to G-Earth");
});

Do on connection to hotel and get client info

ext.on('connect', (host, connectionPort, hotelVersion, clientIdentifier, clientType) => {
  // do something with client info
});

Do on connection to hotel ended

ext.on('end', () => {
  console.log("Connection to G-Earth ended");
});

Do on click on button in G-Earth Extensions tab

ext.on('click', () => {
  console.log("G-Earth button clicked");
});

Packet intercepting

Intercept all packets in one direction

ext.interceptAll(HDirection.TOCLIENT, hMessage => {
  let hPacket = hMessage.getPacket();
  ...
});

ext.interceptAll(HDirection.TOSERVER, hMessage => {
  let hPacket = hMessage.getPacket();
  ...
});

Intercept all packets with a certain header id in one direction

ext.interceptByHeaderId(HDirection.TOCLIENT, 969, hMessage => {
  let hPacket = hMessage.getPacket();
  ...
});

ext.interceptByHeaderId(HDirection.TOSERVER, 2443, hMessage => {
  let hPacket = hMessage.getPacket();
  ...
});

Intercept all packets by name or hash in one direction

ext.interceptByNameOrHash(HDirection.TOCLIENT, 'Ping', hMessage => {
  let hPacket = hMessage.getPacket();
  ...
});

ext.interceptByNameOrHash(HDirection.TOSERVER, 'Pong', hMessage => {
  let hPacket = hMessage.getPacket();
  ...
});

Reading a packet

Reading a var by var

let hPacket = hMessage.getPacket(); // Example: {in:Chat}{i:1}{s:"Hello"}{i:0}{i:1}{i:0}{i:0}
let userIndex = hPacket.readInteger();
let message = hPacket.readString();
hPacket.readInteger();
let bubble = hPacket.readInteger();

Reading a structure into an array

let hPacket = hMessage.getPacket(); // Example: {in:Chat}{i:1}{s:"Hello"}{i:0}{i:1}{i:0}{i:0}
let vars = hPacket.read('iSiiii');
let userIndex = vars[0];
let message = vars[1];
let bubble = vars[3];

Creating a packet

Creating packet from identifier (name or hash) and direction

let hPacket = new HPacket('Chat', HDirection.TOCLIENT); // Example: {in:Chat}
hPacket.appendInt(1);       // {in:Chat}{i:1}
hPacket.appendString('Hello');  // {in:Chat}{i:1}{s:"Hello"}
hPacket.appendInt(0);       // {in:Chat}{i:1}{s:"Hello"}{i:0}
hPacket.appendInt(1);       // {in:Chat}{i:1}{s:"Hello"}{i:0}{i:1}
hPacket.appendInt0);       // {in:Chat}{i:1}{s:"Hello"}{i:0}{i:1}{i:0}
hPacket.appendInt(0);       // {in:Chat}{i:1}{s:"Hello"}{i:0}{i:1}{i:0}{i:0}

Creating packet from header Id

let hPacket = new HPacket(1918) // Example: {l}{h:1918}
    .appendInt(1)       // {l}{h:1918}{i:1}
    .appendString('Hello')  // {l}{h:1918}{i:1}{s:"Hello"}
    .appendInt(0)       // {l}{h:1918}{i:1}{s:"Hello"}{i:0}
    .appendInt(1)       // {l}{h:1918}{i:1}{s:"Hello"}{i:0}{i:1}
    .appendInt(0)       // {l}{h:1918}{i:1}{s:"Hello"}{i:0}{i:1}{i:0}
    .appendInt(0);      // {l}{h:1918}{i:1}{s:"Hello"}{i:0}{i:1}{i:0}{i:0}

Creating packet from packet expression

let hPacket = new HPacket('{in:Chat}{i:1}{s:"Hello"}{i:0}{i:1}{i:0}{i:0}');

OR

let hPacket = new HPacket('{l}{h:1918}{i:1}{s:"Hello"}{i:0}{i:1}{i:0}{i:0}');

Sending a packet

Send packet to client

ext.sendToClient(hPacket);

Send packet to server

ext.sendToServer(hPacket);

More

For more examples and/or help read the wiki