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

tools-for-js

v2.0.1

Published

基于babel构建的JavaScript前端工具库

Downloads

54

Readme

项目名称

tools-for-js —— JavaScript 前端工具库

安装

npm install tools-for-js --save

使用

import { API } from 'tools-for-js'

JS API

| 名称 | API | | ------------------------------------------------ | ----------------- | | 阿拉伯数字转中文数字 | numToChinese | | 金额格式化 | moneyFormat | | 时间格式化 | dateFormat | | 下划线转小驼峰 | convertSmallHump | | 将对象中的键转小写 | lowercaseKeys | | 将对象中的键转大写 | upperCaseKeys | | 获取时间间隔 | getTimeDistance | | 获取时间戳 | timeStamp | | 获取倒计时 | countDown | | 距离当前时间状况 | transformDate | | 变量类型判断 | IsType | | 深拷贝变量 | deepCopy | | 校验空值参数 | isEmpty | | 校验两个参数是否相等 | isEqual | | 数组去重 | deWeightArray | | 计算树的最后节点某字段的总和 | treeLastChildSum | | 校验数组对象中是否存在指定的字段为空 | checkKeyEmpty | | 移动数组元素 | arrEleMove | | 数组元素交换位置 | arrExchange | | 数组格式转树状结构 | arrayToTree | | 根据 label 的值获取 value | getValueFromArray | | 随机抽取数组中的 n 个值 | randomNumEnum | | 精确加法 | exactAdd | | 计算数组元素的和 | summation | | 计算两个参数 | countNumber | | GBK 字符集实际长度计算 | getStrLength | | 密码强度校验 | checkPwdStrength | | 按指定长度分段字符串 | splitString | | 将对象转换为查询字符串 | objectToQs | | 计算数据分页 | getPagination | | 根据 key 值排序,相同时则根据时间 timeKey 值排序 | sortByKeyAndTime | | 根据 key 获取对象值 | getValByKey | | 数组随机打乱 | shuffleArray | | 将路径中的反斜杠字符 \ 替换为斜杠 / | replacePath | | 切割/获取文件名 | splitToFileName | | 数组反选 | invertSelection | | 创建时间对象 | createDate | | 获取结束时间 | getExpiresEndTime | | 判断是否过期 | isExpires | | 随机数字 | randomNum | | 随机字符串 | randomCode | | 随机颜色 | randomColor | | 创建 UUID | createUUID | | 随机 MAC 地址 | randomMac | | 随机索引 | randomIndex | | 随机数组中的值 | randomEnum | | 随机数组中的 n 个值 | randomNumEnum | | 随机指定范围的整数 | randomIntRange | | 验证手机号 | checkMobile | | 验证邮箱 | checkEmail | | 验证运动账号 | checkSports | | 判断是否为 json 字符串 | isJSONString | | 待更新 | function |

WEB 相关 API

| 名称 | API | | -------------------------- | ---------------- | | store2:localStorage 缓存 | local | | store2:sessionStorage 缓存 | session | | 设置有效期信息 | setExpires | | 获取有效期信息 | getExpires | | 移除有效期信息 | removeExpires | | 获取 cookie | getCookie | | 获取所有 cookie | getCookies | | 设置 cookie | setCookie | | 删除指定 cookie | removeCookie | | 删除所有 cookie | removeCookies | | 将 txt 的 blob 转文本内容 | blobToText | | 下载流文件 | downloadStream | | 图片转 base64 | getBase64 | | 浏览器内核 | kernelInfo | | 移动端/PC 端 | isMobile | | 是否 android 终端 | isAndroid | | 是否 ios 终端 | isIOS | | 是否微信环境 | isWeiXn | | 是否 QQ 环境 | isQQ | | 是否钉钉环境 | isDingTalk | | 是否微博环境 | isWeiBo | | 获取哈希路由参数 | getHashParam | | 获取路由参数 | getQueryParams | | 获取当前路径 | getPath | | 清除.html 后缀 | wrapperCleanUrls | | 获取移动端转换比例 | getScale | | 移动端自适应尺寸转换 | sizeConvert | | 创建 script 标签加载 js | createScript | | 清除.html 后缀 | wrapperCleanUrls | | 复制文本 | copyText |