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 🙏

© 2024 – Pkg Stats / Ryan Hefner

crabrave

v1.0.0

Published

near-zero-cost abstractions ported from Rust to TypeScript

Downloads

5

Readme

crabrave

near-zero-cost abstractions ported from Rust to TypeScript

features:

  • very simple API that closely follows Rust's
  • rust style enums with packed data
  • Option<T> and Result<T> types
  • match(), and unwrap()
  • about as performant as doing the comparisons by hand
  • very lightweight, you won't notice it's even there in prod
  • works in all environments (browser, node, bun, deno)
  • (soon) helpers to wrap existing functions
  • (soon) wrappers over built-in web APIs and external libraries (a very simple and incomplete fetch wrapper is already included)

Check /examples and /test for code examples.

To install development dependencies:

bun install

To run:

bun run index.ts

To test:

bun test

questions you might have

  1. why is everything arrow functions?
    • smaller bundle size.
  2. more fluent api? :pleading_face:
    • sorry, fluent APIs are not tree-shakable, and I can't add them until they are otherwise the bundle size will explode :( (ideally there would just be a macro system and then this whole thing becomes a zero-cost abstraction instead of an almost-zero-cost one)
  3. but the bundle size is already so small! your competiton is an order of magnitude bigger!
    • I guess.
  4. ~~why are there errors all over the code?~~
    • ~~because we're lying to typescript and it's not a very big fan of our dishonesty.~~
    • I managed to shut typescript up somehow
  5. what is the performance impact?
    • not too bad probably since it's just one extra function call. if macros were a thing you could make it zero-cost, I'll try to experiment with that in the future probably with bun or vite.
  6. ok but like, benchmark it.
    • there are too many factors to even consider doing this. (did you know that v8 uses four compilers? or that other engines exist?)
  7. this is disgusting
    • that's not a question but yes it is

This project was created using bun init in bun v1.0.7. Bun is a fast all-in-one JavaScript runtime.