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

gitlon

v0.2.4

Published

gitlon 生态主包:聚合所有 @gitlon/* 子包并统一导出

Readme

gitlon

gitlon 主包,统一聚合 Gitlon 生态下的工具包。也可以只安装需要的子包,减少依赖范围。

安装

pnpm add gitlon

导入

主包转发各子包的命名导出:

import {
  onLoad,
  onShow,
  formatDate,
  formatMoney,
  isEmail,
  add,
} from 'gitlon'

默认导出仍是 GitlonHooks Vue 插件:

import gitlonHooks from 'gitlon'

app.use(gitlonHooks)

需要使用 dayjs 默认实例时,请从 @gitlon/time 直接导入:

import time from '@gitlon/time'

构建期使用的 Vite 插件从子路径 gitlon/vite 导入:

// vite.config.ts
import { buildVersionPlugin } from 'gitlon/vite'

export default defineConfig({
  plugins: [buildVersionPlugin()],
})

gitlon/vite 依赖 Node 内置模块,只能在 vite.config.ts 等 Node 环境导入;浏览器代码引入会让打包报 node:path 解析失败。

当前子包

| 包名 | 说明 | | --- | --- | | @gitlon/hooks | Vue 3 页面生命周期:onLoad / onShow | | @gitlon/time | dayjs 默认与命名导出 | | @gitlon/format | 日期、数字、金额等展示格式化 | | @gitlon/validate | 常用表单与业务校验 | | @gitlon/math | 防精度丢失的四则运算与精度处理 |

API 总览

Hooks

import { onLoad, onShow } from 'gitlon'

onLoad((query) => {
  console.log(query) // Record<string, string> | undefined
})

onShow(() => {
  console.log('页面显示')
})

onLoadonShow 必须在 Vue 组件 setup()<script setup> 中同步调用。完整行为、Vue 插件配置和 <keep-alive> 用法见 @gitlon/hooks

Format

import {
  formatDate,
  formatDateTime,
  formatMoney,
  formatNumber,
  formatPercent,
  formatFileSize,
  formatPhone,
  formatBankCard,
  formatString,
} from 'gitlon'

formatDate('2026-09-15')
formatMoney(1234567.8, { symbol: '¥' })
formatNumber(1234567.8, { decimals: 2 })
formatPercent(0.1234)
formatFileSize(1024)
formatPhone('13812345678', { mask: true })
formatBankCard('6222021234567890123', { mask: true })
formatString('  hello  ')

日期、金额、数字选项以及空值行为见 @gitlon/format

Validate

import {
  isEmail,
  isPhone,
  isUrl,
  isIdCard,
  isBankCard,
  isNumber,
  isInteger,
  isPositiveNumber,
  isEmpty,
  isDate,
  isChinese,
  isEnglish,
  isSocialCreditCode,
  isPassword,
} from 'gitlon'

isEmail('[email protected]')       // { success: true, message: '' }
isPhone('12812345678')            // { success: false, message: '手机号格式不正确' }
isSocialCreditCode('91330100MA27X9Q42W')
isPassword('Gitlon123')

校验函数统一返回 { success, message } 结果对象,失败时 message 为对应文案,非法输入不会抛异常。完整规则和选项见 @gitlon/validate

Math

import { add, subtract, multiply, divide, round, toFixed } from 'gitlon'

add(0.1, 0.2) // 0.3
subtract(1, 0.1) // 0.9
multiply(0.1, 0.2) // 0.02
divide(0.3, 0.1) // 3
round(1.005, 2) // 1.01
toFixed(1.2, 2) // '1.20'

完整参数、非法输入和多参数计算规则见 @gitlon/math

直接使用子包

pnpm add @gitlon/format @gitlon/validate
import { formatMoney } from '@gitlon/format'
import { isEmail } from '@gitlon/validate'

直接安装子包适合只需要部分能力的项目;@gitlon/hooks 还需要项目提供 Vue 3,vue-router 为可选依赖。