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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tcomb-ats

v1.0.0

Published

Assert library for AtScript

Readme

An assert library for AtScript based on tcomb type combinators.

Setup

npm install tcomb-ats

Add the following keys to your traceur options:

{
  "types": true,
  "typeAssertions": true,
  "typeAssertionModule": "path/to/tcomb-ats",
  "annotations": true // if you also want annotations
}

Set "typeAssertions": false in production.

Demo

git clone https://github.com/gcanti/tcomb-ats.git
cd tcomb-ats
npm install
gulp

Open ./example/index.html in a browser.

Syntax

Primitives

var t = require('tcomb-ats');
var Str = t.Str;

// strings
var s: Str = 'a'; // ok
var s: Str = null; // throws (tcomb's primitives are not nullable)
var s: Str = 1; // throws

// numbers
var Num = t.Num;
var n: Num = 1; // ok

// booleans
var Bool = t.Bool;
var b: Bool = true; // ok

// you can use other irreducible types provided by tcomb
// or define your own, see tcomb documentation

Nullable types

Use the maybe<T> combinator:

var s: maybe<Str> = 'a'; // ok
var s: maybe<Str> = null; // ok

Functions

function sum(a: Num, b: Num): Num {
  return a + b;
}

sum(1, 2); // ok
sum(1, 'a'); // throws

Lists

Use the list<T> combinator:

var list = t.list;

var a: list<Str> = ['a']; // ok
var b: list<Str> = [1]; // throws

// you can also use the `Array<T>` syntax
var c: Array<Str> = ['a'];

Classes

class Person {
  constructor(name: Str, surname: Str) {
    this.name = name;
    this.surname = surname;
  }
}

var p1: Person = new Person('Giulio', 'Canti'); // ok
var p2: Person = new Person('Giulio'); // throws

Tuples

Use the tuple combinator:

var tuple = t.tuple;

var t: tuple<Str, Num> = [1, 'a']; // ok
var t: tuple<Str, Num> = [1, 2]; // throws

Dicts

Use the dict combinator:

var dict = t.dict;

var d: dict<Str, Num> = {a: 1}; // ok
var d: dict<Str, Num> = {a: 'b'}; // throws

Enums

Use the enums combinator:

var Align = t.enums.of('left center right');

var e: Align = 'left'; // ok
var e: Align = 'justify'; // throws

Subtypes

Use the subtype combinator:

var Positive = t.subtype(Num, function (n) {
  return n >= 0;
});

var n: Positive = 1; // ok
var n: Positive = -1; // throws
var n: Positive = 'a'; // throws

Unions

Use the union combinator:

var StrOrNum = t.union([Str, Num]);

var u: StrOrNum = 'a'; // ok
var u: StrOrNum = 1; // ok
var u: StrOrNum = true; // throws

tcomb's structs

var Person = t.struct({
  name: t.Str,
  surname: t.Str
});

var p: Person = new Person({
  name: 'Giulio',
  surname: 'Canti'}
); // ok
var p: Person = 1; // throws

License

The MIT License (MIT)