@danielsimonjr/mathts-units 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @danielsimonjr/mathts-units
2
+
3
+ Standalone units & dimensional analysis for [MathTS](https://github.com/danielsimonjr/mathts).
4
+
5
+ A focused entry point over the unit system in
6
+ [`@danielsimonjr/mathts-core`](https://www.npmjs.com/package/@danielsimonjr/mathts-core).
7
+ The implementation is re-exported, not duplicated.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install @danielsimonjr/mathts-units
13
+ ```
14
+
15
+ ## What it exports
16
+
17
+ - `Unit` -- dimensional quantity class (`new Unit(5, 'km')`), with `.to()`, `.toBest()`, `.value`, `.type`.
18
+ - `isUnit` / `isUnitValue` -- type guards.
19
+ - `DimensionMismatchError`, `UnitParseError` -- error types.
20
+ - Registry: `BASE_UNITS`, `DERIVED_UNITS`, `ALL_UNITS`, `UNIT_ALIASES`, `getUnitDef`.
21
+ - Prefixes: `SI_PREFIXES`, `BEST_PREFIXES`, `getPrefix`.
22
+ - `DIMENSIONLESS`, `dim`, and the `Dimensions` / `UnitDef` types.
23
+
24
+ ```ts
25
+ import { Unit } from '@danielsimonjr/mathts-units';
26
+ new Unit(100, 'km/h').to('m/s').value; // 27.777...
27
+ ```
28
+
29
+ ## License
30
+
31
+ MIT (c) Daniel Simon Jr.
@@ -0,0 +1 @@
1
+ export { ALL_UNITS, BASE_UNITS, BEST_PREFIXES, DERIVED_UNITS, DIMENSIONLESS, DimensionMismatchError, Dimensions, SI_PREFIXES, UNIT_ALIASES, Unit, UnitDef, UnitParseError, dim, getPrefix, getUnitDef, isUnit, isUnitValue } from '@danielsimonjr/mathts-core';
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ // src/index.ts
2
+ import {
3
+ Unit,
4
+ isUnit,
5
+ isUnitValue,
6
+ DimensionMismatchError,
7
+ UnitParseError,
8
+ DIMENSIONLESS,
9
+ dim,
10
+ BASE_UNITS,
11
+ DERIVED_UNITS,
12
+ ALL_UNITS,
13
+ UNIT_ALIASES,
14
+ getUnitDef,
15
+ SI_PREFIXES,
16
+ BEST_PREFIXES,
17
+ getPrefix
18
+ } from "@danielsimonjr/mathts-core";
19
+ export {
20
+ ALL_UNITS,
21
+ BASE_UNITS,
22
+ BEST_PREFIXES,
23
+ DERIVED_UNITS,
24
+ DIMENSIONLESS,
25
+ DimensionMismatchError,
26
+ SI_PREFIXES,
27
+ UNIT_ALIASES,
28
+ Unit,
29
+ UnitParseError,
30
+ dim,
31
+ getPrefix,
32
+ getUnitDef,
33
+ isUnit,
34
+ isUnitValue
35
+ };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@danielsimonjr/mathts-units",
3
+ "version": "0.1.0",
4
+ "description": "Standalone units & dimensional-analysis for MathTS -- the Unit class, unit registry, and SI prefixes, re-exported as a focused package",
5
+ "author": "Daniel Simon Jr.",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsup src/index.ts --format esm --dts --clean",
23
+ "dev": "tsup src/index.ts --format esm --dts --watch",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "test:coverage": "vitest run --coverage",
27
+ "typecheck": "tsc --noEmit",
28
+ "lint": "eslint src --ext .ts",
29
+ "lint:fix": "eslint src --ext .ts --fix",
30
+ "clean": "rm -rf dist",
31
+ "build:prod": "tsup src/index.ts --format esm --dts --clean --minify --treeshake"
32
+ },
33
+ "dependencies": {
34
+ "@danielsimonjr/mathts-core": "0.1.3",
35
+ "typed-function": "^4.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^25.5.2",
39
+ "tsup": "^8.0.0",
40
+ "typescript": "^5.3.0",
41
+ "vitest": "^4.1.5"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/danielsimonjr/mathts",
49
+ "directory": "units"
50
+ },
51
+ "keywords": [
52
+ "math",
53
+ "typescript",
54
+ "units",
55
+ "dimensional-analysis",
56
+ "physics",
57
+ "conversion",
58
+ "si"
59
+ ]
60
+ }