import { curry } from './curry.js'
/**
 * @typedef {'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function'} TypeOfValue
 */

/**
 * @template T
 * @param {T} x
 * @returns {TypeOfValue}
 */
export const type = x => typeof x

export const is = curry(
  /**
   * @template T
   * @param {FunctionConstructor} ctr 
   * @param {T} x
   */
  (ctr, x) => x.constructor === ctr)

/**
 * @template T
 * @param {T} x
 */
export const isFn = x => type(x) === 'function'

export const isArray = Array.isArray