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

nex-lib

v1.2.3

Published

Lightweight TypeScript/JavaScript utility library: time formatting, URL parsing, HTTP helpers (retry/timeout/query), validation, string/object utils, storage, colorful console. Tree-shaking and full types.

Readme

nex-lib — JavaScript/TypeScript Utility Library

npm version npm downloads license TypeScript

Documentation

轻量、类型友好、支持 Tree‑shaking 的前端工具库。聚焦常用场景:时间格式化、URL 解析、输入校验、对象/字符串工具、控制台彩色日志。

SEO 关键词:JavaScript utils、TypeScript utils、date format、URL parse、validation、object utils、string utils、colorful console, deep merge, camelCase。

安装(Install)

# npm
npm install nex-lib

# pnpm
pnpm add nex-lib

# yarn
yarn add nex-lib

快速开始(Quick Start)

ESM 用法:

import { format, getTimestamp, createWURL, ObjectUtils, StringUtils, ValidationUtils, EchoUtils } from 'nex-lib';

// 时间格式化 / 时间戳
format();                 // 'YYYY-MM-DD HH:mm:ss'
format(1633072800);       // 指定秒数
getTimestamp();           // 毫秒时间戳
getTimestamp(1633072800); // 指定秒数对应的毫秒

// URL 工具
const u = createWURL('https://sub.example.com/path?foo=bar');
u.getMainDomain();      // 'example.com'
u.parseQueryParams();   // { foo: 'bar' }
u.addParamsToURL({ q: 'x' }); // 'https://sub.example.com/path?foo=bar&q=x'
u.isHttps();            // true
u.getPathname();        // '/path'
u.getPort();            // '80'(未显式端口时)

// 校验工具
ValidationUtils.isValidEmail('[email protected]');
ValidationUtils.isValidURL('https://example.com');
ValidationUtils.isValidPhoneNumber('1234567890');
ValidationUtils.isValidDate('2024-02-29');
ValidationUtils.isValidPostalCode('100000');
ValidationUtils.isValidIDCard('11010119900307123X');

// 对象工具
ObjectUtils.deepMerge({ a: 1 }, { b: 2 });
ObjectUtils.deepEqual({ a: 1 }, { a: 1 });
ObjectUtils.judgeTypes([]);      // 'array'
ObjectUtils.keys({ a: 1 });      // ['a']
ObjectUtils.values({ a: 1 });    // [1]

// 字符串工具
StringUtils.toCamelCase('hello_world');   // 'helloWorld'
StringUtils.reverseString('abc');         // 'cba'
StringUtils.ellipsisStr('abcdefghijklmn', 6, 4); // 'abcdef...jklmn'
StringUtils.createRandomStr(8);           // 随机串
StringUtils.countOccurrences('foofoo', 'foo'); // 2

// 彩色日志
EchoUtils.green('OK', { id: 1 });

CommonJS 用法:

const { format, getTimestamp, createWURL, ObjectUtils, StringUtils, ValidationUtils, EchoUtils } = require('nex-lib');

特性(Features)

  • 时间工具:formatgetTimestamp(日期格式化、时间戳)
  • URL 工具:主域名提取、查询参数解析/追加、协议/路径/端口获取
  • 校验工具:邮箱、URL、手机号、日期、邮编、身份证等常见校验
  • 对象工具:深合并、深比较、类型判断、树结构过滤、键值获取
  • 字符串工具:驼峰化、反转、省略、随机串、词频统计、随机颜色
  • 彩色日志:标准 ANSI 彩色输出,调试更友好
  • TypeScript:完善类型定义,IDE 体验良好
  • Tree‑shaking:按需引入,减小包体积
  • 零运行时依赖:更轻、更稳

API 概览(API Overview)

  • format(seconds?: number): string
  • getTimestamp(seconds?: number): number
  • createWURL(url: string){ getMainDomain, parseQueryParams, addParamsToURL, isHttps, getPathname, getPort }
  • ObjectUtilsStringUtilsValidationUtilsEchoUtils

文档(Docs)

许可证(License)

  • ISC