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 🙏

© 2025 – Pkg Stats / Ryan Hefner

eptools

v1.1.1

Published

一些公共函数

Readme

项目介绍

项目旨在处理时间转换、数字的加减乘数等运算的一些通用函数

启动命名

npm install eptools --save

使用说明

import { EPTime, EPCalculator, ArrayTool } from 'eptools';

EPTime

| 函数 | 参数 | 说明 | 举例 | | --- | --- | --- | --- | |outTime(v, format) | v: Date | TimeStampformat: 'yyyy-MM-dd HH:mm:ss' 见时间格式 | 对时间或者时间戳进行转换 |EPTime.outTime(new Date(),'yyyy/MM/dd HH:mm:ss') | | formatTime(v, type) | v: String | Date type: 'strtime' | 'datestr' | 将时间数字字符串转成时间字符串,当v长度为14时且type为strtime时,输出年月日时分秒时间格式,长度为8时,输出年月日时间格式,当type为datestr时,输入yyyyMMddHH:mm:ss,否则原样输出v | EPTime.formatTime('20190203123523')EPTime.formatTime('20190203')EPTime.formatTime(new Date(),'datestr') | |EPTime.diffTime(inTime, type)|inTime:Numbertype:String | 计算时间差,inTime 为毫秒数,type 为hour 返回毫秒数有多少小时,否则返回年月日时分秒| | |getDayOfWeek|无| 获取本周的第一天和最后一天|| |getDayOfMonth|无|获取本月的第一天和最后一天|| |getQuartorStartDate|无|根据 年份 和 季度 获取 季度 第一天 和 季度 最后 一天|| |formatDate|value: Number|格式化月和日为MM、dd||

时间格式

|格式| 函数| 备注| 举例| |--|--|--|--| |yyyy| 年| | 2017| |M| 月 |不补0 |1| |MM| 月| |01| |W| 周| 仅周选择器的 format 可用;|不补0 |1| |WW| 周| 仅周选择器的 format 可用| 01| |d| 日 |不补0| 2| |dd| 日| | 02| |H| 小时 |24小时制;不补0| 3| |HH| 小时| 24小时制| 03| |h| 小时 |12小时制,须和 A 或 a 使用;不补0| 3| |hh| 小时 |12小时制,须和 A 或 a 使用| 03| |m| 分钟 |不补0| 4| |mm| |分钟| 04| |s| 秒 |不补0| 5| |ss| 秒| 05| |A| AM/PM| 仅 format 可用,大写| AM| |a| am/pm| 仅 format 可用,小写| am| |timestamp| JS时间戳 仅 value-format 可用;组件绑定值为number类型 |1483326245000| |[MM]| 不需要格式化字符| 使用方括号标识不需要格式化的字符 (如 [A] [MM]) |MM|

EPCalculator

| 函数 | 参数 | 说明 | 举例 | | --- | --- | --- | --- | |accAdd|arg1:Numberarg2:Numberoriginal:Boolean|加法运算:前面两个参数为被加数及加数,后面为是否原样输出还是保留两位小数|EPCalculator.accAdd(arg1,arg2,original)| |accDel|arg1:Numberarg2:Numberoriginal:Boolean|减法运算:前面两个参数为被减数及减数,后面为是否原样输出还是保留两位小数|EPCalculator.accDel(arg1,arg2,original)| |accMul|arg1:Numberarg2:Numberoriginal:Boolean|乘法运算:前面两个参数为被乘数及乘数,后面为是否原样输出还是保留两位小数|EPCalculator.accMul(arg1,arg2,original)| |accDiv|arg1:Numberarg2:Numberoriginal:Boolean|除法运算:前面两个参数为被除数及除数,后面为是否原样输出还是保留两位小数|EPCalculator.accDiv(arg1,arg2,original)|

ArrayTool

| 函数 | 参数 | 说明 | 举例 | | --- | --- | --- | --- | |getSectionArr|arg1:number[]|将一个无序数字数组从小到大进行分段:getSectionArr([1,7,4,8,10]), 返回[[1, 4], [4, 7], [7, 8], [8, 10]]|ArrayTool.getSectionArr(arg1)| |arr2Tree|arg1:TreeObjectType[]arg2:ArrOptionType|将具有父子关系的一维数组转成树形结构:前面两个参数为数组和父子标识(id, pid)对应的字段|ArrayTool.arr2Tree(arg1,{id: 'id', pid: 'pid'},original)| |tree2Arr|arg1:TreeObjectType[]arg2:TreeOptionType|将树形数据转为具有父子关系的一维数组,前面两个参数为树形数据和子节点标识(child)对应的字段|ArrayTool.tree2Arr(arg1,{child: 'children'},original)| |traverse|arg1:TreeObjectType[]|将树形数据扁平化,并返回各自的所属层级ID|ArrayTool.traverse(arg1)|