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

boxtype

v1.0.1

Published

Boxtype is a library to box up values for safe use and transport. It's quick and easy to create and use type boxes. It keeps tricky fingers off your enclosed data. All you need is a little signet and a little desire to keep your values safe!

Downloads

1

Readme

Boxtype

The type-safe, (almost) thread-safe type boxing library

Boxtype is a library to box up values for safe use and transport. It's quick and easy to create and use type boxes. It keeps tricky fingers off your enclosed data. All you need is a little signet and a little desire to keep your values safe!

Installation

Just install it and you're ready to go!

npm i boxtype --save

Setup

To use boxtype you'll need signet, which comes as a dependency of boxtype. Just require the libraries, do a little setup and you're off to the races.

const signet = require('signet')();
const boxtype = require('boxtype')(signet);

Inspiration

This library was born out of a conversation between [https - //github.com/cmstead](Chris Stead) and [https - //github.com/jason-kerney](Jason Kerney) contemplating the idea of types and type safety, while looking at this code -

const cons = (a, b) => (x) => x ? a : b;
const car = list => list(true);
const cdr = list => list(false);

API

Boxtype comes with a small, but action-packed API which supports boxing with TypedValue, Maybe, Either and Just. Need something else? It's your world, build away!

  • typeWith - typeName:string => boxType
  • boxWith - boxTypeName:string => valueType:?composite<string, type> => value:* => boxType
  • either - type:composite<string, type>, defaultValue:* => * => Either<*>
  • just - value:* => Just<() => value:*>
  • maybe - type:composite<string, type> => value:* => Maybe<*>
  • none - () => None (None is actually the instance of 'none')
  • register - boxTypeName:string, baseType:[type] => boxTypeConstructor:function
  • some - value:* => unBoxed:*

All boxtype boxes -- except Either, Just, Maybe and None -- adhere to the following API:

  • Value box: transform:[variant<null, function>], unboxDepth:[int] => * -- (Performs recursive unboxing, stops when reaching optional depth)
  • toString - () => typeAndValue:string
  • valueOf - () => * -- (Performs recursive unboxing)