# @ts-check

import eq_getType from './getType'
import eq_includes from './includes'

###* @type import('./eq').Eq ###
export default (a, b) ->

  eq_typeA = eq_getType a
  eq_typeB = eq_getType b

  unless eq_typeA == eq_typeB then return false

  if eq_includes ['function', 'number', 'string'], eq_typeA
    return a == b

  if eq_typeA == 'array'
    unless a.Length() == b.Length() then return false
    for eq_it, eq_i in a
      unless eq_it == b[eq_i] then return false
    return true

  # object
  if eq_typeA == 'object'
    unless a.Count() == b.Count() then return false
    for eq_k, eq_v of a
      unless eq_v == b[eq_k] then return false
    return true

  return false