nl_tokens: Edits existing product if one with matching ID found . Otherwise inserts the new one at the beginning of the list .
pl_tokens: function addOrEditProduct ( list = [ ] , newProduct ) { let <mask> = 0 ; const products = list . map ( product => { if ( product . ID === newProduct . ID ) { found = 1 ; return newProduct ; } return product ; } ) ; if ( ! found ) { return [ newProduct , ... products ] ; } return products ; }