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

guide-web-utils

v1.0.3

Published

封装一些前端常用的js方法供开发人员直接使用。

Readme

介绍

封装一些前端常用的js方法供开发人员直接使用。

安装教程

可通过 npm i guide-web-utils 直接安装

使用方法

一、可在main.js中全局注册

import * as publicMethod from 'guide-web-utils'  
Vue.prototype.$public = publicMethod  

二、也可以在组件中单独引入需要使用的方法

import { check10 } from 'guide-web-utils'

方法介绍

  • check10

    介绍: 数字小于10在前面补充0
    参数:
      {Number} val 需判断的数值

  • getCurrentTime

    介绍: 获取当前时间或日期的方法
    参数:
      {String} separator 日期间的分隔符,默认为'-'
      {Boolean} excludeTime 是否不包括时间,默认为false

  • formatterDateMethod

    介绍: 格式化时间日期的方法
    参数:
      {String} date 需要格式化的日期
      {String} separator 日期间的分隔符,默认为'-'
      {Boolean} excludeTime 是否不包括时间,默认为false

  • getIntervalDateMethod

    介绍: 获取指定日期或当前日期前后n天的方法
    参数:
       {Number} dateInterval 大于0表示之后的天数,小于0表示之前的天数
       {String} date 指定的日期,没有时默认为当前日期
       {String} separator 日期间的分隔符,默认为'-'
       {Boolean} excludeTime 是否不包括时间,默认为false

  • downloadDataStreamMethod

    介绍: 后台返回数据流, 前端转换下载的方法
    参数:
       {String} streamData 接口返回的数据流
       {String} fileName 导出文件的名称
       {String} fileType 导出文件的类型('application/vnd.ms-excel';'application/zip';'application/pdf')
       {Boolean} withoutToBlob 一般情况下需要将后台返回的数据流转blob,默认值为false,如果不需要转就传参数 true

  • deepCloneMethod

    介绍: 深拷贝的方法
    参数:
       {any} obj 待拷贝的对象

  • getIndexMethod

    介绍: 生成序号的方法,用于表格生成序号
    参数:
       {Number} index 列表序号
       {Number} currentPage 当前页
       {Number} pageSize 页数

  • footAndMeterTransformEachOther

    介绍: 米和英尺相互转换的方法
    参数:
       {Number} originData 待转换的数据
       {Boolean} toMeter 是否转换为米,默认是将原数据转为英尺

  • celsiusAndFahrenheitTransformEachOther

    介绍: 摄氏度和华氏温度相互转换的方法
    参数:
       {Number} originData 待转换的数据
       {Boolean} toCelsius 是否转换为摄氏度,默认是将原数据转为华氏温度

  • selectAllMethod

    介绍: 封装一个select选择器多选 【选择全部和取消全部】 联动效果
    参数:
       {Array} newValue 传入监听函数的最新值
       {Array} oldValue 传入监听函数的原值
       {Array} valueArray 选中的值
       {Array} valueSource 传入下拉菜单数据源
       {String} valueKey 下拉菜单数据中对应值的key,默认为 code
       {Number/String} allValue 传入全部所代表的值, 默认-1
    返回结果: 返回选择中的值

  • filterTreeData

    介绍: 剔除某一个树形结构数组中不满足某个值的数据,建议使用原数据的副本,可能会改变原数据
    参数:
       {Array} arraySource 待处理的数据源
       {String} valueKey 需要判断的数据组中的key
       {Array} valueArray 需满足的值的集合
       {String} childrenKey 子节点集合的key,默认为children
    返回结果: 返回过滤后的值

  • getScrollCount

    介绍: 在树形组件中,有时候需要滚动到指定的节点处,通过该方法获取到需要滚动的节点个数
       {Array} treeDataSource 需要查找的数据源
       {String} valueKey 根据某个属性进行查找
       {Array} targetValue 需要滚动到的节点的key
    返回结果: 返回目标节点前节点的个数