Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@jiayouzuo/shared-js

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jiayouzuo/shared-js

通用JavaScript工具函数库

latest
npmnpm
Version
1.0.9
Version published
Maintainers
1
Created
Source

@jiayouzuo/shared-js

通用 JavaScript 工具函数库,支持 ESM / CommonJS / UMD。

安装

npm install @jiayouzuo/shared-js

功能模块

模块说明
httpHTTP 请求封装(拦截器、重试、取消)
timer定时器工具(rafTimeout、idleCallback)
format格式化工具(数值、日期、中文大写金额)
validate验证工具(类型判断、格式校验)
uid唯一ID生成(uuid、雪花ID、时间戳ID)
wsWebSocket 封装(自动重连、心跳)
safe安全函数(JSON、Storage、属性访问)
workerWeb Worker 封装(内联函数、Promise 化)
transportWebTransport 封装(HTTP/3、双向流、数据报)

快速使用

import {
  http,              // HTTP 客户端
  formatDate,        // 日期格式化
  isEmptyValue,      // 空值判断
  uuid,              // UUID 生成
  safeLocalStorage,  // 安全 localStorage
  createWebSocket,   // WebSocket 客户端
  runInWorker        // Worker 执行
} from '@jiayouzuo/shared-js'

// HTTP 请求
const users = await http.get('/api/users')

// 日期格式化
formatDate(new Date(), 'YYYY-MM-DD HH:mm:ss')

// 空值判断
isEmptyValue(null)  // true
isEmptyValue('')    // true
isEmptyValue([])    // true

// UUID
uuid()  // 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'

// 安全存储
safeLocalStorage.set('user', { name: '张三' })
safeLocalStorage.get('user')  // { name: '张三' }

// Worker 执行(不阻塞主线程)
const sum = await runInWorker(
  (nums) => nums.reduce((a, b) => a + b, 0),
  [1, 2, 3, 4, 5]
)  // 15

License

MIT

Keywords

utils

FAQs

Package last updated on 04 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts