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

autils

v1.1.8

Published

前端常用函数库

Downloads

2

Readme

autils  GitHub forksGitHub stars

npm Build Status LICENSE MIT

前端常用函数库

目的:封装前端代码经常使用的函数,提高开发效率。如果你也有常用的代码,欢迎为本项目提交PR。

安装使用

  1. 直接下载bulid目录下的autils.min.js使用,支持UMD通用模块规范
  <script src="autils.min.js"></script>
  <script>
      var deepCopy = autils.deepCopy(obj1,obj2)
  </script>
  1. 使用npm安装
  $ npm install -D autils

推荐使用方法

不需要完整引入所有函数,只引入需要使用的方法即可

  // 只引入部分方法('autils/lib/<方法名>')
  const deepCopy = require('autils/lib/deepCopy')
  const object = deepCopy(obj1,obj2)

API文档

Class

  hasClass  检查元素是否有class

  addClass  为元素添加class

  removeClass  为元素移除class

  toggleClass  为元素切换class

dom

  getScrollTop  获取滚动条距顶部的距离

  setScrollTop  设置滚动条距顶部的距离

  scrollTo  在${duration}时间内,滚动条平滑滚动到${to}指定位置

  offset  获取一个元素的距离文档(document)的位置,类似jQ中的offset()

  softKeyCal  移动端端软键盘呼出和消失的事件回调

Regexp

  isUrl  判断是否为URL地址

  isEmail  判断是否为邮箱地址

  isIdCard  判断是否为身份证号

  isPhoneNum  判断是否为手机号

  priceSubstr  千位分割方法

Secret

  secretInfo  给隐私信息标记号加密

Time

  formatPassTime  格式化时间戳为天时分秒[d,h,m,s]

  formatTime  格式化时间戳为年月日时分秒[y-m-d h:m:s]

Object

  deepCopy  对象合并/深拷贝

  isEmptyObject  判断Object是否为空

array

  shuffle  数组打乱随机乱序

  arrayEqual  判断数组是否相等

  intersection  输出2数组的交叉项

device

  isWeixin  是否是微信浏览器

  mobileType  设备类型iphone or android

  getOs  是否是手机mobile or web

function

  throttle  节流函数

  debounce  防抖函数

localStorage

  localStorageApi  本地持久化存储

      localStorageApi.set
      localStorageApi.get
      localStorageApi.remove
      localStorageApi.clear

cookie

  cookieApi  cookie存储(适用和服务端交互)

      cookieApi.set
      cookieApi.get
      cookieApi.remove
      cookieApi.has
      cookieApi.keys

Type

  typeOf  判断类型

Url

  getUrlParams  url参数转对象

  stringfyQs  对象序列化

random

  getRandom  返回选定返回的随机整数

download

  download  根据链接生成下载

License

autils is open source and released under the MIT License.