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

@nangxif/filters

v0.1.6

Published

过滤器集

Readme

filters

一个过滤器集

一、包含的过滤器

| 过滤器 | 作用 | | --------------------- | ------------------------------------------------------------ | | filterToYMDT | 将时间转换成规定格式 | | filterToDecimal | 最多保留几位小数 | | filterToSystem | 简单的进制转换 | | filterToSeparation | 规定固定位置用自定义分隔号隔开,用于分隔电话号码以及银行卡号等 | | filterToHide | 转换自定义位置字符 | | filterToTextTransform | 转换大小写,包括全部大小写,首字母大小写等,可兼容多句子 |

二、各自的用法

1.filterToYMDT

| 参数 | 默认值 | 可取值 | 含义 | | --------- | ------ | ------------------------------------- | ------------------------ | | data | / | 时间 | 接收的数据 | | type | YMDT | YMDT、LYMDT、YM、LYM、MD、LMD、YMD、LYMD、WEEK | 转换的类型 | | separator | - | 自定义的分隔字符或者字符串 | 用于分隔日期的分隔符 | | hasZero | true | false/true | 时分秒需不需要保持两位数 |

2.filterToDecimal

| 参数 | 默认值 | 可取值 | 含义 | | ----- | ------ | ------------ | ---------------- | | data | / | 数字,浮点数 | 接收的数据 | | count | 1 | 正整数 | 最多保留几位小数 |

3.filterToSystem

| 参数 | 默认值 | 可取值 | 含义 | | -------------- | ------ | -------- | ------------------------------------ | | data | / | 数字 | 接收的数据 | | originUnit | g | 有效单位 | 小于进制时显示的原始单位 | | transitionUnit | kg | 有效单位 | 大于等于进制时显示的转换单位 | | SystemNum | 1000 | 正整数 | originUnit到transitionUnit的转换进制 | | count | 1 | 正整数 | 转换之后最多保留几位小数 |

4.filterToSeparation

| 参数 | 默认值 | 可取值 | 含义 | | -------- | ------ | ------------ | ---------------- | | data | / | 字符串 | 接收的数据 | | interval | 3 | 正整数 | 隔几位插入symbol | | symbol | , | 自定义分隔符 | 分隔符 |

5.filterToHide

| 参数 | 默认值 | 可取值 | 含义 | | ------ | ------ | ----------------------------------- | ---------------- | | data | / | 数字、字符串 | 接收的数据 | | start | / | 大于等于0的正整数 | 起始位置,包含 | | end | / | 大于start且小于等于data长度的正整数 | 终止位置,不包含 | | symbol | * | 自定义的替换字符 | 替换的字符 |

6.filterToTextTransform

| 参数 | 默认值 | 可取值 | 含义 | | ---- | --------------- | ------------------------------------------------------------ | ------------------ | | data | / | 中英文字符串 | 接收的数据 | | type | AllInitialUpper | AllInitialUpper[全部首字母大写]、AllInitialLower[全部首字母小写]、InitialUpper[所有句子首字母大写]、InitialLower[所有句子首字母小写]、Upper[全部大写]、Lower[全部小写] | 通知过滤器转换方式 |

7.filterToSort

| 参数 | 默认值 | 可取值 | 含义 | | -------- | --------- | --------------------- | ------------------------------------------- | | data | / | 一定格式的数组 | 接收的数据 | | sortType | ascending | ascending/descending | ascending升序/descending降序 | | key | / | data里面元素对象的key | 当data里面的元素是对象的时候,就需要设置key |

三、导入及初始化

1.可以在vue中作为过滤器使用

//按需注册
import Filters from "@nangxif/filters";
Vue.filter("filterToDateAndTime", Filters.filterToDateAndTime);

//一键注册
import Filters from "@nangxif/filters";
Object.keys(Filters).forEach(key => {
  Vue.filter(key, Filters[key]);
});

//eg:
{{ new Date() | filterToDateAndTime }}

2.在js中使用

<script src="filters.min.js"></script>

<script>
Filters.filterToSystem(99,"cm","m",100);
</script>