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

@lumjs/tyst

v1.0.0

Published

A small set of functions for working with _typed strings_.

Readme

lum.tyst.js

A small set of functions for working with typed strings.

This is not a universal serialisation system, as it does not by default store any type information in the serialised strings. Instead it is based on a model where you know exactly what type a specific value should be.

I guess you could use this as the foundation for a more universal system, but it's designed more for being a simple wrapper around storage systems that only support strings, but where you may need to store values that cannot be directly encoded as JSON but which are simple enough to encode as a string.

Exports

getValueType(value, opts)

Get a type name and handler function (if applicable) for any JS value. The names are mostly just what typeof returns, but uses 'null' instead of calling null and object, and by default uses int and float instead of number for slightly more flexibility when dealing with numeric values.

parseFunction(str, opts)

Parses a string representation of a JS function into a Function. It supports a multitude of function string formats, including:

function name(arg1, arg2) { ... } // variable args, regular body
function(arg1, arg2) { ... }      // variable args, regular body
arg => statement                  // single arg, single statement
(arg1, arg2) => statement         // variable args, single statement
arg => { ... }                    // single arg, regular body
(arg1, arg2) => { ... }           // variable args, regular body

Function names are ignored, single-statement functions will by default have 'return ' prepended to the body, and all functions are generated using new Function(); see the actual documentation for more details.

parseTypedString(strval, defval, opts)

Given a string representing a JS value, and a default value (which isn't optional as it is used to determine what type of value to decode the string into), this uses getValueType() to get the type info, and will use parseFunction() if the type name is function (assuming that no custom function handler was set in the options that is).

Read the function docs for info on how it handles all the other types.

toTypedString(value, opts)

This uses getValueType(), and then will serialise the value into a format that parseTypedString() will be able to parse. If you use custom handlers when serialising, you'll obviously need to make sure you have corresponding handlers to pass to parseTypedString() as well.

Transcoder

A class that you can create an instance of, passing options that will be used as defaults for both encoding and decoding.

You can also make sub-classes with specially named methods that will be used to automatically generate custom handlers.

TODO

  • Tests

Official URLs

This library can be found in two places:

Author

Timothy Totten [email protected]

License

MIT