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

fat-lib

v1.1.0

Published

some function

Readme

fat_lib

刚创建的自用工具库,变动较大,不适合用于生产环境

Data

getAllKeys

function getAllKeys(array: Object[]): string[]

获取数据的全部keys

leftJoin

function leftJoin( 
config: {
    leftArray: Object[], 
    rightArray: Object[], 
    keys: string | string[], 
    filed?: string | string[], 
    fillValue?: string | number | "preValue" | undefined | null
    })
:any[]

这个函数能根据keys左连接两个数组,并根据params返回一个新数组。

This function merges two arrays according to keys and returns a new array based on params.

innerJoin

function innerJoin(     
config: {
    leftArray: Object[], 
    rightArray: Object[], 
    keys: string | string[], 
    filed?: string | string[], 
    fillValue?: string | number | "preValue" | undefined | null
    })
: any[]

这个函数能根据keys内连接两个数组,并根据params返回一个新数组。

This function merges two arrays according to keys and returns a new array based on params.

math

数学运行相关方法

sum

计算数组的总和

avg

计算数组的平均数

std

计算数组的标准差

variance

计算数组的方差

promise

run

使用run(Promise)运行异步函数,无需使用try...catch...捕获错误,返回结果为[error,result]

singleRunning

function singleRunning( fn: Function): () => Promise<void>

根据传入的函数,生成一个新的函数,仅允许单次运行,防止函数重复运行

usePolling

function usePolling( 
    fn: Promise<any>
)
:   {
    start: (ms: number) => void, 
    stop: () => void
    }

根据传入的函数,生成一个新的函数,使用start()方法开始轮询,使用stop()方法结束轮询

string

replaceMany

function replaceMany(
    word: string,
    regList: [(string | RegExp), string][]
    )
: string

根据二维数据的规则,按顺序批量替换word中的字符串,返回新的word

time

formatDate

function formatDate( date?: Date | string, formatter?: string): string

指定年月日的显示格式, 根据y、m、d的数量控制字符长度, 转换后的格式默认为yyyy-mm-dd

isWorkday

function isWorkday(     
    date?: string | Date,     
    officialHoliday?: (string | Date)[],     
    dayOff?: (string | Date)[]
    )
: boolean

判断date是否为工作日,可传入法定节假日数组officialHoliday和调休日数组dayOff

getTodayMilliseconds

获取当日时间,用微秒数表示

getTodaySeconds

获取当日时间,用秒数表示

touch

useTouch

function useTouchEvent(     
params: {
    el?: HTMLElement, 
    left?: Function, 
    right?: Function, 
    up?: Function, 
    down?: Function, 
    start?: Function, 
    move?: Function | null, 
    direction?: "x" | "y"
    })
: {remove(): void}

为给定DOM元素绑定触摸事件,返回.remove方法为自销毁程序

type

typeReal

function typeReal(obj: any): string

获取数据类型

request

createAxios

function createAxios(
config: {
    base_url?: string | undefined, 
    retries?: number | undefined, 
    timeout?: number | undefined, 
    retryDelay?: ((retryCount: number, error: AxiosError<unknown, any>) => number) | undefined
    })
: AxiosInstance

快速创建可重试的axios请求主体