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

@mingto/tools

v1.0.687

Published

明途公共工具库

Readme

@mingto/tools

明途公共 TypeScript 工具库,提供类型判断、浏览器工具、文件处理、数学计算、字符串处理、函数控制、下载、WebSocket、Worker、主题和国际化等能力。

安装

pnpm add @mingto/tools

使用方式

import { isString, add, getFileSuffix } from '@mingto/tools'

isString('hello')
add(0.1, 0.2)
getFileSuffix('/demo/file.pdf')

默认导出提供国际化语言设置能力:

import tools from '@mingto/tools'

tools.locale('zh-cn')
tools.getLocale()

模块清单

array

| API | 说明 | |-----|------| | chunkArray | 将数组按指定长度切分 |

browser

| API | 说明 | |-----|------| | copyText | 复制文本到剪贴板 | | createAudioPermission | 创建音频播放权限辅助能力 | | getAbsoluteUrl | 获取绝对 URL | | getBrowserFingerprint | 获取浏览器指纹 | | isAndroid | 判断 Android 环境 | | isIos | 判断 iOS 环境 | | isMobile | 判断移动端环境 | | isPc | 判断 PC 环境 |

core

| API | 说明 | |-----|------| | beParsedAsNumber | 将值按数字解析 | | canBeParsedAsNumber | 判断值是否可解析为数字 | | checkArrayEmpty | 判断数组是否为空 | | checkEmpty | 判断值是否为空 | | checkEmptyNotZero | 判断值是否为空但保留数字 0 | | checkObjectEmpty | 判断对象是否为空 | | isArray | 判断数组 | | isBoolean | 判断布尔值 | | isFunction | 判断函数 | | isNullOrUndefined | 判断 nullundefined | | isNumber | 判断数字 | | isObject | 判断对象 | | isString | 判断字符串 | | isUndefined | 判断 undefined |

file

| API | 说明 | |-----|------| | batchDownloadFile | 批量下载文件 | | getFileIcon | 获取文件图标 | | getFileName | 获取文件名 | | getFilePathNotQuery | 获取去除 query 的文件路径 | | getFilePathQuery | 获取文件路径 query | | getFileSuffix | 获取文件后缀 | | getFileSuffixIcon | 获取文件后缀图标 | | getFileTitle | 获取文件标题 | | isCompressFilePath | 判断压缩文件路径 | | isDocumentFilePath | 判断文档文件路径 | | isFilePath | 判断是否为文件路径 | | isImageFilePath | 判断图片文件路径 | | isMarkdownFilePath | 判断 Markdown 文件路径 | | isMusicFilePath | 判断音频文件路径 | | isPptFilePath | 判断 PPT 文件路径 | | isVideoFilePath | 判断视频文件路径 | | singleDownloadFile | 下载单个文件 | | singleDownloadFileBase64 | 下载 Base64 文件 | | updateFilePathQuery | 更新文件路径 query |

同时导出文件类型枚举与类型:

import type { FileSuffix, ImageFileSuffix } from '@mingto/tools'
import { FileSuffixEnum, ImageFileSuffixEnum } from '@mingto/tools'

function

| API | 说明 | |-----|------| | debounce | 防抖函数 | | throttle | 节流函数 |

math

| API | 说明 | |-----|------| | add | 精确加法 | | subtract | 精确减法 | | multiply | 精确乘法 | | divide | 除法 | | getDecimalPlaces | 获取小数位数 | | calcAspectRatio | 计算宽高比 |

object

| API | 说明 | |-----|------| | deepFreeze | 深冻结对象 | | pickObject | 从对象中选取指定字段 |

string

| API | 说明 | |-----|------| | chunkString | 将字符串按指定长度切分 | | objectToQueryString | 对象转 query string | | queryStringToObject | query string 转对象 |

supply

| API | 说明 | |-----|------| | getUuid | 获取 UUID | | timeDelay | 延迟执行 |

theme

| API | 说明 | |-----|------| | useTheme | 主题相关工具 |

validator

| API | 说明 | |-----|------| | isValidBase64 | 校验 Base64 字符串 | | isValidUrl | 校验 URL |

web-socket

| API | 说明 | |-----|------| | createWebSocket | 创建 WebSocket 连接 | | isWebSocketSupported | 判断当前环境是否支持 WebSocket |

wrker

| API | 说明 | |-----|------| | createWorker | 创建 Worker | | closeWorker | 关闭 Worker |

常用示例

类型判断

import { isArray, isNumber, isObject, isString } from '@mingto/tools'

isArray([1, 2, 3])
isNumber(1)
isObject({ a: 1 })
isString('hello')

精确计算

import { add, divide, multiply, subtract } from '@mingto/tools'

add(0.1, 0.2)
subtract(0.3, 0.1)
multiply(0.1, 0.2)
divide(10, 2)

文件路径处理

import { getFileName, getFileSuffix, getFileTitle, isImageFilePath } from '@mingto/tools'

getFileName('/path/to/demo.png')
getFileTitle('/path/to/demo.png')
getFileSuffix('/path/to/demo.png')
isImageFilePath('/path/to/demo.png')

函数控制

import { debounce, throttle } from '@mingto/tools'

const onResize = debounce(() => {}, 300)
const onScroll = throttle(() => {}, 300)

国际化

支持语言:zh-cnzh-twenmsarthvi

import tools from '@mingto/tools'

tools.locale('en')
const locale = tools.getLocale()

许可证

ISC