npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@skillnull/webeesocket

v0.1.5

Published

通过事件驱动机制 EventEmitter 对 Websocket 和微信 connectSocket 进行集成封装

Downloads

3

Readme

通过事件驱动机制 EventEmitter 对 Websocket 和微信 connectSocket 进行集成封装

CDN

使用 UMD 格式
<script src="https://www.unpkg.com/@skillnull/[email protected]/dist/WebEESocket.js"></script>
# or
<script src="https://cdn.jsdelivr.net/npm/@skillnull/[email protected]/dist/WebEESocket.js"></script>

使用 ES 格式
<script src="https://www.unpkg.com/@skillnull/[email protected]/dist/WebEESocket.es.js"></script>
# or
<script src="https://cdn.jsdelivr.net/npm/@skillnull/[email protected]/dist/WebEESocket.es.js"></script>

安装

yarn add @skillnull/webeesocket

# or with npm

npm install @skillnull/webeesocket

使用

// 使用 CDN 引用时,无需 import 
import { WEBSOCKET } from '@skillnull/webeesocket'

/**
 * @params: {
 *   url: <String> 服务器连接地址
 *   auth: <Any> 服务器认证信息
 *   heartbeat?: <Any> 心跳握手内容
 *   heartbeat_time?: <Any> 心跳握手间隔,默认30000ms,heartbeat 传值此项才会生效
 *   protocol?: <String | String[]> 协议
 *   reconnect_step?: <Number> 重连间隔,不传默认 1000,传 -1 表示不重连
 * }
 */
this.WEBSOCKET = new WEBSOCKET({ 
  url: "your socket server url",
  auth: {
    // server need auth info
  },
  heartbeat: {
    // heartbeat need info
  },
  heartbeat_time: 30000,
  protocol: "protocol for websocket",
  reconnect_step: 1000
})

/**
 * code: 与服务端约定的用于监听的 code
 */
this.WEBSOCKET.on(code, (data) => {
  // handler data
})

/**
 * 订阅
 * @data: {
 *   key: <String> 用于缓存和退订,需保证唯一和可回溯
 *   body: <Any> 服务端需要的,订阅的具体参数,默认将进行 JSON.stringify
 *   not_stringify?: <Boolean> 是否取消将参数 body 进行 JSON.stringify,默认 false
 * }
 */
this.WEBSOCKET.subscribe({
  key: "require",
  body: "require",
  not_stringify: "not require"
})

/**
 * 退订
 * @data: {
 *   key: <String> 订阅时传的 key
 *   body?: <Any> 其他参数,会合并到订阅时缓存的 body 上,默认将合并后的 body 进行 JSON.stringify
 *   not_stringify?: <Boolean> 是否取消将合并后的参数 body 进行 JSON.stringify,默认 false
 * }
 */
this.WEBSOCKET.unsubscribe({
  key: "require", 
  body: "require", 
  not_stringify: "not require"
})