@nullvoxpopuli/ember-composable-helpers
Version:
Composable helpers for Ember
16 lines (13 loc) • 450 B
JavaScript
import { helper } from '@ember/component/helper';
import { isEmpty } from '@ember/utils';
import { get } from '@ember/object';
import asArray from '../utils/as-array.js';
function findBy([byPath, value, array]) {
if (isEmpty(byPath)) {
return undefined;
}
return asArray(array).find(item => get(item, String(byPath)) === value);
}
var findBy$1 = helper(findBy);
export { findBy$1 as default, findBy };
//# sourceMappingURL=find-by.js.map