nunof07/smalltypes

View on GitHub
src/main/scalar/IsJsFunction.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { Scalar } from '@main';

/**
 * Determines if variable is a standard JavaScript function.
 */
export class IsJsFunction<T> implements Scalar<boolean> {
    /**
     * Variable to check.
     */
    private readonly val: T;

    /**
     * Ctor.
     * @param val Variable to check.
     */
    constructor(val: T) {
        this.val = val;
    }

    /**
     * Type determinant.
     */
    public isScalar(): true {
        return true;
    }

    /**
     * Get the value.
     */
    public value(): boolean {
        return typeof this.val === 'function';
    }
}