is

Checks if the given argument is an array.

Type signature

(x?: any) => boolean

Examples

array([1, 2, 3]);
// ⇒ true
Try in REPL
array({ a: 1 });
// ⇒ false
Try in REPL

Questions

  • How to check if a given value is an array?

TypeScript sourceJavaScript source

Checks if the given value is a boolean.

Type signature

(x?: any) => boolean

Examples

boolean(false); // ⇒ true
Try in REPL
boolean(1); // ⇒ false
Try in REPL

Questions

  • How to check if a given value is a boolean?

TypeScript sourceJavaScript source

Checks if the given value is a byte.

Type signature

(x?: number) => boolean

Examples

byte(128);
// ⇒ true
Try in REPL
byte(325);
// ⇒ false
Try in REPL
byte(65.5);
// ⇒ false
Try in REPL

Questions

  • How to check if a given value is a byte?
  • How to check if a given number is a byte?

TypeScript sourceJavaScript source

Checks if the given value is a Date object.

Type signature

(x?: any) => boolean

Examples

date(new Date());
// ⇒ true
Try in REPL
date(123);
// ⇒ false
Try in REPL

Questions

  • How to check if a given value is a Date object?

TypeScript sourceJavaScript source

Checks if the given value is defined.

Type signature

(x?: any) => boolean

Examples

defined(undefined);
// ⇒ false
Try in REPL
defined(null);
// ⇒ true
Try in REPL
defined(0);
// ⇒ true
Try in REPL
defined({ a: 1 });
// ⇒ true
Try in REPL

Questions

  • How to check if a given value is defined?
  • How to check if a given value is not undefined?

TypeScript sourceJavaScript source

Checks if the given value is a function.

Type signature

(x?: any) => boolean

Examples

_function((x) => x + 5);
// ⇒ true
Try in REPL

Questions

  • How to check if a given value is a function?

TypeScript sourceJavaScript source

Checks if the given value is an integer.

Type signature

(x?: number) => boolean

Examples

integer(5);
// ⇒ true
Try in REPL
integer(32.5);
// ⇒ false
Try in REPL

Questions

  • How to check if a given value is an integer?
  • How to check if a given number is an integer?

TypeScript sourceJavaScript source

Checks and asserts the given value is not null or undefined.

Type signature

<T>(val: T) => val is NonNullable<T>

Examples

nonNullable(null);
// ⇒ false
Try in REPL
nonNullable(undefined);
// ⇒ false
Try in REPL
nonNullable(false);
// ⇒ true
Try in REPL
nonNullable({ a: 1 });
// ⇒ true
Try in REPL

Questions

  • How to check if a given value is non-nullable?
  • How to check if a given value is not null?
  • How to check if a given value is not undefined?

TypeScript sourceJavaScript source

Checks if the given value is a number in a normal range [0, 1].

Type signature

(x?: number) => boolean

Examples

normal(0.75);
// ⇒ true
Try in REPL
normal(-1);
// ⇒ false
Try in REPL
normal(2.5);
// ⇒ false
Try in REPL

Questions

  • How to check if a given value is in 0 to 1 inclusive range?

TypeScript sourceJavaScript source

Checks if the given value is a number.

Type signature

(x?: any) => boolean

Examples

number(0 / 0);
// ⇒ false
Try in REPL
number(15.6);
// ⇒ true
Try in REPL

Questions

  • How to check if a given value is a valid number?
  • How to check if a given value is not NaN?
  • How to check if a given value is finite?

TypeScript sourceJavaScript source

Checks if the given value is an object.

Type signature

(x?: any) => boolean

Examples

object({ a: 1, b: 2 });
// ⇒ true
Try in REPL
object([1, 2, 3]);
// ⇒ false
Try in REPL

Questions

  • How to check if a given value is an object?

TypeScript sourceJavaScript source

Checks if the given value is a string.

Type signature

(x?: any) => boolean

Examples

string("Test");
// ⇒ true
Try in REPL
string(["T", "e", "s", "t"]);
// ⇒ false
Try in REPL

Questions

  • How to check if a given value is a string?

TypeScript sourceJavaScript source