New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

nex-lib

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nex-lib

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.

latest
npmnpm
Version
1.2.3
Version published
Maintainers
1
Created
Source
nex-lib logo

nex-lib — JavaScript/TypeScript Utility Library

npm version npm downloads license TypeScript

Documentation

nex-lib screenshot

轻量、类型友好、支持 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('a@b.com');
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

Keywords

webkubor

FAQs

Package last updated on 20 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts