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

wassat

v2.3.0

Published

what is that?

Downloads

160

Readme

wassat Build Status codecov.io

(What's that?)

Installation and Usage

npm install wassat

var wassat = require('wassat');

API

wassat(Object anything) -> String

The main function accepts anything and returns a string. The result is an all-lowercase version of the basic JavaScript "class" of which the object is an instance. If it's an instance of something else (HTMLElement for example, or perhaps the Math object), it returns "object". Under the hood, wassat uses Object.prototype.toString. For null and undefined, wassat() uses strict equality.

  • wassat('abc') -> 'string'
  • wassat(123) -> 'number'
  • wassat(NaN) -> 'number'
  • wassat(true) -> 'boolean'
  • wassat({}) -> 'object'
  • wassat([]) -> 'array'
  • wassat(function(){}) -> 'function'
  • wassat(new Date()) -> 'date'
  • wassat(new RegExp()) -> 'regexp'
  • wassat(new Error()) -> 'error'
  • wassat((function(){return arguments})()) -> 'arguments'
  • wassat(document.querySelector('div')) -> 'object'
  • wassat(null) -> 'null'
  • wassat(undefined) -> 'undefined'

.is methods

There is a corresponding "is" method for each type, as follows:

wassat.isString([Object anything]) -> Boolean

true if wassat(anything) === 'string', else false

wassat.isNumber([Object anything]) -> Boolean

true if wassat(anything) === 'number', else false

Note: Returns true for NaN

wassat.isBoolean(Object anything) -> Boolean

true if wassat(anything) === 'boolean', else false

wassat.isArray(Object anything) -> Boolean

true if wassat(anything) === 'array', else false

wassat.isObject(Object anything) -> Boolean

true if wassat(anything) === 'object', else false

wassat.isFunction(Object anything) -> Boolean

true if wassat(anything) === 'function', else false

wassat.isDate(Object anything) -> Boolean

true if wassat(anything) === 'date', else false

wassat.isRegExp(Object anything) -> Boolean

true if wassat(anything) === 'regexp', else false

wassat.isError(Object anything) -> Boolean

true if wassat(anything) === 'error', else false

wassat.isArguments(Object anything) -> Boolean

true if wassat(anything) === 'arguments', else false

wassat.isNull(Object anything) -> Boolean

true if wassat(anything) === 'null', else false

wassat.isUndefined(Object anything) -> Boolean

true if wassat(anything) === 'undefined', else false

Other Methods

wassat.isNil(Object anything) -> Boolean

true if wassat(anything) === 'null' or wassat(anything) === 'undefined'

wassat.isPrimitive(Object anything) -> Boolean

true if anything is of a primitive type (string, number, boolean). Primitive types can't hold properties. Not yet tested with ES6 Symbols.

wassat.isIt(Function ctor, Object anything) -> Boolean

Uses instanceof to check if ctor's prototype is in anything's prototype chain. Performs a little check for primitives so it can handle those too (since "abc" instanceof String is false).

wassat.isItExactly(Function ctor, Object anything) -> Boolean

Compares the prototype of anything (via Object.getPrototypeOf) to the value of ctor.prototype to see if ctor is the constructor function of anything. Performs a little check for primitives so it can handle those too (since Object.getPrototypeOf("abc") throws).

wassat.isAll(String type, Array iterable) -> Boolean

For each item in iterable, returns false if wassat(item) isn't type. Else true.