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

@blackglory/types

v1.4.0

Published

Type guards for JavaScript and Typescript.

Downloads

12,239

Readme

types

Type guards for JavaScript and Typescript.

Install

npm install --save @blackglory/types
# or
yarn add @blackglory/types

API

function isArray<T>(val: unknown): val is Array<T>
function isntArray<T>(val: T): val is Exclude<T, Array<unknown>>

function isEmptyArray(val: unknown[]): boolean
function isntEmptyArray<T>(val: T[]): val is NonEmptyArray<T>

function isAsyncIterable<T>(val: unknown): val is AsyncIterable<T>
function isntAsyncIterable<T>(val: T): val is Exclude<T, AsyncIterable<unknown>>

function isBigInt(val: unknown): val is bigint
function isntBigInt<T>(val: T): val is Exclude<T, bigint>

function isBoolean(val: unknown): val is boolean

function isChar(val: unknown): val is string
function isntChar(val: unknown): boolean

function isDate(val: unknown): val is Date
function isntDate<T>(val: T): val is Exclude<T, Date>

function inEnum<T>(val: unknown, _enum: object): val is T

function isError(val: unknown): val is Error
function isntError<T>(val: T): val is Exclude<T, Error>

function isFalsy(val: unknown): val is Falsy
function isntFalsy<T>(val: T): val is Exclude<T, Falsy>

function isFunction<T extends Function = (...args: any[]) => any>(
  val: unknown
): val is T
function isntFunction<T>(val: T): val is Exclude<T, Function>

function isIterable<T>(val: unknown): val is Iterable<T>
function isntIterable<T>(val: T): val is Exclude<T, Iterable<unknown>>

function isJson(val: unknown): Json
function isntJson<T>(val: T): val is Exclude<T, Json>

function isJsonable(val: unknown): boolean
function isntJsonable<T>(val: T): boolean

function isNull(val: unknown): val is null
function isntNull<T>(val: T): val is Exclude<T, null>

function isNullish(val: unknown): val is Nullish
function isntNullish<T>(val: T): val is Exclude<T, Nullish>

function isNumber(val: unknown): val is number
function isntNumber<T>(val: T): val is Exclude<T, number>

function isFinite(val: number): boolean
function isPositiveInfinity(val: number): boolean
function isNegativeInfinity(val: number): boolean
function isNaN(val: number): boolean
function isntNaN(val: number): boolean

function isObject(val: unknown): val is object & Record<string | symbol | number, unknown>
function isntObject<T>(val: T): val is Exclude<T, object & Record<string | symbol | number, unknown>>

function isPlainObject(val: unknown): val is object & Record<string | symbol | number, unknown>
function isntPlainObject<T>(val: T): val is Exclude<T, object & Record<string | symbol | number, unknown>>

function isEmptyObject(val: object): boolean
function isntEmptyObject(val: object): boolean

function isPromise<T>(val: unknown): val is Promise<T>
function isntPromise<T>(val: T): val is Exclude<T, Promise<unknown>>

function isntPromiseLike<T>(val: T): val is Exclude<T, PromiseLike<unknown>>
function isPromiseLike<T>(val: unknown): val is PromiseLike<T>

function isString(val: unknown): val is string
function isntString<T>(val: T): val is Exclude<T, string>

function isUndefined(val: unknown): val is undefined
function isntUndefined<T>(val: T): val is Exclude<T, undefined>

function isAbsoluteURL(str: string): boolean

function isRegExp(val: unknown): val is RegExp
function isntRegExp<T>(val: T): val is Exclude<T, RegExp>

function isSymbol(val: unknown): val is symbol
function isntSymbol<T>(val: T): val is Exclude<T, symbol>