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

@domain.js/utils

v0.1.0

Published

domain.js utils 通用模块

Readme

@domain.js/utils

Build status codecov

Installation

Documention

Table of contents

Functions

Functions

deepFreeze

Const deepFreeze(object): any

深度冻结一个对象,防止被不小心篡改

Parameters

| Name | Type | | :------ | :------ | | object | any |

Returns

any

Defined in

index.ts:61


inExpired

Const inExpired(time, life): boolean

判断某个秒级时间戳是否已过期,基于当前时间

Parameters

| Name | Type | Description | | :------ | :------ | :------ | | time | number | 要判断的时间 秒级时间戳 | | life | number | 有效期时间长度,单位秒 |

Returns

boolean

Defined in

index.ts:97


lcfirst

Const lcfirst(value): string

首字符小写

Parameters

| Name | Type | | :------ | :------ | | value | string |

Returns

string

Defined in

index.ts:55


md5

Const md5(str): string

计算给定字符串的md5值

Parameters

| Name | Type | | :------ | :------ | | str | Object | | str.toString | () => string |

Returns

string

Defined in

index.ts:11


modifiyURL

Const modifiyURL(address, adds?, removes?): string

修改指定url上添加一些参数

Parameters

| Name | Type | | :------ | :------ | | address | string | | adds? | Params | | removes? | string[] |

Returns

string

Defined in

index.ts:105


nt2space

Const nt2space(value): string

将字符串里的换行,制表符替换为普通空格

Parameters

| Name | Type | | :------ | :------ | | value | string |

Returns

string

Defined in

index.ts:49


randStr

randStr(len, type): string

生成随机字符串,

Parameters

| Name | Type | Description | | :------ | :------ | :------ | | len | number | 要生成的随机串长度 | | type | "strong" | "strong" 强壮型 包括特殊字符 |

Returns

string

Defined in

index.ts:21

randStr(len, type): string

生成随机字符串,

Parameters

| Name | Type | Description | | :------ | :------ | :------ | | len | number | 要生成的随机串长度 | | type | "normal" | "noraml" 普通型 不包括特殊字符 |

Returns

string

Defined in

index.ts:27

randStr(len, type): string

生成随机字符串,

Parameters

| Name | Type | Description | | :------ | :------ | :------ | | len | number | 要生成的随机串长度 | | type | string | string 自定义随机串字典 |

Returns

string

Defined in

index.ts:33


sleep

Const sleep(ms): Promise<unknown>

睡眠等待

Parameters

| Name | Type | | :------ | :------ | | ms | number |

Returns

Promise<unknown>

Defined in

index.ts:58


tryCatchLog

Const tryCatchLog<T, L>(fn, errorLog): (...args: Parameters<T>) => Promise<void>

Type parameters

| Name | Type | | :------ | :------ | | T | extends (...args: any[]) => Promise<void> | | L | extends (...args: any[]) => void |

Parameters

| Name | Type | | :------ | :------ | | fn | T | | errorLog | L |

Returns

fn

▸ (...args): Promise<void>

Parameters

| Name | Type | | :------ | :------ | | ...args | Parameters<T> |

Returns

Promise<void>

Defined in

index.ts:82


ucfirst

Const ucfirst(value): string

首字符大写

Parameters

| Name | Type | | :------ | :------ | | value | string |

Returns

string

Defined in

index.ts:52