Skip to content

Commit

Permalink
feat(energy): update "best" array to use SI prefixed units (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
furrycatherder authored Sep 11, 2024
1 parent 34ead41 commit 994fca7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@
"size-limit": [
{
"brotli": true,
"limit": "5.46 KB",
"limit": "5.49 KB",
"path": "./dist/index.js"
},
{
"gzip": true,
"limit": "6.88 KB",
"limit": "6.91 KB",
"path": "./dist/index.js"
},
{
"brotli": true,
"limit": "5.23 KB",
"limit": "5.27 KB",
"path": "./dist/index.mjs"
},
{
"gzip": true,
"limit": "6.64 KB",
"limit": "6.67 KB",
"path": "./dist/index.mjs"
}
]
Expand Down
14 changes: 11 additions & 3 deletions src/conversions/measures/energy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ import { type Measure, MeasureKind } from '../types';

export const energy: Measure = {
kind: MeasureKind.Energy,
best: ['J'],
best: ['GWh', 'MWh', 'kWh', 'Wh', 'J'],
units: [
{ names: ['joule', 'joules'], symbols: ['J'], ratio: 1 },
...expandMacro(Macros.si, { names: ['joule', 'joules'], symbols: ['J'], ratio: 1 }),
...expandMacro(Macros.si, {
names: ['joule', 'joules'],
symbols: ['J'],
ratio: 1,
}),

// https://en.wikipedia.org/wiki/Kilowatt-hour
{ names: ['watt-hour'], symbols: ['W⋅h', 'W h', 'Wh'], ratio: 3600 },
...expandMacro(Macros.si, { names: ['watt-hour', 'watt-hours'], symbols: ['W⋅h', 'W h', 'Wh'], ratio: 3600 }),
...expandMacro(Macros.si, {
names: ['watt-hour', 'watt-hours'],
symbols: ['W⋅h', 'W h', 'Wh'],
ratio: 3600,
}),
],
};

0 comments on commit 994fca7

Please sign in to comment.