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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ycts-tool

v1.0.12

Published

一些实用小工具

Downloads

58

Readme

项目简介

自己整理的一些常用小工具

引入项目

import $y from '@ycts/tool';
$y.getUid();

内置方法

  • 对象深拷贝
$y.copy({ ... });
  • JSON对象打印
$y.logs({ ... });
  • 获取唯一ID
$y.getUid();
  • 获取GET参数
$y.getQuery();
  • 本地存储相关(localStorage封装)
// 存储
$y.setLocalStore('name', value, time = 24);
// 获取
$y.getLocalStore('name');
// 删除
$y.deleteLocalStore('name');
  • 获取星期几
/**
 * @param { String | Date } dat 指定日期
 * @param { String } locale 国际化 [zh, en] = [中文, 英文]
 * @param { Boolean } short 是否返回简称
 */
$y.getWeekName();
  • 获取文字宽度
/**
 * @discription 获取文字宽度
 * @param { String } text 指定文本
 * @param { String } font 文本字体
 * @return { String } 文字宽度
 */
$y.getTextWidth();
  • 本地下载
/**
 * @discription 本地下载
 * @param { string | ArrayBuffer | ArrayBufferView | Blob } data 需要下载的对象
 * @param { String } name 保存的文件名称
 */
$y.downFile(data, name);
  • 文本复制功能
/**
 * @discription 文本复制功能
 * @param { String } text 需要复制的内容
 * @returns { Boolean } 复制成功或失败
 */
$y.copyText(text);
  • 图片预加载
/**
 * @discription 图片预加载
 * @param { String } src 需要加载的图片地址
 * @returns { Promise } 返回一个Promise对象
 */
$y.loadImage(src);
  • 图片文件转换为图片对象
/**
 * @discription 图片文件转换为图片对象
 * @param { Blob | Object } file 需要转换的图片文件
 * @returns { Promise } 返回一个Promise对象
 */
$y.loadFileImage(file);
  • 音频预加载
/**
 * @discription 音频预加载
 * @param { String } url 需要加载的音频文件
 * @returns { Promise } 返回一个Promise对象
 */
$y.loadAudio(url);
  • 获取随机数
/**
 * @discription 获取随机数
 * @param { Number } min 随机数区间最小值
 * @param { Number } max 随机数区间最大值
 * @returns { Number } 返回一随机数
 */
$y.getRandom(min, max);
  • 获取本地时区
$y.getUTC();
  • 数字前补位(00-09)
$y.fillNums(num);
  • 获取日期对象
/**
 * @discription 获取日期对象
 * @param { Date | String } dat 需要处理的日期 默认当前时间
 * @param { String } utc 将日期处理为指定时区 默认当前时区
 * @return { Object } 处理后的日期 { Y, M, D, h, m, s }
 */
$y.initDate();
  • 获取日期字符串
/**
 * @discription 获取日期字符串
 * @param { Date | String } dat 需要处理的日期 默认当前时间
 * @param { String } time 是否需要时分秒 默认true
 * @param { String } utc 将日期处理为指定时区 默认当前时区
 * @return { Object } 处理后的日期字符串 YYY-MM-DD hh:mm:ss
 */
$y.getDate();