src/Message.js
function populateDefault(message, field) {
  const fieldName = field.getName();
  if (message.has(fieldName)) {
    return true;
  }

  const defaultValue = field.getDefault(message);
  if (defaultValue === null) {
    return false;
  }

  const msg = msgs.get(message);

  if (field.isASingleValue()) {
    msg.data.set(fieldName, defaultValue);
    msg.clearedFields.delete(fieldName);
    return true;
  }

  if (isEmpty(defaultValue)) {
    return false;
  }

  if (field.isASet()) {
    message.addToSet(fieldName, Array.from(defaultValue));
    return true;
  }

  msg.data.set(fieldName, defaultValue);
  msg.clearedFields.delete(fieldName);
  return true;
}
function populateDefault(message, field) {
  const fieldName = field.getName();
  if (message.has(fieldName)) {
    return true;
  }

  const defaultValue = field.getDefault(message);
  if (defaultValue === null) {
    return false;
  }

  const msg = msgs.get(message);

  if (field.isASingleValue()) {
    msg.data.set(fieldName, defaultValue);
    msg.clearedFields.delete(fieldName);
    return true;
  }

  if (isEmpty(defaultValue)) {
    return false;
  }

  if (field.isASet()) {
    message.addToSet(fieldName, Array.from(defaultValue));
    return true;
  }

  msg.data.set(fieldName, defaultValue);
  msg.clearedFields.delete(fieldName);
  return true;
}
function populateDefault ( message , field ) { const fieldName = field . getName ( ) ; if ( message . has ( fieldName ) ) { return true ; } const defaultValue = field . getDefault ( message ) ; if ( defaultValue === null ) { return false ; } const msg = msgs . get ( message ) ; if ( field . isASingleValue ( ) ) { msg . data . set ( fieldName , defaultValue ) ; msg . clearedFields . delete ( fieldName ) ; return true ; } if ( isEmpty ( defaultValue ) ) { return false ; } if ( field . isASet ( ) ) { message . addToSet ( fieldName , Array . from ( defaultValue ) ) ; return true ; } msg . data . set ( fieldName , defaultValue ) ; msg . clearedFields . delete ( fieldName ) ; return true ; }
Populates the default on a single field if it's not already set
and the default generated is not a null value or empty array.

@param {Message} message
@param {Field} field

@returns {boolean} Returns true if a non null/empty default was applied or already present.
Populates the default on a single field if it s not already set and the default generated is not a null value or empty array .