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

@edgenets/utils

v0.4.1

Published

Edgenets utilities package containing common types and utilities.

Readme

@edgenets/utils

A shared TypeScript utility library for the Edgenets ecosystem.
Provides logging, type helpers, environment config, validation, and other reusable tools.

Designed for Firebase Cloud Functions and pnpm monorepo projects.

Table of contents

edgenets-utils/
├── src/
│   ├── assert/        → 运行时断言,辅助强制类型收窄
│   ├── env/           → 环境变量获取、校验、缓存
│   ├── logger/        → 日志封装,默认 pino,支持 mockLogger
│   ├── date/          → 时间封装(基于 Intl + dayjs adapter)
│   │   ├── format.ts         # 格式化相关函数
│   │   ├── diff.ts           # 时间差计算
│   │   └── index.ts          # 模块导出
│   ├── errors/        → 异常封装
│   │   ├── codes.ts          # 错误枚举 ErrorCode
│   │   ├── messages.ts       # 可选:错误码 → 默认提示
│   │   ├── app-error.ts      # 错误基类 AppError
│   │   └── index.ts          # 统一导出
│   ├── validation/    → 基于 zod,但可插拔(保持 adapter 模式)
│   ├── constants/     → 项目常量、枚举(跨模块复用)
│   ├── types/         → 基础类型工具(如 DeepPartial、Awaitable)
│   ├── string/        → 字符串工具,如 slug、uuid 等
│   ├── array/         → 数组处理,如 groupBy、uniqueBy
│   ├── object/        → 对象深拷贝、merge 等
│   └── index.ts       → 仅 re-export,核心 API 明确暴露
├── .gitignore
├── package.json       # name: @edgenets/utils
├── tsconfig.json
└── README.md

Usage

Error handling

import { AppError, ErrorCode } from '@edgenets/utils'

function checkToken(token?: string) {
  if (!token) {
    throw new AppError(ErrorCode.AUTH_VAL_TOKEN_INVALID)
  }
}

Logging handling

import { getLogger, setGlobalLogger, createConsoleLogger } from '@edgenets/utils'

// 设置全局等级
setGlobalLogger(createConsoleLogger('debug'))

const logger = getLogger()

logger.info('App started')
logger.debug('Debug message')

ID generation

import { NanoIdUtil } from '@edgenets/utils'

const id = NanoIdUtil.generateDefault(12)         // ab8X0kTzG7Q9
const custom = NanoIdUtil.generateCustom(6, 'xyz') // xyyzyz
const numericId = NanoIdUtil.generateNumberId()    // 1073132153242091