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

@gik/tools-checker

v0.0.11

Published

A minimal type-checker for JavaScript purists. Part of our [tools suite](https://github.com/gikmx/tools).

Downloads

10

Readme

@gik/tools-checker 0.0.11

A minimal type-checker for JavaScript purists. Part of our tools suite.

Contributors
Supported platforms

Table of contents

  • checker A minimal type-checker for JavaScript purists.
    • is Determine if given value really belongs to the corresponding type.
      • objectEmpty member Determine if an element is an object and has no keys
      • string member Determines if value is really a string.
      • number member Determines if value is really a number.
      • array member Determines if value is really an array.
      • function member Determines if value is really a function.
      • regexp member Determines if value is really a regexp.
      • boolean member Determines if value is really a boolean.
      • object member Determines if value is really an object.
    • props function Validates properties of given object.
  • Types ``

checker

A minimal type-checker for JavaScript purists.

Members

▲ Top


is

Determine if given value really belongs to the corresponding type.

Members

▲ Top


objectEmpty

static property of checker.is

Determine if an element is an object and has no keys

Parameters
Returns

boolean - Whether the object is empty or not.

▲ Top


string

static property of checker.is

Determines if value is really a string.

Parameters
Returns

boolean - Wheter value is string or not.

▲ Top


number

static property of checker.is

Determines if value is really a number.

Parameters
Returns

boolean - Wheter value is number or not.

▲ Top


array

static property of checker.is

Determines if value is really an array.

Parameters
Returns

boolean - Wheter value is array or not.

▲ Top


function

static property of checker.is

Determines if value is really a function.

Parameters
Returns

boolean - Wheter value is function or not.

▲ Top


regexp

static property of checker.is

Determines if value is really a regexp.

Parameters
Returns

boolean - Wheter value is regexp or not.

▲ Top


boolean

static property of checker.is

Determines if value is really a boolean.

Parameters
Returns

boolean - Wheter value is boolean or not.

▲ Top


object

static property of checker.is

Determines if value is really an object.

Parameters
Returns

boolean - Wheter value is object or not.

▲ Top


props

static method of checker

Validates properties of given object.

Parameters
Returns

Object - The validated subject extended with default values (when applies).

Throws
  • CheckerPropParamError when invalid parameters are passed.
  • CheckerPropDefError when a type definition is invalid.
  • CheckerPropDefTypeError when a type defintiion is not supported.
  • CheckerPropReqError when a required property is not found.
  • CheckerPropTypeError when a property does not match the defintion.
Example
const subject = { a: 1, b: 'hello' z: undefined };
const result = props(subject, {
    a: { type:'number', required:true },
    b: 'string',
    c: { default: new Date() },
    d: { required: false, default: null, map: value => [value, true] },
})
// result:
// { a: 1, b: 'hello', c: '1981-06-23 10:06:08', d: [null, true], z: undefined }

▲ Top


Types

Members

▲ Top


CheckerPropParamError

static typedef of Types

A definition prop was sent, but it was invalid.

▲ Top


CheckerPropDefError

static typedef of Types

The specified type is not a supported primitive.

▲ Top


CheckerPropDefTypeError

static typedef of Types

A required property was not found in subject.

▲ Top


CheckerPropReqError

static typedef of Types

A property didn't have the correct type.

▲ Top