<commit_before>import {iter} from '..';

/**
 * Yields elements of the input iterable by grouping them into tuples
 * consecutive elements from the same equivalence class.
 *
 * @example
 * // A B C D A B
 * list( map( ( k , g ) => k , group( x => x , 'AAAABBBCCDAABBB' ) ) )
 *
 * @example
 * // AAAA BBB CC D
 * list( map( ( k , g ) => list( g ) , group( x => x , 'AAAABBBCCD' ) ) )
 *
 * @param {Function} key - The function used to determine the equivalence class
 * of an element.
 * @param {Iterable} iterable - The input iterable.
 * @returns {Iterator}
 */
export function* group(key, iterable) {
	const iterator = iter(iterable);

	const first = iterator.next();

	if (first.done) {
		return;
	}

	let currval = first.value;
	let currkey = key(currval);

	const grouper = function* (tgtkey) {
		while (true) {<commit_msg>:books: docs(group): Fix typos in examples.<commit_after>import {iter} from '..';

/**
 * Yields elements of the input iterable by grouping them into tuples
 * consecutive elements from the same equivalence class.
 *
 * @example
 * // A B C D A B
 * list( map( ( [ k , g ] ) => k , group( x => x , 'AAAABBBCCDAABBB' ) ) )
 *
 * @example
 * // AAAA BBB CC D
 * list( map( ( [ k , g ] ) => list( g ) , group( x => x , 'AAAABBBCCD' ) ) )
 *
 * @param {Function} key - The function used to determine the equivalence class
 * of an element.
 * @param {Iterable} iterable - The input iterable.
 * @returns {Iterator}
 */
export function* group(key, iterable) {
	const iterator = iter(iterable);

	const first = iterator.next();

	if (first.done) {
		return;
	}

	let currval = first.value;
	let currkey = key(currval);

	const grouper = function* (tgtkey) {
		while (true) {
{'fraction_non_alphanumeric': 0.14840989399293286, 'fraction_numerical': 0.0, 'mean_word_length': 3.154034229828851, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5956913', 'n_tokens_mistral': 602, 'n_tokens_neox': 580, 'n_words': 203}