github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/helpers/eq-by.js (about)

     1  import { get } from '@ember/object';
     2  import { helper } from '@ember/component/helper';
     3  
     4  /**
     5   * Eq By
     6   *
     7   * Usage: {{eq-by "prop" obj1 obj2}}
     8   *
     9   * Returns true when obj1 and obj2 have the same value for property "prop"
    10   */
    11  export function eqBy([prop, obj1, obj2]) {
    12    if (!prop || !obj1 || !obj2) return false;
    13    return get(obj1, prop) === get(obj2, prop);
    14  }
    15  
    16  export default helper(eqBy);