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

comutils

v1.1.19

Published

前端代码常用工具类

Downloads

11,359

Readme

comutils  GitHub forksGitHub stars

npm Build Status LICENSE MIT

前端代码常用工具类

目的:集成前端常用工具类

安装使用

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

推荐使用方法

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

// 只引入部分方法('outils/<方法名>')
const isUrl = require('outils/isUrl')
const isUrl = isUrl()

API文档

Class

  classApi  className的操作api

    classApi.isElement(el) //是否元素节点
    classApi.hasClass(el,cls)
    classApi.addClass(el,cls)
    classApi.removeClass(el,cls)
    classApi.toggleClass(el,cls)

Object

  copyObj  对象合并/深浅拷贝

Regexp

  isEmail  判断是否为邮箱地址

  isIdCard  判断是否为身份证号

  isPhoneNum  判断是否为手机号

  isUrl  判断是否为URL地址

  priceSubstr  千位分割方法

Secret

  secretInfo  给隐私信息标记号加密

Time

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

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

device

  isWeixin  是否是微信浏览器

  mobileType  设备类型iphone or android

  getOs  是否是手机mobile or web

function

  throttle  节流函数

  debounce  防抖函数

dom

  scrollApi  scrollApi方法

    scrollApi.getScrollTop()
    scrollApi.setScrollTop(h)
    scrollApi.scrollTo(to,duration)

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

localStorage

  localStorageApi  本地持久化存储

    localStorageApi.set(name)
    localStorageApi.get(name)
    localStorageApi.remove(name)
    localStorageApi.clear(name)

cookie

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

    cookieApi.set(name, value[, end[, path[, domain[, secure]]]])
    cookieApi.get(name)
    cookieApi.has(name)
    cookieApi.remove(name)
    cookieApi.keys()

Type

  typeOf  判断类型

Url

  getUrlParams  url参数转对象

  stringfyQs  对象序列化

random

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

collections

  shuffle  数组打乱随机乱序

array

  arrayEqual  判断数组是否相等

animationFrame

  animationFrame  AnimationFrame简单兼容hack

prefixStyle

  prefixStyle  prefixStyle css针对不同浏览器加前缀