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

yg-js-utils

v1.0.0

Published

js常见的函数工具库

Downloads

11

Readme

博客 | NPM地址 | git源码 | gitee源码

yg-js-utils(函数库)

概述

将一些常用的前端工具函数封装,拿来即用;小伙伴们虽然公司会换,项目会换。但是工具函数不会换。来来去去就那些常用的 到底是造船过河还是借船过河,全凭个人喜好!!!作者建议不要重复造轮子,把精力放在业务逻辑上!

安装

npm install yg-js-utils --save

使用说明

1、防抖节流

2、深拷贝

3、浅拷贝

4、call,apply,bind

6、转义字符转换

7、匹配字符串中所有图片src

8、复制文本到粘贴板

9、判断是浏览器内核

10、获取HTML中的纯文本信息

11、去除空格

12、数字千分位分割(10,000,000)

13、将阿拉伯数字翻译成中文的大写数字(五仟二百二十二)

14、数字转为大写金额 (壹仟零伍拾贰万玖仟伍佰贰拾元整)

15、文件大小格式化 (B,KB,MB,GB)

16、动态加载外部样式文件

17、异步加载外部多个js(动态插入)

18、获取地址栏url参数

19、手机号中间四位变成* (177****698)

20、字符串首字母大写  (Hello)

21、number边界处理

    1.大数相加

    2.大数相乘

22、滚动条滚动

    1.动画缓冲(scrollAnimation)

    2.滚动页面到顶部(scrollToTop)

    3.滚动页面到底部(scrollToBottom)

23、时间戳转格式

    1:YYYY-MM-DD HH:MM:SS

    2:刚刚、几天前、几个月前、几年前

    3:星期几

24、随机数

    1:指定长度随机字符串

    2:范围内随机数

    3:数组取随机数

25、6种排序方式

    1:冒泡排序

    2:计数排序

    3:插入排序

    4:归并排序

    5:快速排序

    6:选择排序

26、数组

    1.扁平数据结构转Tree

    2.去重

    3.扁平化(降维)

27、Base64

    1.加密

    2.解密

28、UTF-8

    1.加密

    2.解密

29、cookie

    1.设置

    2.获取

    3.移除

30、常用校验

    1.邮箱校验

    2.手机号校验

    3.微信号校验

    4.QQ号校验

    5.车牌号校验

    6.密码强度校验

    7.是否包含中文校验

    8.邮编号校验

    9.16进制颜色校验

    10.身份证号校验

    11.Ipv4校验

    12.手机是Andoird还是IOS

    13.是否数字

    14.是否对象

    15.是否空对象

    16.是否数组

    17.数据类型判断

    18、银行卡号码校验(luhn算法)

    19.验证版本号格式必须为X.Y.Z

    20.验证护照(包含香港、澳门)

如何使用

import { deepCopy } from 'js-util-libs';
const obj = {
        name: 'yg',
        age: "18",
        title: "good man"
      };
      const text = deepCopy(obj);
      console.log('npm本地包发布前测试:',text);