<commit_before>'use strict';

module.exports = (NODE) => {
  const defaultIn = NODE.getInputByName('default');
  const valueOut = NODE.getOutputByName('value');

  let paramValue;

  NODE.on('init', () => {
    const flowInstanceParams = NODE.flowInstance.params;
    if (flowInstanceParams[NODE.data.paramName]) {
      paramValue = flowInstanceParams[NODE.data.paramName];
      valueOut.type = typeof paramValue;
    }
  });

  valueOut.on('trigger', async (conn, state, callback) => {
    if (paramValue) {
      callback(paramValue);
      return;
    }

    const defaults = await defaultIn.getValues(state);
    const defaultValue = defaults.length ? defaults[0] : undefined;
    callback(defaultValue);
  });
};
<commit_msg>set the output type for connected defaults<commit_after>'use strict';

module.exports = (NODE) => {
  const defaultIn = NODE.getInputByName('default');
  const valueOut = NODE.getOutputByName('value');

  let paramValue;

  NODE.on('init', () => {
    const flowInstanceParams = NODE.flowInstance.params;
    if (flowInstanceParams[NODE.data.paramName]) {
      paramValue = flowInstanceParams[NODE.data.paramName];
      valueOut.type = typeof paramValue;
    } else if (defaultIn.isConnected()) {
      valueOut.type = defaultIn.type;
    }
  });

  valueOut.on('trigger', async (conn, state, callback) => {
    if (paramValue) {
      callback(paramValue);
      return;
    }

    const defaults = await defaultIn.getValues(state);
    const defaultValue = defaults.length ? defaults[0] : undefined;
    callback(defaultValue);
  });
};

{'fraction_non_alphanumeric': 0.13668150031786394, 'fraction_numerical': 0.0012714558169103624, 'mean_word_length': 3.6568047337278107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4900685', 'n_tokens_mistral': 479, 'n_tokens_neox': 472, 'n_words': 95}