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

expect-more

v1.3.0

Published

Curried JavaScript Type Testing Library with Zero Dependencies

Downloads

386,794

Readme

expect-more

Curried JavaScript Type Testing Library with Zero Dependencies

NPM version NPM downloads Build Status Maintainability Follow JamieMason on GitHub Follow fold_left on Twitter

Installation

npm install expect-more --save-dev

Usage

import { endsWith, isWithinRange } from 'expect-more';

const result: boolean = endsWith('Script', 'JavaScript');
// => true

const endsWithScript = endsWith('Script');
endsWithScript('JavaScript');
// => true

isWithinRange(10, 20, 21);
// => false

[0, 1, 1, 2, 3, 5, 8, 13, 21, 34].filter(isWithinRange(5, 15));
// => [5, 8, 13]

API: expect-more

General

declare const isBoolean: (value: unknown) => value is boolean;
declare const isFalse: (value: unknown) => value is false;
declare const isNull: (value: unknown) => value is null;
declare const isRegExp: (value: unknown) => value is RegExp;
declare const isTrue: (value: unknown) => value is true;
declare const isUndefined: (value: unknown) => value is undefined;

Functions

declare const isAsyncFunction: <T = (...args: any[]) => Promise<any>>(
  value: unknown,
) => value is T;
declare const isFunction: <T = (...args: any[]) => any>(value: unknown) => value is T;
declare const isGeneratorFunction: <T = Generator>(value: unknown) => value is T;
declare const throwsAnyError: <T = (...args: any[]) => any>(value: unknown) => value is T;
declare const throwsErrorOfType: <T = (...args: any[]) => any>(
  typeName: string,
  value: unknown,
) => value is T;

Objects

declare const hasMember: <T = any>(memberName: string, value: unknown) => value is T;
declare const isEmptyObject: <T = any>(value: unknown) => value is T;
declare const isNil: (value: unknown) => value is undefined | null;
declare const isNonEmptyObject: <T = any>(value: unknown) => value is T;
declare const isObject: <T = any>(value: unknown) => value is T;
declare const isWalkable: <T = any>(value: unknown) => value is T;

Arrays

declare const isArray: <T extends any[] = any[]>(value: unknown) => value is T;
declare const isArrayIncludingAllOf: <T extends any[] = any[]>(needed: any[], value: unknown) => value is T;
declare const isArrayIncludingAnyOf: <T extends any[] = any[]>(needed: any[], value: unknown) => value is T;
declare const isArrayIncludingOnly: <T extends any[] = any[]>(needed: any[], value: unknown) => value is T;
declare const isArrayOfBooleans: (value: unknown) => value is boolean[];
declare const isArrayOfNumbers: (value: unknown) => value is number[];
declare const isArrayOfObjects: <T extends any[] = any[]>(value: unknown) => value is T;
declare const isArrayOfSize: <T extends any[] = any[]>(
  size: number,
  value: unknown,
) => value is T;
declare const isArrayOfStrings: (value: unknown) => value is string[];
declare const isEmptyArray: <T extends [] = []>(any) => value is T;
declare const isNonEmptyArray: <T extends any[] = any[]>(value: unknown) => value is T;

Dates

declare const isAfter: (other: Date, value: unknown) => value is Date;
declare const isBefore: (other: Date, value: unknown) => value is Date;
declare const isDate: (value: unknown) => value is Date;
declare const isDateBetween: (floor: Date, ceiling: Date, value: unknown) => value is Date;
declare const isDateInMonth: (index: number, value: unknown) => value is Date;
declare const isDateInYear: (year: number, value: unknown) => value is Date;
declare const isDateOnDayOfMonth: (day: number, value: unknown) => value is Date;
declare const isDateOnDayOfWeek: (index: number, value: unknown) => value is Date;
declare const isDateOnOrAfter: (other: Date, value: unknown) => value is Date;
declare const isDateOnOrBefore: (other: Date, value: unknown) => value is Date;
declare const isValidDate: (value: unknown) => value is Date;

Numbers

declare const isCalculable: (value: unknown) => value is number;
declare const isDecimalNumber: (value: unknown) => value is number;
declare const isDivisibleBy: (other: number, value: unknown) => value is number;
declare const isEvenNumber: (value: unknown) => value is number;
declare const isGreaterThanOrEqualTo: (other: number, value: unknown) => value is number;
declare const isLessThanOrEqualTo: (other: number, value: unknown) => value is number;
declare const isNear: (other: number, epsilon: number, value: unknown) => value is number;
declare const isNegativeNumber: (value: unknown) => value is number;
declare const isNumber: (value: unknown) => value is number;
declare const isOddNumber: (value: unknown) => value is number;
declare const isPositiveNumber: (value: unknown) => value is number;
declare const isWholeNumber: (value: unknown) => value is number;
declare const isWithinRange: (
  floor: number,
  ceiling: number,
  value: unknown,
) => value is number;

Strings

declare const endsWith: (other: string, value: unknown) => value is string;
declare const isEmptyString: (value: unknown) => value is string;
declare const isIso8601: (value: unknown) => value is string;
declare const isJsonString: (value: unknown) => value is string;
declare const isLongerThan: (other: string, value: unknown) => value is string;
declare const isNonEmptyString: (value: unknown) => value is string;
declare const isSameLengthAs: (other: string, value: unknown) => value is string;
declare const isShorterThan: (other: string, value: unknown) => value is string;
declare const isString: (value: unknown) => value is string;
declare const isVisibleString: (value: unknown) => value is string;
declare const isWhitespace: (value: unknown) => value is string;
declare const startsWith: (other: string, value: unknown) => value is string;

API: expect-more/gen

declare const withMissingBranches: (value: object | any[]) => Generator;
declare const withMissingLeaves: (value: object | any[]) => Generator;
declare const withMissingNodes: (value: object | any[]) => Generator;
declare const withNullBranches: (value: object | any[]) => Generator;
declare const withNullLeaves: (value: object | any[]) => Generator;
declare const withNullNodes: (value: object | any[]) => Generator;