client/extensions/woocommerce/state/sites/products/reducer.js
function updateCachedProduct( products, product ) {
	let found = false;
	const updatedProduct = { ...product, name: decodeEntities( product.name ) };
	const newProducts = products.map( p => {
		if ( p.id === product.id ) {
			found = true;
			return updatedProduct;
		}
		return p;
	} );

	if ( ! found ) {
		newProducts.push( updatedProduct );
	}

	return newProducts;
}
function updateCachedProduct( products, product ) {
	let found = false;
	const updatedProduct = { ...product, name: decodeEntities( product.name ) };
	const newProducts = products.map( p => {
		if ( p.id === product.id ) {
			found = true;
			return updatedProduct;
		}
		return p;
	} );

	if ( ! found ) {
		newProducts.push( updatedProduct );
	}

	return newProducts;
}
function updateCachedProduct ( products , product ) { let found = false ; const updatedProduct = { ... product , name : decodeEntities ( product . name ) } ; const newProducts = products . map ( p => { if ( p . id === product . id ) { found = true ; return updatedProduct ; } return p ; } ) ; if ( ! found ) { newProducts . push ( updatedProduct ) ; } return newProducts ; }
Merge a product into the products list

@param  {Array}  products A list of products
@param  {Object} product  A single product to update or add to the products list
@return {Array}         Updated product list
Merge a product into the products list