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

@allnulled/typed-as

v0.0.2

Published

Library to automate validations

Readme

typed-as

Library to automate validations.

Install

$ npm i -s @allnulled/typed-as

Usage

const { checkTypes, TypedConstructor } = require("@allnulled/typed-as");

checkTypes({
    name: "John",
    surname: "Smith" 
}, "name:string;surname:string"); // true
checkTypes({
    name: "Alice",
    surname: "Smith" 
}, "name:string;surname:number"); // false
checkTypes({
    name: undefined,
    age: 64
}, `
    name : string | undefined ;
    age : gt( 18 ) ;
`); // true

The TypedConstructor class is useful for easily implement typage in classes creation:

class MyTypedClass extends TypedConstructor {

    static get ConstructorTypes() {
        return `name:string|undefined;age:number&gt(18)`;
    }

    onConstructor(options = {}) {
        Object.assign(this, options);
    }

}

Validators

This library uses the "is" npm module under the hood, and all its validations are available.

The syntax to use the validators, in typed-as, results to something like this:

The following list represents all the available validators in [email protected] and @allnulled/[email protected]:

  • General:

    • is.a (value, type) or is.type (value, type)
    • is.defined (value)
    • is.empty (value)
    • is.equal (value, other)
    • is.hosted (value, host)
    • is.instance (value, constructor)
    • is.instanceof (value, constructor) // DEPRECATED
    • is.nil (value)
    • is.null (value) // DEPRECATED
    • is.undef (value)
    • is.undefined (value) // DEPRECATED
  • Arguments:

    • is.args (value)
    • is.arguments (value) // DEPRECATED
    • is.args.empty (value)
  • Array:

    • is.array (value)
    • is.array.empty (value)
    • is.arraylike (value)
  • Boolean:

    • is.bool (value)
    • is.boolean (value) // DEPRECATED
    • is.false (value) // DEPRECATED
    • is.true (value) // DEPRECATED
  • Date:

    • is.date (value)
  • Element:

    • is.element (value)
  • Error:

    • is.error (value)
  • Function:

    • is.fn (value)
    • is.function (value) // DEPRECATED
  • Number:

    • is.number (value)
    • is.infinite (value)
    • is.decimal (value)
    • is.divisibleBy (value, n)
    • is.integer (value)
    • is.int (value) // DEPRECATED
    • is.maximum (value, others)
    • is.minimum (value, others)
    • is.nan (value)
    • is.even (value)
    • is.odd (value)
    • is.ge (value, other)
    • is.gt (value, other)
    • is.le (value, other)
    • is.lt (value, other)
    • is.within (value, start, finish)
  • Object:

    • is.object (value)
  • Regexp:

    • is.regexp (value)
  • String:

    • is.string (value)
  • Encoded binary:

    • is.base64 (value)
    • is.hex (value)
  • Symbols:

    • is.symbol (value)
  • BigInt:

    • is.bigint (value)

To extend this list, just extend the require("is") in order to add new validators.

Syntax

This library uses simple string splits in this order:

  • ; to separate properties
  • : to separate property rules (left: property; right: validator)
  • . to separate property concatenations (for the previous left-side only)
  • & to separate property validations (for the previous right-side only)
  • | to separate property validation alternatives (for all the groups made by &)
  • ! to negate a property validation

This could be a common example:

id:!undefined;
name:string;
direction:string;
age:number&gt(18);
form.comments:string|undefined;
form.details:string|undefined;

This expression represents how the data is structured and read, and it is a valid expression (if there were such validators and accessible parameters):

property.property1:
        validator1A(arg1, arg2)
            |
        validator1B
    &
        validator2A(arg1, arg2)
            |
        validator2B
    &
        validator3A(arg1, arg2)
            |
        validator3B
;
property.property2:
        validator1A(arg1, arg2)
            |
        validator1B
    &
        validator2A(arg1, arg2)
            |
        validator2B
    &
        validator3A(arg1, arg2)
            |
        validator3B
;

The &, as in the list of string splits, takes precedence over |.

Acknowledgement

Thanks to Cannabis sativa.

License

Do what you want, I do not care.