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

dm-core

v1.0.0-alpha3

Published

dm函数工具

Readme

dm-core-方法注解

深拷贝与浅拷贝

- dm.shallowClone(obj)   //浅拷贝
- dm.deepClone(obj) //深拷贝

cookie

- dm.getCookie(key) //读取cookie
- dm.setCookie(key, value, expiredays) //设置cookie
- dm.delCookie(key)  //删除cookie

日期相关

  • dm.date.timeElapsed(updateTime)//时间转换:几分钟,几小时,刚刚,几天,几月,几年
      
    dm.date.timeStampToTime(timestamp, number) //时间戳转换为时间
      
    dm.date.getCurrentWeekday()//获取今天是星期几
      
    dm.date.getCurrentWeekNumber(start, total) //获取当前是开始日期之后的第几周

http请求

//get请求
dm.http.get("xxxx",params).then(res=>{
    
}).catch(err=>{
    
})

//post请求
dm.http.post("xxxx",data).then(res=>{
    
}).catch(err=>{
    
})
//put请求
dm.http.put("xxxx",params).then(res=>{
    
}).catch(err=>{
    
})

轻提示与确认框

 /*
 *@描述:轻提示,使用的是ant-design-vue
 *@content: 提示的文本内容
 *@type: 弹窗的类型 可选值success,error,  warning,info,loading
 *@dur: 消失时间,单位s
 *@variable4: 变量4
 *@variable5: 变量5
 */
dm.layer.message(content,type,dur)

dm.layer.confirm(title = "", content = "", danger, btnList = ["确认", "关闭"], onSuccess, onCancel)

dm.layer.alert(title = "", content = "", danger, btnList = "确认", callBack) 

其他方法

//判断当前环境是pc端还是移动端
dm.IsPC()

//保留n位小数,注意此方法返回的是 string类型,小数点后面不足的位数会自动补 0
dm.tofixed(num, n) 

// 创建一个a标签,并做点击下载事件
dm.downloadFile(hrefUrl, fileName)

//后端返回文件流下载(导出)文件
// blobData 后台返回的文件流二进制数据
// mimeTypeStr 文件后缀名对应的type值(媒体文件类型)
// fileName 自定义文件名称
dm.downloadFileByFileFlow(blobData, mimeTypeStr, fileName)

//封装blob对象
dm.dataURLToBlob(base64Str, mimeTypeStr)

//后端返回base64公共导出
dm.downloadFileByBase64(base64Str, mimeTypeStr, fileName)

dm.isEmpty(e)// 判断是否为空

dm.typeOf(obj) // 数据类型判断以及判断是否为数字类型或者数字型字符串

/*
 * JSON数组去重
 * @param: [array] json Array
 * @param: [string] 唯一的key名,根据此键名进行去重
 */
dm.uniqueArray(array, key)

/**
 * 两个数组去重
 * @param {Array} originList 原始数组
 * @param {Array} currentList 当前数组
 * @param {String} sortKey 去重字段
 * @return {Array} 返回新数组中不重复的部分
 */
dm.Duplicate(originList, currentList, sortKey = 'id')

dm.unique(arr)// 数组包数组去重

/**
 * 数组元素为对象的去重方法 ES6方法
 * @param arr  原数组
 * @param type  根据元素的某个属性进行去重
 * @returns {Array} 返回去重后的新的数组
 */
dm.Es6duplicate(arr, type)

正则相关

/**
 * 名称校验规则
 * @param {String} str 获取输入的名称
 * @return {Boolean} 返回是否校验通过  true为通过, false为不通过
 */
dm.nameRexp(str, required = true)

/**
 * 根据身份证获取性别
 * @param {String} idCard 获取输入的身份证号码
 * @return {String} 返回性别 {男, 女}
 */
dm.idCard(IDCard)

/**
 * 根据身份证获取性别
 * @param {String} idCard 获取输入的身份证号码
 * @return {String} 返回性别 {男, 女}
 */
dm.IDCardSex(idCard)

/**
 * 校验比例输入  (输入为数字且在0-100之内)
 * @param {String Number} num 输入的比例值
 * @return {Boolean}  校验是否通过  true:通过 / false:未通过
 */
dm.propNum(num)

/**
 * 校验输入的年龄  (输入为数字且在0-120之内)
 * @param {String Number} num  输入的年龄
 * @return {Boolean}  校验是否通过  true:通过 / false:未通过
 */
dm.ageRexp(num)

/**
 * 联系电话校验
 * @param {String Number} num 录入的号码(手机号或者固定电话)
 * @return {Boolean} 校验是否通过  true:通过 / false:未通过
 */
dm.TelphoneNumber(num)

// 检查特殊字符
dm.specialCharactersCheck(str)

// 下划线转换驼峰
dm.toHump(name)

// 驼峰转换下划线
dm.toLine(name)

// 判断两个对象的值是否相等
dm.diffObject(obj1, obj2)
淘宝镜像源 https://registry.npm.taobao.org/

npm 镜像源:https://registry.npmjs.org

获取镜像源:npm config get registry

设置镜像源:npm config set registry https://registry.npmjs.org

npm login 登录 npm

npm publish 发布 npm