Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expect-more

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expect-more

Curried JavaScript Type Testing Library with Zero Dependencies

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
80K
decreased by-5.6%
Maintainers
1
Weekly downloads
 
Created
Source

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

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

Functions

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

Objects

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

Arrays

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

Dates

export declare const isAfter: (other: Date, value: unknown) => value is Date;
export declare const isBefore: (other: Date, value: unknown) => value is Date;
export declare const isDate: (value: unknown) => value is Date;
export declare const isValidDate: (value: unknown) => value is Date;

Numbers

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

Strings

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

API: expect-more/gen

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

FAQs

Package last updated on 08 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc