Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
39 changes: 39 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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 --no-frozen-lockfile
- 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: Fix audit issues
run: pnpm audit --fix
- name: Update package lock file
run: pnpm install --no-frozen-lockfile
- name: Submit autofix
uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # v1.3.2
with:
fail-fast: false
42 changes: 19 additions & 23 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,34 @@ jobs:
secrets: inherit
release:
name: Release
needs: test
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install jq
uses: dcarbone/install-jq-action@v2
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
- 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: Update npm
run: npm install -g npm@latest
- name: Create Release Pull Request or Publish to npm
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
id: changesets
with:
node-version: 'lts/*'
cache: 'pnpm'
- name: Release on GitHub
run: pnpm --package conventional-changelog-conventionalcommits --package semantic-release dlx semantic-release
publish: 'pnpm tsdown && pnpm changeset publish'
commitMode: 'github-api'
title: 'Release new version'
commit: 'Bump version package'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update version for JSR registry
- name: Publish to JSR
run: |
VERSION=$(node -p "require('./package.json').version")
jq --arg version "$VERSION" '.version = $version' jsr.json > jsr.json.tmp
mv jsr.json.tmp jsr.json
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Publish package to JSR
if: env.VERSION != '0.0.0-development'
run: pnpm dlx jsr publish
pnpm dlx jsr publish --allow-dirty
if: steps.changesets.outputs.published == 'true'
96 changes: 45 additions & 51 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,76 +11,70 @@ 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'
- name: Checkout
uses: actions/[email protected]
- name: Setup toolchains
uses: jdx/mise-action@be3be2260bc02bc3fbf94c5e2fed8b7964baf074 # v3.4.0
- name: Install dependencies
run: pnpm install
- name: Prettier check
run: pnpm test:prettier
- name: Biome check
run: pnpm biome check
- name: Syncpack lint
run: pnpm syncpack lint
- name: Syncpack format
run: pnpm syncpack format --check
- name: Checks for known security issues with the installed packages
run: pnpm audit
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: pnpm npm audit signatures
- name: Verify the package for publishing performing all checks and validations
run: pnpm dlx jsr publish --dry-run
node:
name: Node
needs: lints
unit-test:
name: Unit Test
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20, 21]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v3
- 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 Tests
run: pnpm vitest --coverage --reporter=junit --outputFile=test-report.junit.xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
with:
version: latest
- name: Set up Node.js ${{matrix.node}}
uses: actions/setup-node@v4
use_oidc: true
- name: Upload test results to Codecov
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1
if: ${{ !cancelled() }}
with:
node-version: ${{matrix.node}}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Run unit tests
run: pnpm test -- --environment=node
test:
name: Test
needs: lints
use_oidc: true
benchmark:
name: Benchmark
runs-on: ubuntu-latest
strategy:
matrix:
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: Install dependencies
- 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 unit tests
run: pnpm test -- --environment=${{ matrix.environment }}
- name: Run Benchmarks
uses: CodSpeedHQ/action@4348f634fa7309fe23aac9502e88b999ec90a164 # v4.3.1
with:
run: pnpm vitest bench
mode: 'instrumentation'
deno:
name: Deno
needs: lints
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/[email protected]
- name: Install Deno
uses: denoland/setup-deno@v1
uses: denoland/setup-deno@v2.0.3
- name: Type-check the dependencies
run: deno check src/index.ts
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierrc.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .releaserc.json

This file was deleted.

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.
Loading