Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e72fc8b
feat: configure project structure and add tooling setup
hckhanh Nov 2, 2025
4d6b582
ci: add autofix workflow and update test workflows
hckhanh Nov 2, 2025
0306f4f
refactor: standardize code style and fix formatting inconsistencies
hckhanh Nov 2, 2025
a9dc661
feat: add configurations for tsdown and vitest
hckhanh Nov 2, 2025
f7c2368
docs: update README badges for downloads and JSR
hckhanh Nov 3, 2025
2018add
docs: fix README formatting and minor phrasing
hckhanh Nov 3, 2025
fd8724c
docs: refine section titles in README for clarity
hckhanh Nov 3, 2025
cc04905
feat(benchmark): add comprehensive benchmark tests
hckhanh Nov 3, 2025
c23d1b0
ci: update workflows to replace Prettier with Biome
hckhanh Nov 3, 2025
7ac2890
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 3, 2025
7d0f635
chore(deps): update vitest and add CodSpeed plugin
hckhanh Nov 3, 2025
6276590
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 3, 2025
3af8065
chore(deps): remove unused dependencies from devDependencies
hckhanh Nov 3, 2025
42ced12
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 3, 2025
87224cf
ci: enhance autofix workflow with audit fixes and lock sync
hckhanh Nov 3, 2025
e7c3c9b
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 3, 2025
10b69cf
chore(deps): add @vitest/coverage-v8 and clean overrides
hckhanh Nov 3, 2025
d2bf1d8
Add Changesets setup for versioning
hckhanh Nov 3, 2025
28ac86d
Streamline publishes workflow and removes semantic-release
hckhanh Nov 3, 2025
331a9c7
Prepare package for publication
hckhanh Nov 3, 2025
0dbf617
Rename test job to unit-test for clarity
hckhanh Nov 3, 2025
84acc58
Update vitest dependencies to 4.0.6
hckhanh Nov 3, 2025
b287b30
Remove unused coverage and exclude settings
hckhanh Nov 3, 2025
9a327ef
Upgrade esbuild and clean up dependencies
hckhanh Nov 3, 2025
03bbf67
Rename bench description for clarity
hckhanh Nov 3, 2025
8bc3fa1
Update actions and dependencies in workflow
hckhanh Nov 3, 2025
6d61038
Add `override` specifier and fix doc comments
hckhanh Nov 3, 2025
7ca9582
Remove unused `needs` in Deno job
hckhanh Nov 3, 2025
22c2118
Remove unused CODSPEED_TOKEN from workflow
hckhanh Nov 3, 2025
50c9b1b
Downgrade vitest and related packages
hckhanh Nov 3, 2025
cb6aa0a
Remove unused env variables from bench job
hckhanh Nov 3, 2025
555a171
Downgrade esbuild to 0.25.11
hckhanh Nov 3, 2025
3d2341c
Allow non-frozen lockfile in autofix workflow
hckhanh Nov 3, 2025
6673bfe
Add timeout to vitest bench command
hckhanh Nov 3, 2025
9b1d940
Simplify benchmarking configurations
hckhanh Nov 3, 2025
9d8fcf6
Reformat metric data generation loop
hckhanh Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: autofix.ci

on:
pull_request:
branches-ignore:
- 'renovate/**'
push:
branches:
- main

permissions:
contents: read

jobs:
apply:
name: Apply automated fixes
runs-on: ubuntu-latest
if: ${{ github.actor != 'renovate[bot]' && ! contains(github.event.head_commit.author.name , 'renovate[bot]') && ! contains(github.event.head_commit.message , 'chore(release)') }}
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup toolchains
uses: jdx/mise-action@be3be2260bc02bc3fbf94c5e2fed8b7964baf074 # v3.4.0
- name: Install Dependencies
run: pnpm install
- name: Format code
run: pnpm biome check --write
- name: Fix package.json
run: pnpm syncpack fix
- name: Format package.json
run: pnpm syncpack format
- name: Update package lock file
run: pnpm install --fix-lockfile --no-frozen-lockfile
- name: Submit autofix
uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # v1.3.2
with:
fail-fast: false
50 changes: 23 additions & 27 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ jobs:
name: Lints
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'pnpm'
- uses: actions/[email protected]
- name: Setup toolchains
uses: jdx/mise-action@be3be2260bc02bc3fbf94c5e2fed8b7964baf074 # v3.4.0
- name: Install dependencies
run: pnpm install
- name: Prettier check
Expand All @@ -39,15 +33,8 @@ jobs:
node: [18, 20, 21]
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest
- name: Set up Node.js ${{matrix.node}}
uses: actions/setup-node@v4
with:
node-version: ${{matrix.node}}
cache: 'pnpm'
- name: Setup toolchains
uses: jdx/mise-action@be3be2260bc02bc3fbf94c5e2fed8b7964baf074 # v3.4.0
- name: Install dependencies
run: pnpm install
- name: Run unit tests
Expand All @@ -61,19 +48,28 @@ jobs:
environment: [edge-runtime, jsdom, happy-dom]
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'pnpm'
- name: Setup toolchains
uses: jdx/mise-action@be3be2260bc02bc3fbf94c5e2fed8b7964baf074 # v3.4.0
- name: Install dependencies
run: pnpm install
- name: Run unit tests
run: pnpm test -- --environment=${{ matrix.environment }}
benchmark:
name: Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup toolchains
uses: jdx/mise-action@be3be2260bc02bc3fbf94c5e2fed8b7964baf074 # v3.4.0
- name: Install Dependencies
run: pnpm install
- name: Run Benchmarks
uses: CodSpeedHQ/action@4348f634fa7309fe23aac9502e88b999ec90a164 # v4.3.1
with:
run: pnpm vitest bench
mode: 'instrumentation'
token: ${{ secrets.CODSPEED_TOKEN }}
deno:
name: Deno
needs: lints
Expand Down
56 changes: 56 additions & 0 deletions .syncpackrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "./node_modules/syncpack/schema.json",
"sortFirst": [
"name",
"description",
"version",
"productName",
"author",
"homepage",
"repository",
"bugs",
"private",
"publishConfig",
"sideEffects",
"type",
"main",
"module",
"types",
"exports",
"scripts",
"dependencies",
"devDependencies",
"peerDependencies",
"trustedDependencies",
"workspaces",
"packageManager"
],
"sortExports": ["import", "types"],
"sortAz": [
"exports",
"scripts",
"workspaces",
"dependencies",
"devDependencies",
"peerDependencies",
"trustedDependencies"
],
"semverGroups": [
{
"label": "All non-peer dependencies must be pinned",
"range": "",
"dependencyTypes": ["!peer"],
"dependencies": ["**"],
"packages": ["**"]
},
{
"label": "Allow peer deps to be equal or higher than current versions",
"range": ">=",
"dependencyTypes": ["peer"],
"dependencies": ["**"],
"packages": ["**"]
}
],
"formatBugs": false,
"formatRepository": false
}
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# vn-number 🇻🇳

[![JSR Score](https://jsr.io/badges/@hckhanh/vn-number)](https://jsr.io/@hckhanh/vn-number)

🛠 A bunch of utility functions that work with number in 🇻🇳 Vietnamese language

[![NPM Downloads](https://img.shields.io/npm/dw/vn-number)](https://www.npmjs.com/package/vn-number)
[![JSR](https://jsr.io/badges/@hckhanh/vn-number/weekly-downloads)](https://jsr.io/@hckhanh/vn-number)

## Features

- [Zero dependencies](https://jsr.io/@hckhanh/vn-number/dependencies)
Expand All @@ -13,7 +14,7 @@

## Functions

### Read Vietnamese number (một triệu hai trăm năm mươi nghìn)
### Read Vietnamese number

```ts
import { readVnNumber } from '@hckhanh/vn-number'
Expand All @@ -22,7 +23,7 @@ const result = readVnNumber(1250000)
console.log(result) // một triệu hai trăm năm mươi nghìn
```

### Format number in Vietnamese format (1.250.000)
### Format number in Vietnamese format

```ts
import { formatVnNumber } from '@hckhanh/vn-number'
Expand All @@ -31,7 +32,7 @@ const result = formatVnNumber(1250000)
console.log(result) // 1.250.000
```

### Format VN currency (VND) (1.250.000 ₫)
### Format VN currency (VND - ₫)

```ts
import { formatVnCurrency } from '@hckhanh/vn-number'
Expand All @@ -40,7 +41,7 @@ const result = formatVnCurrency(1250000)
console.log(result) // 1.250.000 ₫
```

### Format percentage in Vietnamese format (99,1%)
### Format percentage in Vietnamese format

```ts
import { formatVnPercent } from '@hckhanh/vn-number'
Expand All @@ -51,4 +52,4 @@ console.log(result) // 99,1%

## Release Notes

You can go to [Releases](https://github.com/hckhanh/vn-number/releases) page to see the release notes.
You can go to [the Releases](https://github.com/hckhanh/vn-number/releases) page to see the release notes.
61 changes: 61 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedImports": {
"level": "warn",
"fix": "safe"
}
},
"style": {
"useTemplate": "off",
"useConsistentTypeDefinitions": {
"level": "warn",
"fix": "safe"
},
"useNodejsImportProtocol": {
"level": "warn",
"fix": "safe"
},
"noUnusedTemplateLiteral": {
"level": "warn",
"fix": "safe"
}
},
"nursery": {
"recommended": true
}
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded",
"arrowParentheses": "always"
}
}
}
13 changes: 13 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
coverage:
status:
project:
default:
target: auto
threshold: 1%
patch:
default:
target: auto
threshold: 1%

ignore:
- 'docs'
18 changes: 4 additions & 14 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
{
"name": "@hckhanh/vn-number",
"version": "0.0.0-development",
"license": "MIT",
"exports": "./src/index.ts",
"exclude": [
".github/",
"src/**/*.test.ts",
".git*",
".prettier*",
".*ignore",
"*.yml",
"*.yaml",
"*.config.ts",
".*rc.json",
"package.json",
"renovate.json",
"tsconfig.json"
]
"publish": {
"include": ["LICENSE", "README.md", "src/**/*.ts"]
}
}
4 changes: 4 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tools]
npm = "11.6.2"
node = "24.11.0"
pnpm = "10.20.0"
33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
{
"name": "@hckhanh/vn-number",
"version": "0.0.0-development",
"description": "A bunch of utility functions that work with number in Vietnamese language",
"type": "module",
"version": "0.0.0-development",
"author": {
"name": "Khánh Hoàng",
"email": "[email protected]",
"url": "https://khanh.sh"
},
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"test": "vitest related src/**/*.ts",
"format": "biome check --write",
"test": "vitest",
"test:prettier": "prettier --check ."
},
"author": {
"name": "Khánh Hoàng",
"email": "[email protected]",
"url": "https://khanh.sh"
"devDependencies": {
"@biomejs/biome": "2.3.2",
"@edge-runtime/vm": "3.2.0",
"happy-dom": "13.10.1",
"jsdom": "24.1.1",
"prettier": "3.3.3",
"syncpack": "14.0.0-alpha.23",
"vitest": "1.6.0"
},
"license": "MIT",
"keywords": [
"reader",
"read",
Expand All @@ -41,11 +50,5 @@
"helper-functions",
"helper-script"
],
"devDependencies": {
"@edge-runtime/vm": "3.2.0",
"happy-dom": "13.10.1",
"jsdom": "24.1.1",
"prettier": "3.3.3",
"vitest": "1.6.0"
}
"license": "MIT"
}
Loading
Loading