conductor
Why I'm building conductorGitHub
v1.5.0
v1.5.0
  • Introduction
  • Overview
    • Introduction
    • Core concepts
  • API reference
    • always
    • append
    • apply
    • arity
    • branch
    • capitalize
    • compose
    • concat
    • curry
    • curryN
    • delay
    • dump
    • entries
    • equals
    • equalsBy
    • factory
    • filter
    • findIndex
    • flatten
    • flip
    • forEach
    • get
    • head
    • ifElse
    • identity
    • into
    • isPromise
    • iterate
    • join
    • keys
    • map
    • merge
    • mergeBy
    • next
    • not
    • pluck
    • prepend
    • random
    • reduce
    • replace
    • slice
    • some
    • split
    • take
    • then
    • toLowerCase
    • transduce
    • transformers
      • transformers/filter
      • transformers/map
    • type
    • upsert
    • values
  • Guides
    • example use cases
    • checkGuards
Powered by GitBook
On this page
  • description
  • examples
  1. API reference

equalsBy

PreviousequalsNextfactory

Last updated 6 years ago

Available since v1.4.0

description

equalsBy :: (Function | String getter, Any item1, Any item2) => Boolean

Returns true if the values returned by the getter are equals on both items. The getter can be provided as a Function or a String. If getter is a Function, then equalsBy will retrieve the comparison value from both items using the provided function. If it is a String, then equalsBy will use it as a key and retrieve the value associated to this key on both items. equalsBy uses internally to compare the two values returned by getter.

examples

providing a key name as a string

import { equalsBy } from 'conductor'

const obj1 = { id: 1, name: 'Anakin' }
const obj2 = { id: 1, name: 'Darth Vader' }

equalsBy('id', obj1, obj2) // true
equalsBy('name', obj1, obj2) // false

using a function as getter

import { equalsBy } from 'conductor'
import { get } from 'conductor'

const obj1 = { id: 1, name: 'Anakin' }
const obj2 = { id: 1, name: 'Darth Vader' }

equalsBy(get('id'), obj1, obj2) // true
equalsBy(get('name'), obj1, obj2) // false
equals