<commit_before>interface Type<T> extends Function {
    new (...args: any[]): T;
}

interface SpyMap {
    [key: string]: jasmine.Spy;
}

interface ValueMap {
    [key: string]: any;
}

class DynamicMockBase<T extends object> {
    private spyMap: SpyMap = Object.create(null);
    private valueMap: ValueMap = Object.create(null);
    public handler = {
        get: (target: T, propertyName: keyof T, receiver) => {
                // trying to get a property, return value from valueMap.
                if (typeof this.prototype[propertyName] !== 'function') {
                    return this.valueMap[propertyName];
                }

                // trying to get a function, if we haven't created the spy, create one
                if (!this.spyMap[propertyName]) {
                    const spy = jasmine.createSpy(propertyName);
                    this.spyMap[propertyName] = spy;
                }

                return this.spyMap[propertyName];
        },
        // store whatever user wants in the value map
        set: (target, propertyName: keyof T, value, receiver) => {
            if (typeof this.prototype[propertyName] === 'function') {
                throw Error(`Assignment not allowed because ${propertyName} is already a spied function`);
            }

            this.valueMap[propertyName] = value;
            return true;
        },
    };

    constructor(private prototype: T) {}
}

export class MockFactory {
    /**
     * create a mock object that has the identical interface with the class you passed in
     */
    public static create<T extends object>(blueprint: Type<T> | T) {
        let prototype: T;
        if (blueprint['prototype']) {
            prototype = blueprint['prototype'];
        } else {
            prototype = Object.getPrototypeOf(blueprint);
        }

        const mockBase = new DynamicMockBase(prototype);
        return new Proxy<T>(mockBase as any as T, mockBase.handler);
    }
}
<commit_msg>fix missing prototype on some blueprints<commit_after>interface Type<T> extends Function {
    new (...args: any[]): T;
}

interface SpyMap {
    [key: string]: jasmine.Spy;
}

interface ValueMap {
    [key: string]: any;
}

class DynamicMockBase<T extends object> {
    private spyMap: SpyMap = Object.create(null);
    private valueMap: ValueMap = Object.create(null);
    public handler = {
        get: (target: T, propertyName: keyof T, receiver) => {
                // trying to get a property, return value from valueMap.
                if (typeof this.prototype[propertyName] !== 'function') {
                    return this.valueMap[propertyName];
                }

                // trying to get a function, if we haven't created the spy, create one
                if (!this.spyMap[propertyName]) {
                    const spy = jasmine.createSpy(propertyName);
                    this.spyMap[propertyName] = spy;
                }

                return this.spyMap[propertyName];
        },
        // store whatever user wants in the value map
        set: (target, propertyName: keyof T, value, receiver) => {
            if (typeof this.prototype[propertyName] === 'function') {
                throw Error(`Assignment not allowed because ${propertyName} is already a spied function`);
            }

            this.valueMap[propertyName] = value;
            return true;
        },
    };

    constructor(private prototype: T) {}
}

export class MockFactory {
    /**
     * create a mock object that has the identical interface with the class you passed in
     */
    public static create<T extends object>(blueprint: Type<T> | T) {
        let prototype: T;
        if (blueprint['prototype']) {
            prototype = blueprint['prototype'];
        } else {
            prototype = blueprint as T;
        }

        const mockBase = new DynamicMockBase(prototype);
        return new Proxy<T>(mockBase as any as T, mockBase.handler);
    }
}

{'fraction_non_alphanumeric': 0.10453049860794736, 'fraction_numerical': 0.0, 'mean_word_length': 2.047031611410948, 'pattern_counts': {'":': 0, '<': 13, '<?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': '5784651', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1023, 'n_words': 327}