function getPayloadExamples(msg) {
  const examples = msg.examples();
  if (Array.isArray(examples) && examples.some(e => e.payload)) {
    // Instead of flat or flatmap use this.
    const messageExamples = _.flatMap(examples)
      .map(e => {
        if (!e.payload) return;
        return {
          name: e.name,
          summary: e.summary,
          example: e.payload,
        };
      })
      .filter(Boolean);

    if (messageExamples.length > 0) {
      return messageExamples;
    }
  }

  const payload = msg.payload();
  if (payload?.examples()) {
    return payload.examples().map(example => ({ example }));
  }
}
Extracts example from the message payload
@msg {object} - Parser Message function
@returns {object}