nl_tokens: / * Applies a metadata edit operation ( either update or delete ) to an existing array of metadata values .
pl_tokens: function applyMetadataEdit ( metadata , edit ) { switch ( edit . operation ) { case 'update' : { // Either update existing key's value or append a new one at the end const { key , value } = edit ; if ( find ( <mask> , { key } ) ) { return map ( metadata , m => ( m . key === key ? { key , value } : m ) ) ; } return concat ( metadata || [ ] , { key , value } ) ; } case 'delete' : { // Remove a value from the metadata array. If the key is not present, // return unmodified original value. const { key } = edit ; if ( find ( metadata , { key } ) ) { return reject ( metadata , { key } ) ; } return metadata ; } } return metadata ; }