<commit_before>'use strict';

var extend = require('extend-shallow');

/**
 * Parse a string to retrieve or replace @ mention strings.
 *
 * ```js
 * // get an array of @ mention strings
 * var mentions = parse('- @doowb\n- @jonschlinkert');
 * console.log(mentions);
 * //=> ['doowb', 'jonschlinkert']
 *
 * // replace @ mention strings with a url
 * var str = parse('- @doowb\n- @jonschlinkert', function(name) {
 *   return `[@${name}](https://github.com/${name})`;
 * });
 * console.log(str);
 * //=> - [@doowb](https://github.com/doowb)
 * //=> - [@jonschlinkert](https://github.com/jonschlinkert)
 * ```
 *
 * @param  {String} `str` Input string to parse looking for @ mentions.
 * @param  {Object} `options` Optional options object to control the output of the @ mentions
 * @param  {Boolean} `options.stringify` Should the @ mentions be stringified in the output array. When `false` an object with additional information about the mention is returned. Defaults to `true`.
 * @param  {Function} `fn` Optional replace function. When passed in, the @ mentions are replaced in the string instead of returned as an array. The new string is returned.
 * @return {String|Array} Array of mentions when a replace function is not passed in.<commit_msg>add additional example to docs<commit_after>'use strict';

var extend = require('extend-shallow');

/**
 * Parse a string to retrieve or replace @ mention strings.
 *
 * ```js
 * // get an array of @ mention strings
 * var mentions = parse('- @doowb\n- @jonschlinkert');
 * console.log(mentions);
 * //=> ['doowb', 'jonschlinkert']
 *
 * // replace @ mention strings with a url
 * var str = parse('- @doowb\n- @jonschlinkert', function(name) {
 *   return `[@${name}](https://github.com/${name})`;
 * });
 * console.log(str);
 * //=> - [@doowb](https://github.com/doowb)
 * //=> - [@jonschlinkert](https://github.com/jonschlinkert)
 *
 * // get an array of @ mention objects
 * var mentions = parse('- @doowb\n- @jonschlinkert', {stringify: false});
 * console.log(mentions);
 * //=> [
 * //=>   {name: 'doowb', mention: '@doowb', index: 2},
 * //=>   {name: 'jonschlinkert', mention: '@jonschlinkert', index: 11}
 * //=> ]
 * ```
 *
 * @param  {String} `str` Input string to parse looking for @ mentions.
 * @param  {Object} `options` Optional options object to control the output of the @ mentions
 * @param  {Boolean} `options.stringify` Should the @ mentions be stringified in the output array. When `false` an object with additional information about the mention is returned. Defaults to `true`.
 * @param  {Function} `fn` Optional replace function. When passed in, the @ mentions are replaced in the string instead of returned as an array. The new string is returned.
 * @return {String|Array} Array of mentions when a replace function is not passed in.
{'fraction_non_alphanumeric': 0.16055535777856889, 'fraction_numerical': 0.001067995728017088, 'mean_word_length': 3.86159169550173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 6, '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': '689317', 'n_tokens_mistral': 875, 'n_tokens_neox': 859, 'n_words': 301}