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

eleven-methods

v1.0.21

Published

常用方法累计

Readme

工作中常用方法总结

下载

npm i eleven-methods -D

引入

import { ElevenDay } from 'eleven-methods' // 首字母大写 其他一样
const d = new ElevenDay()
// d.方法名
// elevenNum 数字相关
// elevenArr 数组相关
// elevenUrl url相关

使用

d.(方法名)(args)
// 方法调用为当前创建的实例上的方法

1.elevenNum(数字相关)

convertToChinaNum(数字转汉字)

elevenNum.convertToChinaNum(10) // 十

2.elevenDay(时间相关)

2.1 getCurrentYTD (获取当前年的年月日返回数组对象)

elevenDay.getCurrentYTD()

2.2 getCustomYTD (获取自定义年份的年月日返回数组对象)

elevenDay.getCustomYTD('2023')

2.3 AddDays (计算几天后的日期[几天前的日期 传 负数即可])

elevenDay.AddDays(2) // 返回当前日期后两天的日期 字符串
elevenDay.AddDays(-2) // 返回当前日期前两天的日期 字符串

2.4 calcTimeRange (计算时间较当前时间的时间范围)

elevenDay.calcTimeRange('2022-01-06 12:00:00') // 假如当前时间是2022年1月6日 16:01:55 // 此时返回值为 4小时前

2.5 showWeekLastDay (返回本周最后一天的时间)

elevenDay.showWeekLastDay()

2.6 showWeekFirstDay(返回本周第一天的时间)

elevenDay.showWeekFirstDay()

2.7 showMonthFirstDay(返回本月第一天的时间)

elevenDay.showMonthFirstDay()

2.8 showMonthLastDay(返回本月最后一天的时间)

elevenDay.showMonthLastDay()

2.9 getTimeInterval(自定义返回时间间隔)

elevenDay.showMonthLastDay('2022-01-07 12:00:00', '2022-01-07 17:00:00')

3.elevenArr(数组相关)

3.1 filterData(数组对象筛选数组)

// 示例代码
const arr = [1]
const selArr = [{id:1},{id:2},{id:3}]
elevenArr.filterData(arr,selArr,'id') // 第一个参数为目标数组 第二个为筛选的数字 第三个为筛选的属性 
// [{id:1}]

3.2 splitArr(根据长度生成对应的二维数组)

var arr = [1,2,3,4,5,6]
elevenArr.splitArr(arr,2) // [[1,2],[3,4],[5,6]]

3.3 filter兼容写法

// 在需要兼容的文件头部引用方法即可 
// 因filter 被添加到 ECMA-262 标准第 5 版中,因此在某些实现环境中不被支持。 例如 ie8 等等
elevenArr.compatibleWithTheFilter()

3.4 flatDeep(无限嵌套数组扁平化)

// 如果不清楚当前数组下有多少嵌套 则传Infinity 表示一直到将数组全部扁平化才停止 
var arr = [1,[2,3],4,[5,[6,7,[8],0]]]
elevenArr.flatDeep(arr,Infinity) // 第一个入参为嵌套的数组数据 第二个 看上一层提示将对应参数传入 第三个入参默认为当前的数据不为undefined 的情况 如需过滤其他数据 则在第三个入参加入 运行即可
// 出自 MDN JavaScript flat 方法拓展  

4.elevenUrl(url相关)

4.1 getURLString (获取url传递的参数)

elevenUrl.getURLString(arg) // 其中arg为你想获取到的参数属性
// www.baidu.com?a=1 
elevenUrl.getURLString('a')//1

4.2 changeURLArg (修改url传递的参数)

var url = 'www.baidu.com?a=1'
elevenUrl.changeURLArg(url,'a',2) // www.baidu.com?a=2

5.elevenOther(其他)

5.1 动态添加js

elevenOther.loadJs('js地址',回调函数)

5.2 查找多级数组对象下的某个字段值并以数组形式返回

elevenOther.findField('字段名','需要筛选的数据集')

正则相关

使用

import RegularArrangement from 'eleven-methods/utils/regular/index'
var r = new RegularArrangement()
r.regularStatistics('金钱') // 此时会打印出金钱相关的正则  在f12 控制台 需要啥复制啥即可 
// 方法入参有几种情况: "校验数字" "校验字符" "特殊情况" "金钱"