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

@jaydeebee/lite3-native-addon

v0.3.0

Published

Node.js bindings for lite3 (TRON) zero-copy serialization library

Readme

@jaydeebee/lite3-native-addon

Node.js native addon bindings for lite3, a zero-copy binary serialization library.

Disclaimer

This project is:

  • Unofficial - Built independently of the lite3 project, with no affiliation to the original authors
  • A learning exercise - Created primarily to explore Node.js native addon development
  • Not production-ready - Use at your own risk
  • Potentially inefficient - The JavaScript/N-API bridge may negate some of the performance benefits that lite3 offers in native contexts

Installation

npm install @jaydeebee/lite3-native-addon

Prebuilt binaries are available for:

  • Linux x64
  • Linux arm64
  • macOS arm64

Other platforms will fall back to source compilation (requires a C compiler and Python).

Usage

Basic Encode/Decode

import { encode, decode, version } from '@jaydeebee/lite3-native-addon';

// Encode an object to a binary buffer
const buffer = encode({ hello: 'world', count: 42 });

// Decode back to JavaScript
const obj = decode(buffer);

console.log(obj); // { hello: 'world', count: 42 }
console.log(version()); // Addon version

Lazy Proxy Access (Lite3Buffer)

For better performance with large objects where you only need a few fields, use Lite3Buffer.from() to create a lazy proxy that decodes values on-demand:

import { Lite3Buffer } from '@jaydeebee/lite3-native-addon';

// Create from an object (type is inferred)
const proxy = Lite3Buffer.from({
  users: [
    { name: 'Alice', age: 30 },
    { name: 'Bob', age: 25 }
  ],
  metadata: { count: 2 }
});

// Access properties naturally - decoded lazily
console.log(proxy.users[0].name);  // 'Alice' - only this field is decoded
console.log(proxy.metadata.count); // 2

// Array methods work as expected
const names = proxy.users.map(u => u.name);  // ['Alice', 'Bob']
const adults = proxy.users.filter(u => u.age >= 18);

// Works with JSON.stringify, spreading, for...of, etc.
console.log(JSON.stringify(proxy));
const copy = { ...proxy };
for (const user of proxy.users) {
  console.log(user.name);
}

Type Safety

When creating a proxy from a buffer, the return type defaults to unknown for safety (like JSON.parse). Provide a type parameter when you trust the data source:

interface User {
  name: string;
  age: number;
}

// From buffer - returns unknown by default (safe)
const data = Lite3Buffer.from(buffer);
data.name;  // TS error: 'unknown' has no property 'name'

// With type parameter - returns User (trusted)
const user = Lite3Buffer.from<User>(buffer);
user.name;  // OK - full autocomplete and type checking

// For untrusted sources, consider runtime validation:
import { z } from 'zod';
const UserSchema = z.object({ name: z.string(), age: z.number() });
const validated = UserSchema.parse(Lite3Buffer.from(buffer));

Utility Functions

import { Lite3Buffer, $buffer, $decode } from '@jaydeebee/lite3-native-addon';

// Check if a value is a Lite3Buffer proxy
Lite3Buffer.isLite3Buffer(proxy);  // true
Lite3Buffer.isLite3Buffer({});     // false

// Get the underlying buffer
const buffer = Lite3Buffer.getBuffer(proxy);

// Force full decode (escape hatch)
const pojo = proxy[$decode]();

// Access raw buffer via symbol (alternative)
const rawBuffer = proxy[$buffer];

Why Use Lite3Buffer?

| Scenario | decode() | Lite3Buffer.from() | |----------|-----------|---------------------| | Access all fields | Good | Similar | | Access few fields from large object | Wasteful | Efficient | | Repeated access to same field | Faster | Slightly slower (cached after first access) | | Pass-through / routing | Decode + re-encode | Keep as buffer |

Supported Types

  • Strings
  • Numbers (stored as f64)
  • Booleans
  • Null
  • Arrays
  • Objects

Unsupported types (functions, undefined, symbols) are silently skipped during encoding.

Dependencies

This addon uses a forked version of the lite3 library as a git submodule. I hope to resolve this and use the canonical version from fastserial/lite3 in the future.

License

MIT

Contributing

Contributions are welcome.

  • Open a pull request for bug fixes and minor improvements
  • Use Angular commit message conventions (e.g., feat:, fix:, docs:)
  • For significant or invasive changes, please open an issue first to discuss the approach