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

vn-format

v0.3.5

Published

Thư viện tiện ích All-in-one cho lập trình viên Việt Nam

Readme

vn-format

npm version license size

vn-format là bộ thư viện tiện ích (utility library) "All-in-one" dành cho lập trình viên Việt Nam. Mục tiêu là cung cấp các hàm định dạng, xác thực và xử lý dữ liệu đặc thù cho thị trường Việt Nam một cách chuẩn xác, nhẹ và hiệu năng cao.

Tại sao chọn vn-format?

  • 🚀 Zero Dependency: Không phụ thuộc thư viện bên thứ 3, siêu nhẹ.
  • 🇻🇳 Chuẩn Việt Nam: Tối ưu hóa cho các quy tắc tài chính, hành chính và ngữ pháp tiếng Việt.
  • 📦 Modular: Hỗ trợ Tree-shaking (chỉ import những gì bạn cần).
  • 🔧 TypeScript: Viết bằng TypeScript, hỗ trợ autocomplete tuyệt đối.

Cài đặt

npm install vn-format
# hoặc
yarn add vn-format

Tính năng nổi bật

💰 Tài chính: Đọc số thành chữ (hỗ trợ số siêu lớn tỷ tỷ), định dạng tiền tệ, xử lý dấu phẩy/chấm linh hoạt.

🌏 Hành chính: Chuẩn hóa tên Tỉnh/Thành (HCM -> Thành phố Hồ Chí Minh), map thành phố du lịch về tỉnh.

🆔 Định danh: Kiểm tra/Validate số điện thoại, CCCD, Mã số thuế. Tự động nhận diện nhà mạng.

📅 Thời gian: Format ngày tháng, tính thời gian "vừa xong", tính năm Can Chi (Giáp Thìn).

🔤 Chuỗi: Bỏ dấu tiếng Việt, tạo Slug, chuẩn hóa tên người.

Hướng dẫn sử dụng

1. Tài chính (Finance)

import { readMoney, formatVND } from 'vn-format';

// Đọc số thành chữ (Hỗ trợ cấu hình đơn vị, dấu phân cách)
readMoney("10500000"); 
// -> "Mười triệu năm trăm nghìn"

readMoney("100.50", { unit: 'USD', decimalStyle: 'group' });
// -> "Một trăm phẩy năm mươi đô la mỹ"

// Định dạng hiển thị
formatVND(500000); // -> "500.000đ"

2. Địa lý (Location)

Tự động sửa lỗi chính tả và chuẩn hóa tên tỉnh thành.

import { normalizeProvince } from 'vn-format';

normalizeProvince("tphcm"); // -> "Thành phố Hồ Chí Minh"
normalizeProvince("hà tây"); // -> "Hà Nội" (Tự map lịch sử)
normalizeProvince("Đà Lạt"); // -> "Lâm Đồng" (Map địa danh về tỉnh)

3. Thời gian (Date)

import { formatDate, timeAgo, getCanChi } from 'vn-format';

const now = new Date();

formatDate(now, "HH:mm dd/MM/yyyy"); // -> "15:30 14/01/2026"
timeAgo(new Date("2026-01-01")); // -> "2 tuần trước"
getCanChi(2026); // -> "Bính Ngọ"

4. Định danh (Identity)

import { getPhoneNetwork, isValidCCCD } from 'vn-format';

getPhoneNetwork("0981234567"); // -> "Viettel"
isValidCCCD("001096000000"); // -> true

5. Chuỗi (String)

import { removeTone, slugify } from 'vn-format';

removeTone("Nguyễn Mạnh Cường"); // -> "Nguyen Manh Cuong"
slugify("Khai trương nhà máy DEGO"); // -> "khai-truong-nha-may-dego"

Lộ trình phát triển (Roadmap)

  • [x] v0.1.0: Core (Finance & String Utils).
  • [ ] v0.2.0: Identity (Validate CCCD, Mã số thuế, Số điện thoại).
  • [ ] v0.3.0: DateTime (Âm lịch, Ngày lễ Việt Nam).
  • [ ] v1.0.0: Stable Release & Full Unit Test.

Đóng góp

Mọi đóng góp (Pull Requests) đều được hoan nghênh. Vui lòng đọc file CONTRIBUTING.md trước khi bắt đầu.

License

MIT © [Nguyen Manh Cuong]