<commit_before>import npmconf from 'npmconf';

const CONFIG_KEY_SEPARATORS = ['.', '-'];


/**
 * Return context from npm config data
 *
 * @return {Promise}
 */
export default function npm() {
  return new Promise((resolve, reject) => {
    npmconf.load((err, config) => {
      if (err) {
        console.log('npmerr', err);
        reject(err);
      } else {
        resolve(getContext(config));
      }
    });
  });
}

export function getContext(config) {
  const author = getAuthor(config);
  return {
    author,
    formattedAuthor: formatAuthor(author),
    source: config
  };
}


/**
 * Return npm author data
 *
 * @param {Object} config loaded npmconf config object
 * @return {Object}
 */
function getAuthor(config) {
  return {
    name: getConfigValue(config, ['init', 'author', 'name']),
    email: getConfigValue(config, ['init', 'author', 'email']),<commit_msg>docs(context): Add JSDoc<commit_after>import npmconf from 'npmconf';

const CONFIG_KEY_SEPARATORS = ['.', '-'];


/**
 * Return context from npm config data
 *
 * @return {Promise}
 */
export default function npm() {
  return new Promise((resolve, reject) => {
    npmconf.load((err, config) => {
      if (err) {
        console.log('npmerr', err);
        reject(err);
      } else {
        resolve(getContext(config));
      }
    });
  });
}

/**
 * Return npm context
 *
 * @param {Object} config loaded npmconf config object
 * @return {Object}
 */
export function getContext(config) {
  const author = getAuthor(config);
  return {
    author,
    formattedAuthor: formatAuthor(author),
    source: config
  };
}


/**
 * Return npm author data
 *
 * @param {Object} config loaded npmconf config object
 * @return {Object}
 */
function getAuthor(config) {
  return {
    name: getConfigValue(config, ['init', 'author', 'name']),
    email: getConfigValue(config, ['init', 'author', 'email']),
{'fraction_non_alphanumeric': 0.15842636895268475, 'fraction_numerical': 0.0, 'mean_word_length': 3.2772727272727273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '876342', 'n_tokens_mistral': 599, 'n_tokens_neox': 580, 'n_words': 151}