open-nomad/ui/app/helpers/eq-by.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
389 B
JavaScript
Raw Normal View History

import { get } from '@ember/object';
import { helper } from '@ember/component/helper';
/**
* Eq By
*
* Usage: {{eq-by "prop" obj1 obj2}}
*
* Returns true when obj1 and obj2 have the same value for property "prop"
*/
export function eqBy([prop, obj1, obj2]) {
if (!prop || !obj1 || !obj2) return false;
return get(obj1, prop) === get(obj2, prop);
}
export default helper(eqBy);