static isGreater()

Checks whether the given value is the Greater instance of any or given primitive value

Greater.isGreater()

Checks whether the given value is the Greater instance of any or given primitive value.

greater.class.ts
public static isGreater<Value extends number>(
  value: any,
  greaterValue?: Value
): value is Greater<Value> {
  return (
    typeof value === 'object' &&
    value instanceof this &&
    (typeof greaterValue === 'number'
      ? value.valueOf() === greaterValue
      : true)
  );
}

Generic type variables

Valueextendsnumber

A generic type variable indicates captured type of the supplied greaterValue via the return type.

Parameters

value:any

The value of any type to test against the Greater instance.

greaterValue:Value

An optional value of generic type variable Value to check whether it's the primitive value of the given value.

Return type

Greater<Value>

The return type is a boolean resulting from its statement indicating the value is the Greater object that takes the generic type variable Value.

Returns

The return value is a boolean indicating whether the given value is the Greater instance of any or given primitive value.

Example usage

// Example usage.
import { Greater } from '@angular-package/range';

// Define constant `id`.
const id = 390;

// Returns Greater {390} of Greater<390>.
const id390 = Greater.create(id);

// Returns `true`.
Greater.isGreater(id390);

// Returns `false`.
Greater.isGreater(id390, 381);

// Returns `true`.
Greater.isGreater(id390, 390);

Last updated