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

marshal-ts

v1.0.1

Published

Tiny JavaScript marshalling library with zero dependencies. Marshalling is like serialization, but you get the object identity (typeof, instanceof, methods) back on the other end. Supports circular references too!

Downloads

11

Readme

marshal-ts

Tiny JavaScript marshalling library with zero dependencies. Marshalling is like serialization, but you get the object identity (typeof, instanceof, methods) back on the other end. Supports circular references too!

Install

npm install marshal-ts

Usage

Motivating Example

class Foo {
  constructor(public hello: string, private world: string) {}
  sayHello(): string {
    return this.hello + ' ' + this.world;
  }
}

const marshal = new Marshal({ prototypes: [Foo] });
const foo = new Foo('Hello', 'World');
const fooJson = marshal.marshal(foo);
// At this point, you can serialize fooJson with [JSON.stringify] and send it 
// over any kind of transport (write to a file, send over the internet, etc.)
const fooJsonSerialized = JSON.stringify(fooJson);
// ...
// ...and the receiving program can reconstruct it as long as it has the same
// codebase and marshal.
const fooJsonDecoded = JSON.parse(fooJsonSerialized);
const fooReconstructed = marshal.unmarshal(fooJsonDecoded) as Foo;

fooReconstructed.sayHello(); // 'Hello World'

The marshaller understands prototype inheritance:

class Bar extends Foo {
  sayHello(): string {
    return 'No greetings for you';
  }
}

const marshal = new Marshal({ prototypes: [Foo, Bar] });
const foo = new Foo('Hello', 'World');
const bar = new Bar('Hi', 'Earth');
let serializedFoo = JSON.stringify(marshal.marshal(foo));
let serializedBar = JSON.stringify(marshal.marshal(bar));
// ...
// NB: "as Foo" doesn't do anything here, it's just a TypeScript annotation
let reconstructedFoo = marshal.unmarshal(JSON.parse(serializedFoo)) as Foo;
reconstructedFoo.sayHello(); // 'Hello World'
reconstructedFoo instanceof Bar; // false
reconstructedFoo instanceof Foo; // true

let reconstructedBar = marshal.unmarshal(JSON.parse(serializedBar)) as Bar;
reconstructedBar.sayHello(); // 'Hi Earth'
reconstructedBar instanceof Bar; // true

API

TODO