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

any-check

v1.0.2

Published

用于数据格式校验的工具库

Downloads

5

Readme

any-check 介绍

前端常见的数据校验、类型判断、设备环境判断

持续更新中!!!(Continuously update code!!!)

代码贡献规范

请查看 README_dev.md 文件

安装

使用 npm
npm install any-check --save
使用 yarn
yarn add any-check
浏览器 script 引入方式

下载链接

使用例子

// 局部导入
import { isEmail } from 'any-check';
isEmail('[email protected]'); //true

// 导入所有
import * as anyCheck from 'any-check';
anyCheck.isEmail('[email protected]'); //12,000.00

具体方法描述

设备环境相关的方法
import { XXX } from 'any-check';

isWX(); //验证是否微信环境
isALIPAY(); //验证是否支付宝环境
isDINGDING(); //验证是否钉钉环境
isZLB(); //验证是否浙里办环境
isTaurusApp(); //验证是否浙政钉环境
isDeviceMobile(); //验证是否是移动端
isQQBrowser(); //验证是否是QQ浏览器
isIE(); //验证是否IE浏览器
isSpider(); //验证是否是爬虫
isAndroid(); //验证是否安卓设备
isIOS(); //验证是否苹果设备
通过原型判断数据的类型
import { XXX } from 'any-check';

let val = '';
isString(val); //验证是否是字符串
isNumber(val); //验证是否是数字
isBoolean(val); //验证是否是boolean
isFunction(val); //验证是否是函数
isNull(val); //验证是否是null
isUndefined(val); //验证是否是undefined
isObject(val); //验证是否是对象
isArray(val); //验证是否是数组
isDate(val); //验证是否是日期
isRegExp(val); //验证是否是正则
isError(val); //验证是否是错误对象
isSymbol(val); //验证是否是Symbol
isPromise(val); //验证是否是Promise
isSet(val); //验证是否是Set类型
isMap(val); //验证是否是Map类型
是否存在类的方法
import { XXX } from 'any-check';

strHaveStr('abcd', 'bc'); //验证字符串中是否包含某个字符串
haveLetter('aaa'); //验证字符串中是否包含字母
haveNumber('abc123'); //验证字符串中是否包含数字
常规方法
import { XXX } from 'any-check';

let val = '';
isEmail(val); //验证邮箱地址
isMobile(val); //验证手机号码
isTelPhone(val); //验证固定电话
isPostal(val); //验证邮政编码
isCreditCode(val); //验证统一社会信用代码
isDecimal(val); //验证是否是数字
isQQ(val); //验证是否是QQ号
isMoney(val); //验证是否是金额(小数点2位)
isPosInteger(val); //验证正整数
isStartWithNum(val); //验证字符串是否以数字开头
isIDNumber(val); //是否是身份证号码
isUrl(val); //验证是否链接
isNotEmpty(val); //验证参数是否为空
isEmptyObject(val); //验证对象是否为空对象
isIP(val); //验证是否IP
isChinese(val); //验证是否中文
isEnglish(val); //验证是否英文
isHTML(val); //验证是否HTML标记
isObjectEqual({ a: 1 }, { a: 1 }); //验证是否两个对象是否键值相同
isSQLXss(val); //验证是否sql攻击

贡献者