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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gwigz/slua-json

v0.0.1

Published

TypeScript implementation of SLua's lljson.slencode/sldecode tagged JSON format

Downloads

74

Readme

@gwigz/slua-json

TypeScript implementation of SLua's lljson.slencode/sldecode tagged JSON format. Allows Node.js and browser code to exchange typed data (vectors, quaternions, UUIDs, buffers) with SLua scripts.

This is not for use with TSTL pipelines, use this for your projects that interact with SLua via HTTP, etc.

Install

npm install @gwigz/slua-json
# or
bun add @gwigz/slua-json

Usage

import { slencode, sldecode, Vector, Quaternion, UUID } from "@gwigz/slua-json"

// Decode tagged JSON from an SLua script
const data = sldecode<{ pos: Vector; rot: Quaternion }>('{"pos":"!v<1,2,3>","rot":"!q<0,0,0,1>"}')

data.pos.x // 1
data.rot.w // 1

// Encode data for an SLua script to consume via lljson.sldecode
const json = slencode({ pos: new Vector(1, 2, 3) })
// -> '{"pos":"!v<1,2,3>"}'

// Use tight mode for smaller payloads
slencode(new Vector(0, 0, 1), { tight: true })
// -> '"!v,,1"'

Tag format

| Tag | Type | Normal | Tight | | ---- | ----------- | ---------------------------- | --------------------------- | | !v | Vector | !v<x,y,z> | !vx,y,z (zeros omitted) | | !q | Quaternion | !q<x,y,z,w> | !qx,y,z,w (zeros omitted) | | !u | UUID | !uXXXX-XXXX-... (36 chars) | !u + base64 (22 chars) | | !d | Buffer | !d + base64 | same | | !f | Float | !f3.14 | same | | !b | Boolean | !b1 / !b0 | same | | !n | Nil | !n | same | | !! | Escaped ! | !!text | same |

JS ↔ Lua null mapping

| JavaScript | Lua | JSON wire | | ----------- | ------------- | --------- | | null | lljson.null | null | | undefined | nil | "!n" |

Second Life type classes

  • Vector(x, y, z) three-component vector
  • Quaternion(x, y, z, w) four-component quaternion
  • UUID(value) UUID wrapper (lowercased, needed for instanceof detection during encode)

Bring your own types

If you already have types for vectors, quaternions, or UUIDs (from another library or your own codebase), use createCodec to plug in your own constructors and detectors instead of converting between types:

import { createCodec } from "@gwigz/slua-json"
import { UUID, Vector3, Quaternion } from "@caspertech/node-metaverse"

const codec = createCodec({
  vector: {
    create: (x, y, z) => new Vector3(x, y, z),
    test: (vec) => vec instanceof Vector3,
  },
  quaternion: {
    create: (x, y, z, w) => new Quaternion(x, y, z, w),
    test: (quat) => quat instanceof Quaternion,
  },
  uuid: {
    create: (value) => new UUID(value),
    test: (uuid) => uuid instanceof UUID,
  },
})

// Decodes directly into node-metaverse types
const { pos } = codec.sldecode<{ pos: Vector3 }>('{"pos":"!v<1,2,3>"}')

// Encodes node-metaverse types without conversion
codec.slencode({ pos: new Vector3(1, 2, 3) })
// -> '{"pos":"!v<1,2,3>"}'

You can override any combination of vector, quaternion, and uuid. Unspecified types fall back to the built-in classes. createCodec() with no arguments behaves identically to the bare slencode/sldecode exports.

For UUID types where String(value) doesn't return the UUID string, provide a value function:

const codec = createCodec({
  uuid: {
    create: (value) => ({ __type: "uuid", id: value }),
    test: (uuid) => uuid?.__type === "uuid",
    value: (uuid) => uuid.id,
  },
})