New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ryy-utils

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ryy-utils

ryy utils package

latest
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

ryy-utils

项目简介

ryy 工具库,提供常用的JavaScript/TypeScript工具函数,包括防抖节流、深拷贝、时间处理、正则表达式验证、URL处理等实用功能,助力前端开发效率提升。

安装

# npm 安装
npm install ryy-utils

# yarn 安装
yarn add ryy-utils

# pnpm 安装
pnpm add ryy-utils

功能模块

1. 通用工具 (common)

  • debounce - 函数防抖,限制高频触发事件的执行频率
  • throttle - 函数节流,间隔指定时间执行一次函数
  • deepCopy - 深度拷贝对象/数组数据

2. 时间处理 (time)

  • formatDateTime - 格式化时间为指定格式
  • 其他时间相关工具函数

3. 正则表达式 (regx)

  • idCardNoReg - 身份证号验证正则
  • mobileReg - 手机号验证正则
  • moneyReg - 金额验证正则(最多两位小数)
  • urlReg - URL地址验证正则
  • emailReg - 邮箱验证正则

4. 其他工具模块

  • file - 文件处理相关工具
  • href - URL处理相关工具
  • http - HTTP请求相关工具

使用示例

防抖函数

import { debounce } from 'ryy-utils';

// 创建防抖处理的搜索函数
const debouncedSearch = debounce((query) => {
    console.log('搜索:', query);
    // 执行搜索逻辑
}, 500);

// 在输入事件中使用
inputElement.addEventListener('input', (e) => {
    debouncedSearch(e.target.value);
});

时间格式化

import { formatDateTime } from 'ryy-utils';

// 格式化当前时间
const now = new Date();
const formattedDate = formatDateTime(now, 'yyyy-MM-dd hh:mm:ss');
console.log(formattedDate); // 例如: 2023-10-15 14:30:25

// 格式化时间戳
const timestamp = 1634253600000;
const dateStr = formatDateTime(timestamp, 'yyyy/MM/dd');
console.log(dateStr); // 例如: 2021/10/15

正则验证

import { mobileReg, emailReg } from 'ryy-utils';

// 验证手机号
const isValidMobile = mobileReg.test('13812345678');
console.log(isValidMobile); // true

// 验证邮箱
const isValidEmail = emailReg.test('test@example.com');
console.log(isValidEmail); // true

许可证

本项目采用 ISC 许可证 - 查看 LICENSE 文件了解详情

FAQs

Package last updated on 12 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