<commit_before>import {Disposable} from "event-kit";
import Emitter from "../utils/emitter";
import SocketIOSocket from "./socket";

export default class Namespace {
    constructor(nsp) {
        this._emitter = new Emitter();
        this._nsp = nsp;
    }

    _handleConnection(socket) {
        this._emitter.on("connect", socket => {
            const wrappedSocket = new SocketIOSocket(wrappedSocket);
            this._emitter.emit("connect", wrappedSocket);
            this._emitter.emit("connection", wrappedSocket);
        });
    }

    _handleEvents() {
        const onConnect = socket => {
            const wrappedSocket = new SocketIOSocket(wrappedSocket);
            this._emitter.emit("connect", this);
        };;

        this._socket.on("connect", onConnect);
        this._socket.on("connection", onConnection);
    }

    dispose() {
        this._emitter.dispose();
    }


    get rawNamespace() {
        return this._nsp;
    }

    get name() {
        return this._nsp.name;
    }

    get connected() {
        return this._nsp.connected;
    }

    get json() {
        return this._nsp.json;
    }

    get volatile() {
        return this._nsp.volatile;
    }


    /**
     * @return {Promise}
     */
    clients() {
        return new Promise((resolve, reject) => {
            this._nsp.clients(clients => resolve(clients));
        });
    }

    compress(compress) {
        this._nsp.compress(compress);
        return this;
    }

    use(fn) {
        this._nsp.use(fn)
        return this;
    }


    receive(event, handler) {
        this._nsp.on(event, handler);
        return this;
    }

    offReceive(event, handler) {
        this._nsp.removeListener(event, handler);
        return this;
    }

    emit(...args) {
        this._nsp.emit(...args);
        return this;
    }


    send(...args) {
        this._nsp.send(...args);
        return this;
    }

    write(...args) {
        return this.send(...args);
    }


    to(name) {<commit_msg>Fix missing implement `on`, `off`<commit_after>import {Disposable} from "event-kit";
import Emitter from "../utils/emitter";
import SocketIOSocket from "./socket";

export default class Namespace {
    constructor(nsp) {
        this._emitter = new Emitter();
        this._nsp = nsp;
    }

    _handleConnection(socket) {
        this._emitter.on("connect", socket => {
            const wrappedSocket = new SocketIOSocket(wrappedSocket);
            this._emitter.emit("connect", wrappedSocket);
            this._emitter.emit("connection", wrappedSocket);
        });
    }

    _handleEvents() {
        const onConnect = socket => {
            const wrappedSocket = new SocketIOSocket(wrappedSocket);
            this._emitter.emit("connect", this);
        };;

        this._socket.on("connect", onConnect);
        this._socket.on("connection", onConnection);
    }

    dispose() {
        this._emitter.dispose();
    }


    get rawNamespace() {
        return this._nsp;
    }

    get name() {
        return this._nsp.name;
    }

    get connected() {
        return this._nsp.connected;
    }

    get json() {
        return this._nsp.json;
    }

    get volatile() {
        return this._nsp.volatile;
    }


    /**
     * @return {Promise}
     */
    clients() {
        return new Promise((resolve, reject) => {
            this._nsp.clients(clients => resolve(clients));
        });
    }

    compress(compress) {
        this._nsp.compress(compress);
        return this;
    }

    use(fn) {
        this._nsp.use(fn)
        return this;
    }


    on(event, handler, thisArg = null) {
        return this._emitter.on(event, handler, thisArg || this);
    }

    off(event, handler, thisArg = null) {
        return this._emitter.off(event, handler, thisArg || this);
    }


    receive(event, handler) {
        this._nsp.on(event, handler);
        return this;
    }

    offReceive(event, handler) {
        this._nsp.removeListener(event, handler);
        return this;
    }

    emit(...args) {
        this._nsp.emit(...args);
        return this;
    }


    send(...args) {
        this._nsp.send(...args);
        return this;
    }

    write(...args) {
        return this.send(...args);
    }


    to(name) {
{'fraction_non_alphanumeric': 0.13823046233278574, 'fraction_numerical': 0.0, 'mean_word_length': 1.8527443105756358, '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': '4880198', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1266, 'n_words': 242}