<commit_before>import EventEmitter from 'events';
import path from 'path';
import {Server as WebSocketServer} from 'ws';
import {util, fileUtil} from "../../helper";

class Reloader extends EventEmitter {
    constructor(options) {
        super();
        Object.assign(this, options);
        this.bindChange();
        this.buildWebSocket();
    }
    bindChange() {
        let [server, watcher] = [this.server, this.watcher];

        let reloadResources = [
            path.resolve(server.viewRoot, '**', '*.' + server.extension),
            path.resolve(server.syncData, '**', '*.json')
        ];
        let reload = util.throttle((arg0) => {
            this.reload(arg0);
        }, 1000);
        server.static.forEach(item => {
            reloadResources.push(path.resolve(item, '**', '*.css'));
            reloadResources.push(path.resolve(item, '**', '*.js'));
        });

        this.watcher.onChange(reloadResources, (arg0, arg1) => {
            if (arg1 != 'add') {
                reload(arg0);
            }
        });
    }
    buildWebSocket() {
        let serverApp = this.server.serverApp;
        this.wss = new WebSocketServer({
            server: serverApp
        });

        this.wss.on('connection', (ws) => {
            ws.on('message', (message) => {
                console.log('received: %s', message);
            });
        });

        this.wss.broadcast = (data) => {
            this.wss.clients.forEach(function each(client) {<commit_msg>reload watch add *.html<commit_after>import EventEmitter from 'events';
import path from 'path';
import {Server as WebSocketServer} from 'ws';
import {util, fileUtil} from "../../helper";

class Reloader extends EventEmitter {
    constructor(options) {
        super();
        Object.assign(this, options);
        this.bindChange();
        this.buildWebSocket();
    }
    bindChange() {
        let [server, watcher] = [this.server, this.watcher];

        let reloadResources = [
            path.resolve(server.viewRoot, '**', '*.' + server.extension),
            path.resolve(server.syncData, '**', '*.json')
        ];
        let reload = util.throttle((arg0) => {
            this.reload(arg0);
        }, 1000);
        server.static.forEach(item => {
            reloadResources.push(path.resolve(item, '**', '*.css'));
            reloadResources.push(path.resolve(item, '**', '*.js'));
            reloadResources.push(path.resolve(item, '**', '*.html'));
        });

        this.watcher.onChange(reloadResources, (arg0, arg1) => {
            if (arg1 != 'add') {
                reload(arg0);
            }
        });
    }
    buildWebSocket() {
        let serverApp = this.server.serverApp;
        this.wss = new WebSocketServer({
            server: serverApp
        });

        this.wss.on('connection', (ws) => {
            ws.on('message', (message) => {
                console.log('received: %s', message);
            });
        });

        this.wss.broadcast = (data) => {
            this.wss.clients.forEach(function each(client) {
{'fraction_non_alphanumeric': 0.16623122142390595, 'fraction_numerical': 0.006531678641410843, 'mean_word_length': 1.982473222979552, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '7200710', 'n_tokens_mistral': 915, 'n_tokens_neox': 882, 'n_words': 161}