Skip to content

Commit fc9bd9a

Browse files
authored
Merge pull request #1 from BlankRiser/dev
Add support for additional units
2 parents 5d5b149 + f93c510 commit fc9bd9a

16 files changed

Lines changed: 965 additions & 777 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Code quality
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "src/**"
8+
pull_request:
9+
branches: [main]
10+
paths:
11+
- "src/**"
12+
13+
jobs:
14+
quality:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v5
21+
with:
22+
persist-credentials: false
23+
fetch-depth: 0
24+
- name: Setup Biome
25+
uses: biomejs/setup-biome@v2
26+
with:
27+
version: latest
28+
- name: Run Biome
29+
run: biome ci .

.github/workflows/release.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
name: CI
1+
name: Release
22

33
on:
44
workflow_dispatch:
5-
push:
6-
branches: [main]
7-
paths:
8-
- "src/**"
9-
pull_request:
10-
branches: [main]
11-
paths:
12-
- "src/**"
135
release:
146
types: [created]
157

@@ -22,6 +14,8 @@ jobs:
2214
steps:
2315
- name: Checkout
2416
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
2519

2620
- name: Setup Bun
2721
uses: oven-sh/setup-bun@v2

biome.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"formatter": {
4+
"formatWithErrors": true,
5+
"lineWidth": 120,
6+
"indentWidth": 2,
7+
"bracketSpacing": true,
8+
"indentStyle": "space"
9+
}
10+
}

build.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import type { BuildConfig } from 'bun'
1+
import type { BuildConfig } from "bun";
22

3-
import dts from 'bun-plugin-dts'
3+
import dts from "bun-plugin-dts";
44

55
const buildConfig: BuildConfig = {
6-
entrypoints: ['./src/index.ts'],
7-
outdir: './dist',
8-
minify: true,
9-
}
6+
entrypoints: ["./src/index.ts"],
7+
outdir: "./dist",
8+
minify: true,
9+
};
1010

1111
await Promise.all([
12-
Bun.build({
13-
...buildConfig,
14-
plugins: [dts()],
15-
format: 'esm',
16-
naming: "[dir]/[name].js",
17-
}),
18-
Bun.build({
19-
...buildConfig,
20-
format: 'cjs',
21-
naming: "[dir]/[name].cjs",
22-
})
23-
])
12+
Bun.build({
13+
...buildConfig,
14+
plugins: [dts()],
15+
format: "esm",
16+
naming: "[dir]/[name].js",
17+
}),
18+
Bun.build({
19+
...buildConfig,
20+
format: "cjs",
21+
naming: "[dir]/[name].cjs",
22+
}),
23+
]);

package.json

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
11
{
2-
"name": "@devhaven/unit-conversion",
3-
"version": "0.0.5",
4-
"description": "A type-safe unit conversion library.",
5-
"license": "Apache-2.0",
6-
"author": "Ram Shankar Choudhary",
7-
"type": "module",
8-
"main": "./dist/index.js",
9-
"module": "./dist/index.js",
10-
"types": "./dist/index.d.ts",
11-
"exports": {
12-
"types": "./dist/index.d.ts",
13-
"import": "./dist/index.js",
14-
"require": "./dist/index.cjs"
15-
},
16-
"scripts": {
17-
"build": "bun run build.ts",
18-
"dev": "bun --watch run src/index.ts",
19-
"lint": "biome check src",
20-
"lint:fix": "biome check --fix src",
21-
"test": "vitest watch",
22-
"test:run": "vitest run",
23-
"test:watch": "vitest watch",
24-
"test:ui": "vitest --ui"
25-
},
26-
"files": [
27-
"dist"
28-
],
29-
"keywords": [
30-
"bun",
31-
"unit-conversion"
32-
],
33-
"homepage": "https://github.com/BlankRiser/unit-conversion#readme",
34-
"repository": {
35-
"type": "git",
36-
"url": "git+https://github.com/BlankRiser/unit-conversion.git"
37-
},
38-
"bugs": {
39-
"url": "https://github.com/BlankRiser/unit-conversion/issues"
40-
},
41-
"devDependencies": {
42-
"@biomejs/biome": "2.1.3",
43-
"@types/bun": "1.2.19",
44-
"@vitest/ui": "3.2.4",
45-
"bun-plugin-dts": "0.3.0",
46-
"typescript": "5.9.2",
47-
"vitest": "3.2.4"
48-
}
2+
"name": "@devhaven/unit-conversion",
3+
"version": "0.0.5",
4+
"description": "A type-safe unit conversion library.",
5+
"license": "Apache-2.0",
6+
"author": "Ram Shankar Choudhary",
7+
"type": "module",
8+
"main": "./dist/index.js",
9+
"module": "./dist/index.js",
10+
"types": "./dist/index.d.ts",
11+
"exports": {
12+
"types": "./dist/index.d.ts",
13+
"import": "./dist/index.js",
14+
"require": "./dist/index.cjs"
15+
},
16+
"scripts": {
17+
"build": "bun run build.ts",
18+
"dev": "bun --watch run src/index.ts",
19+
"lint": "biome check src",
20+
"lint:fix": "biome check --fix src",
21+
"test": "vitest watch",
22+
"test:run": "vitest run",
23+
"test:watch": "vitest watch",
24+
"test:ui": "vitest --ui",
25+
"check:deps": "bunx knip"
26+
},
27+
"files": [
28+
"dist"
29+
],
30+
"keywords": [
31+
"bun",
32+
"unit-conversion"
33+
],
34+
"homepage": "https://github.com/BlankRiser/unit-conversion#readme",
35+
"repository": {
36+
"type": "git",
37+
"url": "git+https://github.com/BlankRiser/unit-conversion.git"
38+
},
39+
"bugs": {
40+
"url": "https://github.com/BlankRiser/unit-conversion/issues"
41+
},
42+
"devDependencies": {
43+
"@biomejs/biome": "2.1.3",
44+
"@types/bun": "1.2.19",
45+
"@vitest/ui": "3.2.4",
46+
"bun-plugin-dts": "0.3.0",
47+
"typescript": "5.9.2",
48+
"vitest": "3.2.4"
49+
}
4950
}

src/constants/config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export interface ConversionConfig {
2-
isFloat?: boolean;
3-
includeUnit?: boolean;
4-
decimals?: number;
2+
isFloat?: boolean;
3+
includeUnit?: boolean;
4+
decimals?: number;
55
}
66

77
/**
@@ -12,7 +12,7 @@ export interface ConversionConfig {
1212
* @property {number} decimals - Number of decimal places to round the conversion result to. Default is 2.
1313
*/
1414
export const DEFAULT_CONFIG: ConversionConfig = {
15-
isFloat: true,
16-
includeUnit: true,
17-
decimals: 2,
15+
isFloat: true,
16+
includeUnit: true,
17+
decimals: 2,
1818
};

0 commit comments

Comments
 (0)