lib/images.js
/** 
 * At array of objects {name, value} finds object by name and replace its value,
 * and if it was not found then adds new object to array
 */
At array of objects {name, value} finds object by name and replace its value,
and if it was not found then adds new object to array
At array of objects { name value } finds object by name and replace its value and if it was not found then adds new object to array
function addOrReplace(arr, name, value) {
  const obj = arr.filter( _ => _.name === name)[0];
  if (obj) {
    obj.value = value
  } else {
    arr.push({name, value});
  }
}
function addOrReplace ( arr , name , value ) { const obj = arr . filter ( _ => _ . name === name ) [ 0 ] ; if ( obj ) { obj . value = value } else { arr . push ( { name , value } ) ; } }
At array of objects {name, value} finds object by name and replace its value,
 and if it was not found then adds new object to array
At array of objects { name value } finds object by name and replace its value and if it was not found then adds new object to array