import { assert } from "../../assert.js";

const VALID_TYPES = ['number', 'boolean', 'string', 'function', 'object', 'undefined'];

/**
 * performs typeof match
 * @param {string} type
 * @returns {function(*): boolean}
 */
export function isTypeOf(type) {
    assert.notEqual(VALID_TYPES.indexOf(type), -1, `type must be one of [${VALID_TYPES.join(', ')}], instead was '${type}'`);

    return function (m) {
        return typeof m === type;
    }
}