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

js-useful-tools

v1.2.8

Published

js常用方法

Downloads

8

Readme

简介

js常用函数合集,支持vue,react,html项目,更新中...

https://www.npmjs.com/package/js-useful-tools
  • npm下载
npm install js-useful-tools
https://npmmirror.com/package/js-useful-tools
  • cnpm下载
cnpm install js-useful-tools

预览地址

  1. https://kangleyunju.gitee.io/js_useful_tools
  2. https://kangleyunju.github.io/js_useful_tools/
  3. https://static-mp-2503170c-6f74-4217-ac1a-43133fb6d1b4.next.bspapp.com/js_useful_tools/index.html

现有方法

  1. createToken 生成随机位数token
createToken(token位数)
  1. checkWeb 验证网址
checkWeb('https://www.baidu.com')
  1. checkEmail 验证邮箱
checkEmail('[email protected]')
  1. checkTelephone 验证手机号
checkTelephone('13012345678')
  1. checkCarNumber 验证车牌号
checkCarNumber('沪A12345D')
  1. dayDiff 两个日期间隔天数
dayDiff('2022-09-08','2023-01-09')
  1. downloadFile 下载文件
downloadFile(链接, 名称)
  1. fileToBlob 文件转blob
fileToBlob(file)
  1. fileToBase64 文件转base64
fileToBase64(file)
  1. urlToBase64 链接转base64
urlToBase64(path)
  1. setStorage 添加缓存
setStorage(key,data)
  1. getStorage 获取缓存
getStorage(key)
  1. removeStorage 删除缓存
removeStorage(key)
  1. shake 震动
shake(震动时长)
  1. copyText 复制文本
copyText('npm i js_useful_tools')
  1. checkIsMobile 检查设备是否手机
checkIsMobile()
  1. arraySort 数组排序,支持二维数组
globale.arraySort([{val:1},{val:3},{val:2}],2,'val')
  1. debounce 防抖
debounce(()=>{
  console.log('用户结束操作1秒后执行,比如实时搜索')
},1000)
  1. throttle 节流
throttle(()=>{
  console.log('1秒执行一次操作,比如提交事件')
},1000)
  1. arrayRandom 从数组中随机取一个数
arrayRandom([1, 2, 3])
  1. encodeStr 字符串加密
encodeStr('js_useful_tools')
  1. decodeStr 字符串解密
decodeStr('yÝÒÔèØËÛáËÓãÞÛß')
  1. stampToTime 时间戳转年月日
stampToTime(1680860366194)
  1. isLeapYear 是否闰年
isLeapYear(2023)
  1. deepClone 深拷贝
deepClone([1,2,3])
  1. rgbToHex rgb颜色转16进制
globale.rgbToHex('rgb(255,16,7,0.5)')
  1. hexToRgb 16进制颜色转rgb
globale.hexToRgba('#2ff086', 0.9)
  1. getJsType 获取js类型
globale.getJsType(null)
  1. getStamp 获取各个日期时间戳
global.getStamp('month')
  1. exportJson 导出json
global.exportJson(data)
  1. importJson 导入json
global.importJson(file)
  1. fullScreen 某个元素全屏
global.fullScreen(document.body)
  1. urlToFile url转file
global.urlToFile(url)
  1. isUrlAble url是否有效
global.isUrlAble(url)
  1. getVideoPoster 获取视频封面
global.getVideoPoster(file)
  1. compressImg 图片压缩
global.compressImg(file)
  1. formatSeconds 秒数转时分秒
global.formatSeconds(12345)//03:25:45
  1. getFileSize 获取文件大小
global.getFileSize(12345)//12.1KB

使用方法

  • vue项目
//单个方法引入
improt {createToken} from 'js-useful-tools'
createToken(8)
//全部方法引入
improt * as global from 'js-useful-tools'
global.createToken(8)
  • html项目
//单个方法引入
<script type="module">
  import {createToken} from 'js-useful-tool'
  createToken(8)
</script>
//全部方法引入
<script type="module">
  import  * as globale from 'js-useful-tool'
  global.createToken(8)
</script>

仓库

| gitee | github | | --- | --- | | js_useful_tools | js_useful_tools |

邮箱

有问题可以提Issue,或者发邮件:[email protected],觉得不错可以点个赞

发布

npm config set registry https://registry.npmjs.org
npm publish