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

@libs-ui/pipes-format-number

v0.2.356-41

Published

Pipe format số theo ngôn ngữ (EN/VI) với hỗ trợ phân cách hàng nghìn, số thập phân và số âm.

Downloads

2,450

Readme

Format Number Pipe

Pipe format số theo ngôn ngữ (EN/VI) với hỗ trợ phân cách hàng nghìn, số thập phân và số âm.

Tính năng

  • ✅ Format phân cách hàng nghìn (dấu . cho VI, dấu , cho EN)
  • ✅ Định dạng số thập phân với số chữ số tùy chỉnh
  • ✅ Hỗ trợ số âm với option kiểm soát
  • ✅ Chuyển đổi giữa định dạng số có dấu phân cách và số thuần
  • ✅ Hỗ trợ truyền ngôn ngữ trực tiếp vào pipe (EN/VI) hoặc tự động detect từ UtilsCache

Cài đặt

npm install @libs-ui/pipes-format-number

Sử dụng

Trong Template

import { LibsUiPipesFormatNumberPipe } from '@libs-ui/pipes-format-number';
import { UtilsLanguageConstants } from '@libs-ui/utils';

@Component({
  selector: 'app-example',
  standalone: true,
  imports: [LibsUiPipesFormatNumberPipe],
  template: `
    <!-- Tự động detect ngôn ngữ từ UtilsCache -->
    <p>Số: {{ 1234567 | LibsUiPipesFormatNumberPipe: true : 2 }}</p>
    <!-- Output: 1.234.567 (VI) hoặc 1,234,567 (EN) -->

    <!-- Truyền ngôn ngữ trực tiếp -->
    <p>EN: {{ 1234567 | LibsUiPipesFormatNumberPipe: true : 2 : true : false : 'en' }}</p>
    <!-- Output: 1,234,567 -->

    <p>VI: {{ 1234567 | LibsUiPipesFormatNumberPipe: true : 2 : true : false : 'vi' }}</p>
    <!-- Output: 1.234.567 -->
  `,
})
export class ExampleComponent {
  readonly EN = UtilsLanguageConstants.EN;
  readonly VI = UtilsLanguageConstants.VI;
}

Dùng trong TypeScript

Pipe là thin wrapper của hàm viewDataNumberByLanguage trong @libs-ui/utils. Khi cần gọi trong TypeScript, import và dùng thẳng hàm đó — không cần inject pipe:

import { viewDataNumberByLanguage, UtilsLanguageConstants } from '@libs-ui/utils';

// Tự động detect ngôn ngữ từ UtilsCache
const formatted = viewDataNumberByLanguage(1234567.89, true, 2);
// Output: '1.234.567,89' (VI) hoặc '1,234,567.89' (EN)

// Truyền ngôn ngữ trực tiếp
const formattedEN = viewDataNumberByLanguage(1234567.89, true, 2, true, false, UtilsLanguageConstants.EN);
// Output: '1,234,567.89'

const formattedVI = viewDataNumberByLanguage(1234567.89, true, 2, true, false, UtilsLanguageConstants.VI);
// Output: '1.234.567,89'

Công nghệ sử dụng

| Công nghệ | Mô tả | | -------------- | --------------------------------- | | Angular 18+ | Pipe transform với standalone API | | @libs-ui/utils | viewDataNumberByLanguage utility |

API Reference

Pipe Name

LibsUiPipesFormatNumberPipe

Parameters

| Parameter | Type | Default | Description | | --------------------- | ------------------ | ----------- | ------------------------------------------------------------------------------------ | | value | number \| string | required | Giá trị cần format | | acceptNegativeValue | boolean | required | Cho phép giá trị âm | | parseFixed | number | 1 | Số chữ số thập phân tối đa | | ignoreFormatSeparator | boolean | true | Bỏ qua format separator trong input string | | ignoreParseFloat | boolean | undefined | Không parse float | | lang | string | undefined | Ngôn ngữ format ('en' hoặc 'vi'). Nếu không truyền, tự động detect từ UtilsCache |

Usage Syntax

<!-- Cơ bản - tự động detect ngôn ngữ từ UtilsCache -->
{{ value | LibsUiPipesFormatNumberPipe:acceptNegativeValue }}

<!-- Với parseFixed -->
{{ value | LibsUiPipesFormatNumberPipe:acceptNegativeValue:2 }}

<!-- Đầy đủ parameters -->
{{ value | LibsUiPipesFormatNumberPipe:acceptNegativeValue:2:false:false }}

<!-- Với ngôn ngữ cụ thể -->
{{ value | LibsUiPipesFormatNumberPipe:acceptNegativeValue:2:true:false:'en' }} {{ value | LibsUiPipesFormatNumberPipe:acceptNegativeValue:2:true:false:'vi' }}

Unit Tests

Xem chi tiết tại test-commands.md

# Chạy test cho pipe này
npx nx test pipes-format-number
npx nx test pipes-format-number --no-cache

Demo

  • Local: http://localhost:4500/pipes/format-number
  • Production: (sau khi deploy)

License

MIT