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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ssports_fe/ssutils

v1.4.6

Published

前端业务代码工具库

Readme

ssutils

前端业务代码工具库

目的:高效完成前端业务代码

业务开发过程中,会经常用到日期格式化url参数转对象浏览器类型判断等常用函数,为避免不同项目多次复制粘贴的麻烦,这里统一封装,并发布到npm,以提高开发效率。

安装使用

  1. 直接下载dist目录下的ssutils.min.js
  2. 使用yarn或者npm安装

浏览器

    <script src="ssutils.min.js"></script>
    <script>
        var browser = ssutils.browser()
    </script>

yarn or npm

$ yarn add --dev @ssports_fe/ssutils
$ npm install --save-dev @ssports_fe/ssutils

webpack、RequireJS、SeaJS等

// 完整引入
const ssutils = require('@ssports_fe/ssutils')
const browser = ssutils.browser()
or
import ssutils from '@ssports_fe/ssutils';

推荐使用方法

引入需要使用的方法

// 只引入部分方法('@ssports_fe/ssutils/<方法名>')
const browser = require('@ssports_fe/ssutils/browser')

API文档

Array

array 数组相关操作

  • arrayEqual 判断两个数组是否相等
  • isArrayLike 判断是否为类数组

browser

browser 浏览器相关判断

  • getBrowser 返回对应浏览器型号
  • getExplore 获取浏览器类型和版本
  • getOS 获取操作系统类型
  • browserRedirect 跳转对应的移动端项目
  • isSupportWebP 判断浏览器是否支持webP格式图片

calc

calc 数学计算相关操作

  • strip 把错误的数据转正
  • digitLength 返回Number类型数字的长度
  • times 精确乘法
  • plus 精确加法
  • minus 精确减法
  • divide 精确除法
  • round 四舍五入

cookie

cookie Cookie相关操作

  • get 获取cookie
  • set 设置cookie
  • remove 删除cookie

dom

dom Dom相关操作

  • setPageTitle 设置页面标题(title)
  • getScrollTop 获取滚动条距顶部的距离
  • setScrollTop 设置滚动条距顶部的距离
  • offset 获取一个元素的距离文档(document)的位置,类似jQ中的offset()
  • windowResize H5软键盘缩回、弹起回调
  • scrollTo 在${duration}时间内,滚动条平滑滚动到${to}指定位置
  • hasClass dom节点是否包含某个类
  • addClass 给dom节点增加类
  • removeClass 给dom节点移除类
  • getStyle 获取dom节点的style
  • on 绑定事件
  • off 移除事件

function

function 基础工具函数

  • throttle 函数节流
  • debounce 函数防抖
  • typeOf 获取对象类型

iframe

iframe iframe相关操作

  • setParentTitle 设置iframe的title
  • reloadIframeUrl iframe父级页面跳转
  • getScrollXY 获取窗口滚动坐标

keycode

keycode 键盘相关操作

  • getKeyName 根据keycode获得键名

object

object 对象相关操作

  • deepClone 深度clone
  • isEmptyObject 判断obj是否为空
  • extend 扩展对象

random

random 随机数相关操作

  • randomNum 生成指定范围[min, max]的随机数
  • randomColor 随机生成颜色
  • getUUID 生成32位随机数

regexp

regexp 正则相关操作

  • isEmail 判断是否为邮箱地址
  • isIdCard 判断是否为身份证号
  • isPhoneNum 判断是否为手机号
  • isUrl 判断是否为URL地址
  • isIqiyiApp 判断是否爱奇艺APP访问的H5链接
  • getIqiyiAppVersion 获取爱奇艺APP版本号

storage

storage 获取window对象上的本地存储数据

  • session 获取存储的sessionStorage
  • local 获取存储的localStorage

string

string 字符串相关操作

  • digitUppercase 现金额转大写

url

url 浏览器地址相关操作

  • getPageName 获取url路径名
  • getQueryString 获取url参数
  • getHash 获取url中hash值
  • parseQueryString url参数转对象
  • stringfyQueryString 对象序列化
  • getNewApiUrl 设置来源