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

mall-utils

v2.2.5

Published

common functions

Readme

一些通用方法整理,部分只适用于商城

该库已经实现 tree shaking,只会打包用到的代码。

使用

  1. 安装 npm i --save mall-utils
  2. 引入 import { AppConst } from 'mall-utils'

config

| 方法 | 说明 | 类型 | | --------- | ------------------------------------------------ | -------- | | AppConst | 配置参数 | Object | | setConfig | 设置一个或多个 json 格式入参,合并到 AppConst 中 | Function |

contactService

| 方法 | 说明 | 类型 | | -------------- | ------------------------------------------------------ | -------- | | connectService | 环信客服连接,使用集成网页链接方式,传入 configId 调用 | Function | | contactService | 兼容 mall 调用,传入客服类型 type,结合 setConfig 使用 | Function |

cookie

| 方法 | 说明 | 类型 | | --------- | ----------- | -------- | | setCookie | 设置 cookie | Function | | getCookie | 获取 cookie | Function | | delCookie | 删除 cookie | Function |

date

| 方法 | 说明 | 类型 | | ---------------- | ----------------------------------------------- | -------- | | parseDatetime | 转换时间格式,形如 YYYY-MM-DD HH:mm:ss | Function | | friendlyDateTime | 距离当前时间计算,转换成 T 天前、H 小时前等形式 | Function | | formatTime | 时长(毫秒)转换成 T 天、H 小时等形式 | Function |

models

| 方法 | 说明 | 类型 | | --------- | ----------------------- | ----- | | Countdown | 用于 vue 项目显示倒计时 | Class |

pay

| 方法 | 说明 | 类型 | | --------- | ------------------ | -------- | | unionpay | 银联支付 | Function | | alipay | 支付宝支付 | Function | | wechatpay | 微信环境下调起支付 | Function |

sessionStorage

| 方法 | 说明 | 类型 | | ----------------- | -------------------------------------------------- | -------- | | setSessionStorage | 设置 sessionStorage | Function | | getSessionStorage | 获取 sessionStorage 对应名称值,已转换 Object 类型 | Function |

string

| 方法 | 说明 | 类型 | | --------------- | ------------------------ | -------- | | padZero | 添加 0 到对应长度字符串 | Function | | fullMoney | 金钱,分转元,带两位小数 | Function | | removeHtmltag | 去除 html 标签 | Function | | changeToHtmltag | 换行符转换成<br />标签 | Function |

tool

| 方法 | 说明 | 类型 | | -------------- | ---------------------------------------------------------------------- | -------- | | wait | 等待时长,毫秒 | Function | | getProtocol | 获取桥接协议 | Function | | getOpenid | 获取 openid,需要预先调用 setConfig 方法设置 APP_APPID | Function | | changeBlur | 输入内容,软键盘弹出,页面内容整体上移,但是键盘收起,页面内容不下滑。 | Function | | changefocus | 安卓微信 H5 弹出软键盘后挡住 input 输入框 | Function | | debounce | 简单防抖 | Function | | hideMenu | 隐藏右上角菜单键 | Function | | loadScript | 加载 js 文件,返回 Promise | Function | | download | 根据 url 地址下载 | Function | | copyText | 复制文本到剪贴板 | Function | | imgUrlToBase64 | 图片链接转 base64 | Function | | imgUrlToBlob | 图片链接转 blob url | Function | | memoize | 缓存函数 | Function | | isMP | 不需要调用微信 SDK 判断是否为小程序 | Function | | looseEqual | 判断任意两个变量是否相等 | Function |

Track

| 方法 | 说明 | 类型 | | ----- | ------------------------------------------- | ----- | | Track | 埋点封装,内部加载 js,实例化时配置对应参数 | Class |

url

| 方法 | 说明 | 类型 | | -------------- | --------------------------------------------------------------------- | -------- | | addHistoryUrl | 添加返回历史记录链接 | Function | | getQueryString | 获取网址参数对应键名的值 | Function | | buildUrl | 构建 url | Function | | remainStateKey | 保存当前页面 history.state.key,vue 项目添加在 afterEach 路由钩子函数 | Function | | onBackPage | 监听返回历史,配合 remainStateKey 函数使用 | Function |

validate

| 方法 | 说明 | 类型 | | ------------- | ----------------------- | -------- | | isObject | 判断是否为对象类型 | Function | | isPlainObject | 判断是否为普通对象类型 | Function | | isArray | 判断是否为数组 | Function | | isRegExp | 判断是否为正则 | Function | | isDate | 判断是否为 Date 类型 | Function | | isFunction | 判断是否为函数类型 | Function | | isPromise | 判断是否为 Promise 类型 | Function | | isValidDate | 判断是否为有效时间 | Function | | isWechat | 是否为微信浏览器 | Boolean | | isWorkWechat | 是否为企业微信浏览器 | Boolean | | isNative | 是否为 native 环境 | Boolean | | isIos | 是否为 iOS 环境 | Boolean | | isAndroid | 是否为安卓环境 | Boolean | | isUrl | 判断是否为 url | Function | | isMobile | 判断是否为手机号 | Function | | isEmail | 判断是否为邮箱 | Function | | isCardID | 判断是否为合法身份证号 | Function | | isIframe | 判断是否在 iframe 内 | Function |

vuePlugins

Vue 插件,使用

import Vue from "vue";
Vue.use(PCodeLinkTo);

| 方法 | 说明 | 类型 | | ----------- | ---------------------- | ---------- | | PCodeLinkTo | 根据 code 进行链接跳转 | Vue Plugin |

wxSDK

| 方法 | 说明 | 类型 | | ------------- | -------------------------------- | -------- | | jWeixin | weixin-js-sdk 引入对象 | Object | | initWXConfig | 初始化签名配置,传入配置参数方法 | Function | | configWxShare | 调用分享集合 | Function | | scanQRCode | 扫描二维码 | Function | | getLocation | 获取定位,经纬度 | Function | | previewImage | 预览图片 | Function |