mirror of https://github.com/status-im/consul.git
13 lines
398 B
JavaScript
13 lines
398 B
JavaScript
|
import { get, set } from '@ember/object';
|
||
|
export default function(arr, item, prop, value) {
|
||
|
value = typeof value === 'undefined' ? get(item, prop) : value;
|
||
|
const current = arr.findBy(prop, value);
|
||
|
if (current) {
|
||
|
// TODO: This is reliant on changeset?
|
||
|
Object.keys(get(item, 'data')).forEach(function(prop) {
|
||
|
set(current, prop, get(item, prop));
|
||
|
});
|
||
|
return current;
|
||
|
}
|
||
|
}
|