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

vh-plugin

v1.2.1

Published

轻量级JS插件包

Downloads

195

Readme

Han 的 JS 插件库

Team front end tool library

npm version GitHub issues GitHub forks GitHub stars GitHub license

Browser Support

| Chrome | Firefox | Safari | Opera | Edge | IE | | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |

USE

Mode 1

Using jsDelivr CDN (ES5 UMD browser module):

<script src="//cdn.jsdelivr.net/npm/vh-plugin@latest/dist/vh-plugin.min.js"></script>
<!-- <script src="//unpkg.com/vh-plugin@latest/dist/vh-plugin.min.js"></script> -->
<script>
  console.log(vh);
</script>

Mode 2

<script type="module">
  import vh = '../dist/vh-plugin.esm.js';
</script>

Mode 3 Installing

Package manager

Using npm:

$ npm install vh-plugin

Using yarn:

$ yarn add vh-plugin
import vh from "vh-plugin";

Example

/**
 * 显示Toast消息提示框
 * @param {string} text - 提示框内容,必填项。
 * @param {number} duration - 提示框存在时长,默认值为1666毫秒,非必填项。
 */
vh.Toast(text, duration);
/**
 * 显示loading遮罩层
 * @param {number} opacity - 遮罩层透明度,默认值为0.6,取值范围为0到1之间的小数,非必填项。
 * @param {string} color - loading颜色,默认值为#000000,可以是任何有效的CSS颜色值,非必填项。
 */
vh.showLoading(color, opacity);
/**
 * 隐藏loading遮罩层
 */
vh.hideLoading();
/**
 * 获取当前URL参数
 * @param {string} param - 参数名,必填项。
 * @returns {string|null} 参数值,如果不存在该参数则返回 null。
 */
vh.getUrlParams(param);
/**
 * 获取当前URL所有参数
 * @returns {object} 包含所有参数的 JSON 对象。
 */
vh.getUrlParamsJson();
/**
 * 将JSON对象转换为URL参数字符串
 * @param {object} json - JSON对象,必填项。
 * @returns {string} 类似 a=1&b=2&c=3 的URL参数字符串。
 */
vh.jsonToUrlParams(json);
/**
 * 将时间戳格式化为指定格式的时间字符串
 * @param {number} time - 时间戳,必填项。支持10位和13位时间戳。
 * @param {string} format - 时间格式字符串,不必填项。默认格式为YYYY-MM-DD hh:mm:ss。传入格式时,YYYY、MM、DD、hh、mm、ss不可改变,其他可改变。
 * @returns {string} 指定格式的时间字符串。
 */
vh.TimeFormat(time, format);
/**
 * 复制文本到剪贴板
 * @param {string} text - 需要复制的文本,必填项。
 * @param {string} msg - 复制成功后的提示消息,默认为 "Copy Success"。传入false不弹出消息提示,非必填项。
 */
vh.CopyText(text, msg);
/**
 * 无风险打开URL/下载文件
 * @param {string} url - 需要打开的URL,必填项。
 * @param {string} filename - 如果是下载文件,需要指定文件名。为空则不下载,非必填项。
 * @param {string} target - 打开方式,默认为 "_blank",非必填项。
 * @returns {void}
 */
vh.OpenURL(url, filename, target);
/**
 * 防抖
 * @param {function} fn - 需要执行的函数。
 * @param {number} wait - 间隔时间,默认1000ms。
 */
vh.Debounce(() => fn, wait);
/**
 * 节流
 * @param {function} fn - 需要执行的函数。
 * @param {number} delay - 间隔时间,默认1000ms。
 */
vh.Throttle(() => fn, delay);
/**
 * 用户唯一标识
 * @param {boolean} safe - 是否开启严格模式,非必填项。
 * @returns {string} 返回一个用户唯一标识字符串。
 */
vh.OneKey(safe);
/**
 * 正则校验
 * @param {string} url - 需要校验的URL,必填项。
 * @param {string} phone - 需要校验的手机号码,必填项。
 * @param {string} email - 需要校验的邮箱地址,必填项。
 * @param {string} idcard - 需要校验的身份证号码,必填项。
 * @returns {Boolean} 返回一个布尔值,true或false
 */
vh.check.url(url);
vh.check.phone(phone);
vh.check.email(email);
vh.check.idcard(idcard);
/**
 * 设备类型判断
 * @returns {Object} 返回一个对象,包含了 `windows`、`mac`、`android` 和 `ios` 四个属性,分别表示当前设备类型
 */
vh.check.ua();