<commit_before>import { Enumerable, keyComparer } from "./Enumerable";

export class DistinctEnumerable<T = any> extends Enumerable<T> {
    constructor(protected readonly parent: Enumerable<T>, protected readonly selector?: (item: T) => any) {
        super();
    }
    public [Symbol.iterator]() {
        return this;
    }
    public next(): IteratorResult<T> {
        let result: IteratorResult<T> = {
            done: this.result.length <= this.pointer,
            value: this.result[this.pointer]
        };
        if (result.done && !this.isResultComplete) {
            while (!(result = this.parent.next()).done) {
                const key = this.selector ? this.selector(result.value) : result.value;
                if (!this.result.any((o) => keyComparer(key, this.selector ? this.selector(result.value) : result.value)))
                    break;
            }
            if (result.done) {
                this.isResultComplete = true;
                this.resetPointer();
                return result;
            }
            this.result[this.pointer] = result.value;
            result.done = false;
        }
        result.done ? this.resetPointer() : this.pointer++;
        return result;
    }
}<commit_msg>fix distinct enumerable<commit_after>import { Enumerable, keyComparer } from "./Enumerable";

export class DistinctEnumerable<T = any> extends Enumerable<T> {
    constructor(protected readonly parent: Enumerable<T>, protected readonly selector?: (item: T) => any) {
        super();
    }
    public [Symbol.iterator]() {
        return this;
    }
    public next(): IteratorResult<T> {
        let result: IteratorResult<T> = {
            done: this.result.length <= this.pointer,
            value: this.result[this.pointer]
        };
        if (result.done && !this.isResultComplete) {
            while (!(result = this.parent.next()).done) {
                const key = this.selector ? this.selector(result.value) : result.value;
                if (!this.result.any((o) => keyComparer(key, o)))
                    break;
            }
            if (result.done) {
                this.isResultComplete = true;
                this.resetPointer();
                return result;
            }
            this.result[this.pointer] = result.value;
            result.done = false;
        }
        result.done ? this.resetPointer() : this.pointer++;
        return result;
    }
}
{'fraction_non_alphanumeric': 0.12741471434443075, 'fraction_numerical': 0.0, 'mean_word_length': 1.8941736028537455, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '1349687', 'n_tokens_mistral': 661, 'n_tokens_neox': 641, 'n_words': 142}