Skip to content

Instantly share code, notes, and snippets.

View alanwhy's full-sized avatar
💻
@seeway.ai

alanwhy

💻
@seeway.ai
View GitHub Profile
@alanwhy
alanwhy / stack.js
Last active November 23, 2025 06:33
算法-栈的使用
// 实现一个栈类
class Stack {
constructor() {
this.items = [];
}
// 入栈
push(element) {
this.items.push(element);
}
@alanwhy
alanwhy / WebSocketManager.js
Last active November 23, 2025 06:18
websocket 的封装
// https://juejin.cn/post/7325317637074960420
// WebSocket对象的创建
// WebSocket对象的关闭
// 启用心跳机制,避免断连
// 消息推送,接收到消息后进行业务逻辑处理
// 重连机制,如果断连后尝试一定次数的重连,超过最大次数后仍然失败则关闭连接
export default class WebSocketManager {