2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2020-08-05 18:55:17 +00:00
|
|
|
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]) {
|
2020-08-07 00:59:26 +00:00
|
|
|
if (!prop || !obj1 || !obj2) return false;
|
2020-08-05 18:55:17 +00:00
|
|
|
return get(obj1, prop) === get(obj2, prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default helper(eqBy);
|