repo stringlengths 7 64 | file_url stringlengths 81 338 | file_path stringlengths 5 257 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:25:31 2026-01-05 01:50:38 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/express-session-example/ts/index.ts | examples/express-session-example/ts/index.ts | import express = require("express");
import { createServer } from "http";
import { Server } from "socket.io";
import session from "express-session";
import { type Request } from "express";
declare module "express-session" {
interface SessionData {
count: number;
}
}
const port = process.env.PORT || 3000;
con... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/server.ts | examples/angular-todomvc/server.ts | import { Server } from "socket.io";
const io = new Server(8080, {
cors: {
origin: "http://localhost:4200",
methods: ["GET", "POST"]
}
});
interface Todo {
completed: boolean;
editing: boolean;
title: string;
}
let todos: Array<Todo> = [];
io.on("connection", (socket) => {
socket.emit("todos", ... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/src/test.ts | examples/angular-todomvc/src/test.ts | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare ... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/src/polyfills.ts | examples/angular-todomvc/src/polyfills.ts | /**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/src/main.ts | examples/angular-todomvc/src/main.ts | import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapMod... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/src/app/app.component.spec.ts | examples/angular-todomvc/src/app/app.component.spec.ts | import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
});
it('should create the app', ()... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/src/app/app.component.ts | examples/angular-todomvc/src/app/app.component.ts | import { Component } from '@angular/core';
import { RemoteTodoStore, Todo } from './store';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
todoStore: RemoteTodoStore;
newTodoText = '';
constructor(todoStore: RemoteT... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/src/app/app.module.ts | examples/angular-todomvc/src/app/app.module.ts | import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { RemoteTodoStore } from './store';
import { FormsModule } from "@angular/forms";
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModu... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/src/app/store.ts | examples/angular-todomvc/src/app/store.ts | import { io, Socket } from "socket.io-client";
export class Todo {
completed: boolean;
editing: boolean;
private _title: String = "";
get title() {
return this._title;
}
set title(value: String) {
this._title = value.trim();
}
constructor(title: String) {
this.completed = false;
this.... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/src/environments/environment.ts | examples/angular-todomvc/src/environments/environment.ts | // This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
};
/*
* For easier debugging in development mod... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/src/environments/environment.prod.ts | examples/angular-todomvc/src/environments/environment.prod.ts | export const environment = {
production: true
};
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/e2e/src/app.po.ts | examples/angular-todomvc/e2e/src/app.po.ts | import { browser, by, element } from 'protractor';
export class AppPage {
async navigateTo(): Promise<unknown> {
return browser.get(browser.baseUrl);
}
async getTitleText(): Promise<string> {
return element(by.css('app-root .content span')).getText();
}
}
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/angular-todomvc/e2e/src/app.e2e-spec.ts | examples/angular-todomvc/e2e/src/app.e2e-spec.ts | import { AppPage } from './app.po';
import { browser, logging } from 'protractor';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', async () => {
await page.navigateTo();
expect(await page.getTitleText()... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/typescript-client-example/esm/client.ts | examples/typescript-client-example/esm/client.ts | import { io, type Socket } from "socket.io-client";
interface ServerToClientEvents {
hello: (val: string) => void;
}
interface ClientToServerEvents {
ping: (cb: () => void) => void;
}
const socket: Socket<ServerToClientEvents, ClientToServerEvents> = io("ws://localhost:8080/");
socket.on("connect", () => {
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/typescript-client-example/cjs/client.ts | examples/typescript-client-example/cjs/client.ts | import { io, type Socket } from "socket.io-client";
interface ServerToClientEvents {
hello: (val: string) => void;
}
interface ClientToServerEvents {
ping: (cb: () => void) => void;
}
const socket: Socket<ServerToClientEvents, ClientToServerEvents> = io("ws://localhost:8080/");
socket.on("connect", () => {
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/ReactNativeExample/App.tsx | examples/ReactNativeExample/App.tsx | /**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React from 'react';
import type {PropsWithChildren} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';
import { socket } from './sock... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/ReactNativeExample/__tests__/App.test.tsx | examples/ReactNativeExample/__tests__/App.test.tsx | /**
* @format
*/
import 'react-native';
import React from 'react';
import App from '../App';
// Note: import explicitly to use the types shipped with jest.
import {it} from '@jest/globals';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctl... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/passport-jwt-example/ts/index.ts | examples/passport-jwt-example/ts/index.ts | import express from "express";
import { type Request, type Response } from "express";
import { createServer } from "node:http";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import passport from "passport";
import { Strategy as JwtStrategy, ExtractJwt } from "passport-jwt";
import... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/typescript-example/esm/client.ts | examples/typescript-example/esm/client.ts | import { io } from "socket.io-client";
const socket = io("ws://localhost:8080/", {});
socket.on("connect", () => {
console.log(`connect ${socket.id}`);
});
socket.on("disconnect", () => {
console.log(`disconnect`);
});
setInterval(() => {
const start = Date.now();
socket.emit("ping", () => {
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/typescript-example/esm/server.ts | examples/typescript-example/esm/server.ts | import { Server } from "socket.io";
const io = new Server(8080);
io.on("connection", (socket) => {
console.log(`connect ${socket.id}`);
socket.on("ping", (cb) => {
console.log("ping");
cb();
});
socket.on("disconnect", () => {
console.log(`disconnect ${socket.id}`);
});
}... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/typescript-example/cjs/client.ts | examples/typescript-example/cjs/client.ts | import { io } from "socket.io-client";
const socket = io("ws://localhost:8080/", {});
socket.on("connect", () => {
console.log(`connect ${socket.id}`);
});
socket.on("disconnect", () => {
console.log(`disconnect`);
});
setInterval(() => {
const start = Date.now();
socket.emit("ping", () => {
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/typescript-example/cjs/server.ts | examples/typescript-example/cjs/server.ts | import { Server } from "socket.io";
const io = new Server(8080);
io.on("connection", (socket) => {
console.log(`connect ${socket.id}`);
socket.on("ping", (cb) => {
console.log("ping");
cb();
});
socket.on("disconnect", () => {
console.log(`disconnect ${socket.id}`);
});
}... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/common/events.ts | examples/basic-crud-application/common/events.ts | export type TodoID = string;
export interface Todo {
id: TodoID;
completed: boolean;
title: string;
}
interface Error {
error: string;
errorDetails?: {
message: string;
path: Array<string | number>;
type: string;
}[];
}
interface Success<T> {
data: T;
}
export type Response<T> = Error | Su... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/angular-client/src/main.ts | examples/basic-crud-application/angular-client/src/main.ts | import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, appConfig)
.catch((err) => console.error(err));
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/angular-client/src/app/app.config.ts | examples/basic-crud-application/angular-client/src/app/app.config.ts | import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [provideRouter(routes)]
};
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/angular-client/src/app/app.component.spec.ts | examples/basic-crud-application/angular-client/src/app/app.component.spec.ts | import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppComponent],
}).compileComponents();
});
it('should create the app', () => {
const fixtu... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/angular-client/src/app/app.component.ts | examples/basic-crud-application/angular-client/src/app/app.component.ts | import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterOutlet } from '@angular/router';
import {type Todo, TodoStore} from "./store";
import { FormControl, ReactiveFormsModule } from '@angular/forms';
@Component({
selector: 'app-root',
standalone: true,
imports:... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/angular-client/src/app/app.routes.ts | examples/basic-crud-application/angular-client/src/app/app.routes.ts | import { Routes } from '@angular/router';
export const routes: Routes = [];
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/angular-client/src/app/store.ts | examples/basic-crud-application/angular-client/src/app/store.ts | import { io, Socket } from "socket.io-client";
import { ClientEvents, ServerEvents } from "../../../common/events";
import { environment } from '../environments/environment';
import {Injectable} from "@angular/core";
export interface Todo {
id: string,
title: string,
completed: boolean,
editing: boolean,
syn... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/angular-client/src/environments/environment.development.ts | examples/basic-crud-application/angular-client/src/environments/environment.development.ts | export const environment = {
serverUrl: "http://localhost:3000"
};
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/angular-client/src/environments/environment.ts | examples/basic-crud-application/angular-client/src/environments/environment.ts | export const environment = {
serverUrl: "https://my-custom-domain.com"
};
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/server/test/todo-management/todo.tests.ts | examples/basic-crud-application/server/test/todo-management/todo.tests.ts | import { createApplication } from "../../lib/app";
import { createServer, Server } from "http";
import {
InMemoryTodoRepository,
TodoRepository,
} from "../../lib/todo-management/todo.repository";
import { AddressInfo } from "net";
import { io, Socket } from "socket.io-client";
import { ClientEvents, ServerEvents }... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/server/lib/util.ts | examples/basic-crud-application/server/lib/util.ts | import { ValidationErrorItem } from "joi";
export enum Errors {
ENTITY_NOT_FOUND = "entity not found",
INVALID_PAYLOAD = "invalid payload",
}
const errorValues: string[] = Object.values(Errors);
export function sanitizeErrorMessage(message: any) {
if (typeof message === "string" && errorValues.includes(message... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/server/lib/app.ts | examples/basic-crud-application/server/lib/app.ts | import { Server as HttpServer } from "http";
import { Server, ServerOptions } from "socket.io";
import { ClientEvents, ServerEvents } from "../../common/events";
import { TodoRepository } from "./todo-management/todo.repository";
import createTodoHandlers from "./todo-management/todo.handlers";
export interface Compon... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/server/lib/index.ts | examples/basic-crud-application/server/lib/index.ts | import { createServer } from "http";
import { createApplication } from "./app";
import { InMemoryTodoRepository } from "./todo-management/todo.repository";
const httpServer = createServer();
createApplication(
httpServer,
{
todoRepository: new InMemoryTodoRepository(),
},
{
cors: {
origin: ["htt... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/server/lib/todo-management/todo.handlers.ts | examples/basic-crud-application/server/lib/todo-management/todo.handlers.ts | import { Errors, mapErrorDetails, sanitizeErrorMessage } from "../util";
import { v4 as uuid } from "uuid";
import { Components } from "../app";
import Joi = require("joi");
import {
Todo,
TodoID,
ClientEvents,
Response,
ServerEvents,
} from "../../../common/events";
import { Socket } from "socket.io";
const... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/examples/basic-crud-application/server/lib/todo-management/todo.repository.ts | examples/basic-crud-application/server/lib/todo-management/todo.repository.ts | import { Errors } from "../util";
import { Todo, TodoID } from "../../../common/events";
abstract class CrudRepository<T, ID> {
abstract findAll(): Promise<T[]>;
abstract findById(id: ID): Promise<T>;
abstract save(entity: T): Promise<void>;
abstract deleteById(id: ID): Promise<void>;
}
export abstract class ... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/test/browser.ts | packages/engine.io-parser/test/browser.ts | import {
decodePacket,
decodePayload,
encodePacket,
encodePayload,
createPacketEncoderStream,
createPacketDecoderStream,
Packet,
} from "..";
import expect = require("expect.js");
import { areArraysEqual, createArrayBuffer } from "./util";
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/test/util.ts | packages/engine.io-parser/test/util.ts | const areArraysEqual = (x, y) => {
if (x.byteLength !== y.byteLength) return false;
const xView = new Uint8Array(x),
yView = new Uint8Array(y);
for (let i = 0; i < x.byteLength; i++) {
if (xView[i] !== yView[i]) return false;
}
return true;
};
const createArrayBuffer = (array) => {
// Uint8Array.fr... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/test/index.ts | packages/engine.io-parser/test/index.ts | import {
createPacketDecoderStream,
createPacketEncoderStream,
decodePacket,
decodePayload,
encodePacket,
encodePayload,
Packet,
} from "..";
import expect = require("expect.js");
import { areArraysEqual } from "./util";
import "./node"; // replaced by "./browser" for the tests in the browser (see "brows... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/test/node.ts | packages/engine.io-parser/test/node.ts | import {
decodePacket,
decodePayload,
encodePacket,
encodePayload,
Packet,
createPacketDecoderStream,
createPacketEncoderStream,
} from "..";
import expect = require("expect.js");
import { areArraysEqual } from "./util";
describe("engine.io-parser (node.js only)", () => {
describe("single packet", () =... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/lib/encodePacket.browser.ts | packages/engine.io-parser/lib/encodePacket.browser.ts | import { PACKET_TYPES, Packet, RawData } from "./commons.js";
const withNativeBlob =
typeof Blob === "function" ||
(typeof Blob !== "undefined" &&
Object.prototype.toString.call(Blob) === "[object BlobConstructor]");
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
// ArrayBuffer.isView method... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/lib/decodePacket.ts | packages/engine.io-parser/lib/decodePacket.ts | import {
ERROR_PACKET,
PACKET_TYPES_REVERSE,
Packet,
BinaryType,
RawData,
} from "./commons.js";
export const decodePacket = (
encodedPacket: RawData,
binaryType?: BinaryType,
): Packet => {
if (typeof encodedPacket !== "string") {
return {
type: "message",
data: mapBinary(encodedPacket... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/lib/encodePacket.ts | packages/engine.io-parser/lib/encodePacket.ts | import { PACKET_TYPES, Packet, RawData } from "./commons.js";
export const encodePacket = (
{ type, data }: Packet,
supportsBinary: boolean,
callback: (encodedPacket: RawData) => void,
) => {
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
return callback(
supportsBinary ? data : "b" +... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/lib/commons.ts | packages/engine.io-parser/lib/commons.ts | const PACKET_TYPES = Object.create(null); // no Map = no polyfill
PACKET_TYPES["open"] = "0";
PACKET_TYPES["close"] = "1";
PACKET_TYPES["ping"] = "2";
PACKET_TYPES["pong"] = "3";
PACKET_TYPES["message"] = "4";
PACKET_TYPES["upgrade"] = "5";
PACKET_TYPES["noop"] = "6";
const PACKET_TYPES_REVERSE = Object.create(null);
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/lib/index.ts | packages/engine.io-parser/lib/index.ts | import { encodePacket, encodePacketToBinary } from "./encodePacket.js";
import { decodePacket } from "./decodePacket.js";
import {
Packet,
PacketType,
RawData,
BinaryType,
ERROR_PACKET,
} from "./commons.js";
const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_deli... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/lib/decodePacket.browser.ts | packages/engine.io-parser/lib/decodePacket.browser.ts | import {
ERROR_PACKET,
PACKET_TYPES_REVERSE,
Packet,
BinaryType,
RawData,
} from "./commons.js";
import { decode } from "./contrib/base64-arraybuffer.js";
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
export const decodePacket = (
encodedPacket: RawData,
binaryType?: BinaryType,
): Pa... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io-parser/lib/contrib/base64-arraybuffer.ts | packages/engine.io-parser/lib/contrib/base64-arraybuffer.ts | // imported from https://github.com/socketio/base64-arraybuffer
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use a lookup table to find the index.
const lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
for (let i = 0; i < chars.length; i++) {
lookup[cha... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/connection.ts | packages/socket.io-client/test/connection.ts | import expect = require("expect.js");
import { io, Manager, ManagerOptions } from "..";
import hasCORS from "has-cors";
import { install } from "@sinonjs/fake-timers";
import textBlobBuilder from "text-blob-builder";
import { BASE_URL, wrap } from "./support/util";
import { nextTick } from "engine.io-client";
describe... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/retry.ts | packages/socket.io-client/test/retry.ts | import expect = require("expect.js");
import { io } from "..";
import { wrap, BASE_URL, success } from "./support/util";
describe("retry", () => {
it("should preserve the order of the packets", () => {
return wrap((done) => {
const socket = io(BASE_URL, {
forceNew: true,
retries: 1,
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/url.ts | packages/socket.io-client/test/url.ts | import { url } from "../build/cjs/url";
import expect = require("expect.js");
const loc: any = {};
describe("url", () => {
it("works with undefined", () => {
loc.hostname = "woot.com";
loc.protocol = "https:";
loc.port = 4005;
loc.host = loc.hostname + ":" + loc.port;
const parsed = url(undefine... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/connection-state-recovery.ts | packages/socket.io-client/test/connection-state-recovery.ts | import expect = require("expect.js");
import { io } from "..";
import { wrap, BASE_URL, success } from "./support/util";
describe("connection state recovery", () => {
it("should have an accessible socket id equal to the server-side socket id (default namespace)", () => {
return wrap((done) => {
const socke... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/typed-events.test-d.ts | packages/socket.io-client/test/typed-events.test-d.ts | import { io, Socket } from "..";
import type { DefaultEventsMap } from "@socket.io/component-emitter";
import { expectError, expectType } from "tsd";
// This file is run by tsd, not mocha.
describe("init", () => {
io();
io("https://example.com");
io({
forceNew: true,
});
io("https://example.com", {
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/browser-runner.ts | packages/socket.io-client/test/browser-runner.ts | import { Launcher } from "@wdio/cli";
import { createServer } from "./support/server";
const launcher = new Launcher("./wdio.conf.js");
async function run() {
const server = createServer();
try {
const exitCode = await launcher.run();
server.close();
process.exit(exitCode);
} catch (e) {
consol... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/index.ts | packages/socket.io-client/test/index.ts | import "./url";
import "./connection";
import "./socket";
import "./node";
import "./connection-state-recovery";
import "./retry";
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/socket.ts | packages/socket.io-client/test/socket.ts | import expect = require("expect.js");
import { io } from "..";
import { wrap, BASE_URL, success } from "./support/util";
describe("socket", () => {
it("should have an accessible socket id equal to the server-side socket id (default namespace)", () => {
return wrap((done) => {
const socket = io(BASE_URL, { ... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/node.ts | packages/socket.io-client/test/node.ts | const path = require("path");
const { exec } = require("child_process");
describe("autoUnref option", function () {
before(function () {
if (process.env.WDIO_WORKER_ID !== undefined) {
return this.skip();
}
});
const fixture = (filename) =>
process.execPath + " " + path.join(__dirname, "fixtur... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/support/util.ts | packages/socket.io-client/test/support/util.ts | /**
* This is needed because webdriver.io does not support mocha async mode:
*
* ```
* it("works", (done) => {
* done(); // does not work
* });
* ```
*
* @see https://webdriver.io/docs/frameworks/#using-mocha
* @param fn
*/
export function wrap(fn: (done: (err?: Error) => void) => void) {
let once = true... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/support/server.ts | packages/socket.io-client/test/support/server.ts | import { Server } from "socket.io";
import expect = require("expect.js");
export function createServer() {
const server = new Server(3210, {
pingInterval: 2000,
connectionStateRecovery: {},
allowRequest: (req, callback) => {
// add a fixed delay to test the connection timeout on the client side
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/support/hooks.ts | packages/socket.io-client/test/support/hooks.ts | import { createServer } from "./server";
let server;
export const mochaHooks = {
beforeAll() {
server = createServer();
},
afterAll() {
server.close();
},
};
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/fixtures/unref-polling-only.ts | packages/socket.io-client/test/fixtures/unref-polling-only.ts | const { io } = require("../..");
const socket = io("http://localhost:3210", {
autoUnref: true,
transports: ["polling"],
});
socket.on("open", () => {
console.log("open");
});
setTimeout(() => {
console.log("process should exit now");
}, 50);
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/fixtures/unref.ts | packages/socket.io-client/test/fixtures/unref.ts | const { io } = require("../..");
const socket = io("http://localhost:3210", {
autoUnref: true,
});
socket.on("open", () => {
console.log("open");
});
setTimeout(() => {
console.log("process should exit now");
}, 50);
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/fixtures/no-unref.ts | packages/socket.io-client/test/fixtures/no-unref.ts | const { io } = require("../..");
const socket = io("http://localhost:3211", {
autoUnref: false,
});
setTimeout(() => {
console.log("process should not exit");
}, 50);
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/fixtures/unref-websocket-only.ts | packages/socket.io-client/test/fixtures/unref-websocket-only.ts | const { io } = require("../..");
const socket = io("http://localhost:3210", {
autoUnref: true,
transports: ["websocket"],
});
socket.on("open", () => {
console.log("open");
});
setTimeout(() => {
console.log("process should exit now");
}, 50);
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/test/fixtures/unref-during-reconnection.ts | packages/socket.io-client/test/fixtures/unref-during-reconnection.ts | const { io } = require("../..");
const socket = io("http://localhost:3211", {
autoUnref: true,
});
socket.on("open", () => {
console.log("open");
});
setTimeout(() => {
console.log("process should exit now");
}, 50);
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/lib/on.ts | packages/socket.io-client/lib/on.ts | import { Emitter } from "@socket.io/component-emitter";
export function on(
obj: Emitter<any, any>,
ev: string,
fn: (err?: any) => any,
): VoidFunction {
obj.on(ev, fn);
return function subDestroy(): void {
obj.off(ev, fn);
};
}
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/lib/url.ts | packages/socket.io-client/lib/url.ts | import { parse } from "engine.io-client";
import debugModule from "debug"; // debug()
const debug = debugModule("socket.io-client:url"); // debug()
type ParsedUrl = {
source: string;
protocol: string;
authority: string;
userInfo: string;
user: string;
password: string;
host: string;
port: string;
re... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/lib/manager.ts | packages/socket.io-client/lib/manager.ts | import {
Socket as Engine,
SocketOptions as EngineOptions,
installTimerFunctions,
nextTick,
} from "engine.io-client";
import { Socket, SocketOptions, DisconnectDescription } from "./socket.js";
import * as parser from "socket.io-parser";
import { Decoder, Encoder, Packet } from "socket.io-parser";
import { on ... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/lib/browser-entrypoint.ts | packages/socket.io-client/lib/browser-entrypoint.ts | import { io } from "./index.js";
export default io;
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/lib/index.ts | packages/socket.io-client/lib/index.ts | import { url } from "./url.js";
import { Manager, ManagerOptions } from "./manager.js";
import { DisconnectDescription, Socket, SocketOptions } from "./socket.js";
import debugModule from "debug"; // debug()
const debug = debugModule("socket.io-client"); // debug()
/**
* Managers cache.
*/
const cache: Record<strin... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/lib/socket.ts | packages/socket.io-client/lib/socket.ts | import { Packet, PacketType } from "socket.io-parser";
import { on } from "./on.js";
import { Manager } from "./manager.js";
import {
DefaultEventsMap,
EventNames,
EventParams,
EventsMap,
Emitter,
} from "@socket.io/component-emitter";
import debugModule from "debug"; // debug()
const debug = debugModule("so... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-client/lib/contrib/backo2.ts | packages/socket.io-client/lib/contrib/backo2.ts | /**
* Initialize backoff timer with `opts`.
*
* - `min` initial timeout in milliseconds [100]
* - `max` max timeout [10000]
* - `jitter` [0]
* - `factor` [2]
*
* @param {Object} opts
* @api public
*/
export function Backoff(opts) {
opts = opts || {};
this.ms = opts.min || 100;
this.max = opts.max || 10... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-postgres-emitter/test/util.ts | packages/socket.io-postgres-emitter/test/util.ts | export function times(count: number, fn: () => void) {
let i = 0;
return () => {
i++;
if (i === count) {
fn();
}
};
}
export function sleep(duration: number) {
return new Promise((resolve) => setTimeout(resolve, duration));
}
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-postgres-emitter/test/index.ts | packages/socket.io-postgres-emitter/test/index.ts | import { createServer } from "http";
import { Server, Socket as ServerSocket } from "socket.io";
import { io as ioc, Socket as ClientSocket } from "socket.io-client";
import expect = require("expect.js");
import { createAdapter } from "@socket.io/postgres-adapter";
import type { AddressInfo } from "net";
import { Pool ... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-postgres-emitter/lib/typed-events.ts | packages/socket.io-postgres-emitter/lib/typed-events.ts | /**
* An events map is an interface that maps event names to their value, which
* represents the type of the `on` listener.
*/
export interface EventsMap {
[event: string]: any;
}
/**
* The default events map, used if no EventsMap is given. Using this EventsMap
* is equivalent to accepting all event names, and ... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-postgres-emitter/lib/index.ts | packages/socket.io-postgres-emitter/lib/index.ts | import debugModule from "debug";
import type {
DefaultEventsMap,
EventNames,
EventParams,
EventsMap,
TypedEventBroadcaster,
} from "./typed-events";
import { encode } from "@msgpack/msgpack";
const debug = debugModule("socket.io-postgres-emitter");
const EMITTER_UID = "emitter";
const hasBinary = (obj: any,... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-cluster-adapter/test/util.ts | packages/socket.io-cluster-adapter/test/util.ts | export function times(count: number, fn: () => void) {
let i = 0;
return () => {
i++;
if (i === count) {
fn();
}
};
}
export function sleep(duration: number) {
return new Promise((resolve) => setTimeout(resolve, duration));
}
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-cluster-adapter/test/index.ts | packages/socket.io-cluster-adapter/test/index.ts | import { io as ioc, Socket as ClientSocket } from "socket.io-client";
import expect = require("expect.js");
import { setupPrimary } from "..";
import { times, sleep } from "./util";
import cluster, { Worker } from "node:cluster";
const NODES_COUNT = 3;
cluster.setupMaster({
exec: "./test/worker.js",
// @ts-ignore... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-cluster-adapter/lib/index.ts | packages/socket.io-cluster-adapter/lib/index.ts | import cluster from "node:cluster";
import {
ClusterAdapterWithHeartbeat,
ClusterAdapterOptions,
ClusterMessage,
ServerId,
ClusterResponse,
MessageType,
} from "socket.io-adapter";
import debugModule from "debug";
const debug = debugModule("socket.io-cluster-adapter");
const MESSAGE_SOURCE = "_sio_adapter"... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/transport.ts | packages/engine.io/lib/transport.ts | import { EventEmitter } from "events";
import * as parser_v4 from "engine.io-parser";
import * as parser_v3 from "./parser-v3/index";
import debugModule from "debug";
import type { IncomingMessage, ServerResponse } from "http";
import { Packet, RawData } from "engine.io-parser";
import type { WebSocket } from "ws";
co... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/server.ts | packages/engine.io/lib/server.ts | import * as base64id from "base64id";
import transports from "./transports";
import { EventEmitter } from "events";
import { Socket } from "./socket";
import debugModule from "debug";
import { serialize } from "cookie";
import {
Server as DEFAULT_WS_ENGINE,
type Server as WsServer,
type PerMessageDeflateOptions,
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/socket.ts | packages/engine.io/lib/socket.ts | import { EventEmitter } from "events";
import debugModule from "debug";
import type { IncomingMessage } from "http";
import type { EngineRequest, Transport } from "./transport";
import type { BaseServer } from "./server";
import { setTimeout, clearTimeout } from "timers";
import type { Packet, PacketType, RawData } fro... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/userver.ts | packages/engine.io/lib/userver.ts | import debugModule from "debug";
import { AttachOptions, BaseServer, Server } from "./server";
import { HttpRequest, HttpResponse, TemplatedApp } from "uWebSockets.js";
import transports from "./transports-uws";
import { EngineRequest } from "./transport";
const debug = debugModule("engine:uws");
export interface uOp... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/engine.io.ts | packages/engine.io/lib/engine.io.ts | import { createServer, Server as HttpServer } from "http";
import { Server, AttachOptions, ServerOptions } from "./server";
import transports from "./transports/index";
import * as parser from "engine.io-parser";
export { Server, transports, listen, attach, parser };
export type {
AttachOptions,
ServerOptions,
B... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/transports-uws/websocket.ts | packages/engine.io/lib/transports-uws/websocket.ts | import { Transport } from "../transport";
import debugModule from "debug";
const debug = debugModule("engine:ws");
export class WebSocket extends Transport {
protected perMessageDeflate: any;
private socket: any;
/**
* WebSocket transport
*
* @param req
*/
constructor(req) {
super(req);
t... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/transports-uws/polling.ts | packages/engine.io/lib/transports-uws/polling.ts | import { Transport } from "../transport";
import { createGzip, createDeflate } from "zlib";
import * as accepts from "accepts";
import debugModule from "debug";
import { HttpRequest, HttpResponse } from "uWebSockets.js";
import type * as parser_v4 from "engine.io-parser";
import type * as parser_v3 from "../parser-v3/i... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/transports-uws/index.ts | packages/engine.io/lib/transports-uws/index.ts | import { Polling } from "./polling";
import { WebSocket } from "./websocket";
export default {
polling: Polling,
websocket: WebSocket,
};
| typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/contrib/types.cookie.ts | packages/engine.io/lib/contrib/types.cookie.ts | // imported from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b83cf9ef8b044e69f05b2a00aa7c6cb767a9acd2/types/cookie/index.d.ts (now deleted)
/**
* Basic HTTP cookie parser and serializer for HTTP servers.
*/
/**
* Additional serialization options
*/
export interface CookieSerializeOptions {
/**
* S... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/parser-v3/utf8.ts | packages/engine.io/lib/parser-v3/utf8.ts | /*! https://mths.be/utf8js v2.1.2 by @mathias */
var stringFromCharCode = String.fromCharCode;
// Taken from https://mths.be/punycode
function ucs2decode(string) {
var output = [];
var counter = 0;
var length = string.length;
var value;
var extra;
while (counter < length) {
value = string.charCodeAt(counter++... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/parser-v3/index.ts | packages/engine.io/lib/parser-v3/index.ts | // imported from https://github.com/socketio/engine.io-parser/tree/2.2.x
/**
* Module dependencies.
*/
var utf8 = require('./utf8');
/**
* Current protocol version.
*/
export const protocol = 3;
const hasBinary = (packets) => {
for (const packet of packets) {
if (packet.data instanceof ArrayBuffer || Arra... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/transports/websocket.ts | packages/engine.io/lib/transports/websocket.ts | import { EngineRequest, Transport } from "../transport";
import debugModule from "debug";
import type { Packet, RawData } from "engine.io-parser";
import type { PerMessageDeflateOptions, WebSocket as WsWebSocket } from "ws";
const debug = debugModule("engine:ws");
export class WebSocket extends Transport {
perMessa... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/transports/webtransport.ts | packages/engine.io/lib/transports/webtransport.ts | import { Transport } from "../transport";
import debugModule from "debug";
import { createPacketEncoderStream } from "engine.io-parser";
const debug = debugModule("engine:webtransport");
/**
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/WebTransport_API
*/
export class WebTransport extends Transport... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/transports/polling-jsonp.ts | packages/engine.io/lib/transports/polling-jsonp.ts | import { Polling } from "./polling";
import * as qs from "querystring";
import type { RawData } from "engine.io-parser";
const rDoubleSlashes = /\\\\n/g;
const rSlashes = /(\\)?\\n/g;
export class JSONP extends Polling {
private readonly head: string;
private readonly foot: string;
/**
* JSON-P polling tran... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/transports/polling.ts | packages/engine.io/lib/transports/polling.ts | import { EngineRequest, Transport } from "../transport";
import { createGzip, createDeflate } from "zlib";
import * as accepts from "accepts";
import debugModule from "debug";
import type { IncomingMessage, ServerResponse } from "http";
import type { Packet, RawData } from "engine.io-parser";
import type * as parser_v4... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/engine.io/lib/transports/index.ts | packages/engine.io/lib/transports/index.ts | import { Polling as XHR } from "./polling";
import { JSONP } from "./polling-jsonp";
import { WebSocket } from "./websocket";
import { WebTransport } from "./webtransport";
import type { EngineRequest } from "../transport";
export default {
polling,
websocket: WebSocket,
webtransport: WebTransport,
};
/**
* Po... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-adapter/test/cluster-adapter.ts | packages/socket.io-adapter/test/cluster-adapter.ts | import { createServer } from "http";
import { Server, Socket as ServerSocket } from "socket.io";
import { io as ioc, Socket as ClientSocket } from "socket.io-client";
import expect = require("expect.js");
import type { AddressInfo } from "net";
import { times, shouldNotHappen, sleep } from "./util";
import {
ClusterA... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-adapter/test/util.ts | packages/socket.io-adapter/test/util.ts | export function times(count: number, fn: () => void) {
let i = 0;
return () => {
i++;
if (i === count) {
fn();
} else if (i > count) {
throw new Error(`too many calls: ${i} instead of ${count}`);
}
};
}
export function shouldNotHappen(done) {
return () => done(new Error("should not ... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-adapter/test/index.ts | packages/socket.io-adapter/test/index.ts | import { Adapter, SessionAwareAdapter } from "../lib";
import expect = require("expect.js");
describe("socket.io-adapter", () => {
it("should add/remove sockets", () => {
const adapter = new Adapter({ server: { encoder: null } });
adapter.addAll("s1", new Set(["r1", "r2"]));
adapter.addAll("s2", new Set(... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-adapter/lib/cluster-adapter.ts | packages/socket.io-adapter/lib/cluster-adapter.ts | import { Adapter } from "./in-memory-adapter";
import type {
BroadcastFlags,
BroadcastOptions,
Room,
} from "./in-memory-adapter";
import { debug as debugModule } from "debug";
import { randomBytes } from "crypto";
const debug = debugModule("socket.io-adapter");
const EMITTER_UID = "emitter";
const DEFAULT_TIMEO... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
socketio/socket.io | https://github.com/socketio/socket.io/blob/9978574e4f1d4e21593497f94c40053cd0fff359/packages/socket.io-adapter/lib/index.ts | packages/socket.io-adapter/lib/index.ts | export {
SocketId,
PrivateSessionId,
Room,
BroadcastFlags,
BroadcastOptions,
Session,
Adapter,
SessionAwareAdapter,
} from "./in-memory-adapter";
export {
ClusterAdapter,
ClusterAdapterWithHeartbeat,
ClusterAdapterOptions,
ClusterMessage,
ClusterResponse,
MessageType,
ServerId,
Offset,
... | typescript | MIT | 9978574e4f1d4e21593497f94c40053cd0fff359 | 2026-01-04T15:28:10.329849Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.