From b4d1276276c3b85533629caa671c688a871215a2 Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 7 Mar 2026 11:20:54 +0000 Subject: [PATCH] Fix unit definitions and sync registry --- calculators_list.md | 203 +++++++++++++----- .../lib/components/QuickDefinitionCard.svelte | 4 +- hdyc-svelte/src/lib/data/calculators.ts | 54 ++++- hdyc-svelte/src/lib/data/unitDefinitions.ts | 25 ++- 4 files changed, 214 insertions(+), 72 deletions(-) diff --git a/calculators_list.md b/calculators_list.md index 76cc193..072f05d 100644 --- a/calculators_list.md +++ b/calculators_list.md @@ -31,6 +31,7 @@ The registry currently contains 416 unique calculator slugs. | Attograms to Femtograms – To compare particle masses, convert 150 attograms into femtograms. | attograms-to-femtograms | 0.001 | | Bar to Pascal | bar-to-pascal | 100000.0 | | Bar to PSI | bar-to-psi | 14.5037738 | +| Pascal to Barye – Convert pascals into CGS barye units for historical reference. | pascal-to-barye | 10.0 | | Pascal to Bar – Convert pascals back into bars for quick pressure comparisons. | pascal-to-bar | 1e-05 | | Pascal to Dynes per sq cm – Translate SI pressure into CGS dynes per square centimeter. | pascal-to-dynes-per-sq-cm | 10.0 | | Pascal to kPa – Convert pascals into kilopascals. | pascal-to-kpa | 0.001 | @@ -39,9 +40,12 @@ The registry currently contains 416 unique calculator slugs. | Pascal to PSI – Convert pascals to pounds per square inch. | pascal-to-psi | 0.000145038 | | Pascal to Technical atmosphere – Convert pascals to technical atmospheres (kgf/cm²). | pascal-to-technical-atmosphere | 0.000010197162 | | Pascal to Torr – Convert pascals into torr for vacuum work. | pascal-to-torr | 0.00750062 | +| Pascal-seconds to Centipoise – Convert Pascal-second viscosity into centipoise. | pascal-seconds-to-centipoise | 1000.0 | +| Poise to Pascal-seconds – Express CGS poise viscosity in Pascal-seconds. | poise-to-pascal-seconds | 0.1 | | Becquerel to Curie | becquerel-to-curie | 2.7027027e-11 | | Becquerel to Rutherford | becquerel-to-rutherford | 0.000001 | | Bits to Bytes | bits-to-bytes | 0.125 | +| Nibbles to Bits – Each 4-bit nibble stores exactly four bits in digital streams. | nibbles-to-bits | 4 | | Words (16-bit) to Bits – Convert 16-bit words into raw bits for archive calculations. | words-16-bit-to-bits | 16.0 | | Words (16-bit) to Bytes – Express a 16-bit word as a pair of bytes. | words-16-bit-to-bytes | 2.0 | | Words (32-bit) to Bits – Convert 32-bit words into bits for framing larger registers. | words-32-bit-to-bits | 32.0 | @@ -66,6 +70,7 @@ The registry currently contains 416 unique calculator slugs. | Amps to Kilowatts | amps-to-kilowatts | Multi-Variable | | Amps to kVA | amps-to-kva | Multi-Variable | | Ampere-turns per meter to Oersted – Convert magnetomotive force per meter into oersted units. | ampere-turns-per-meter-to-oersted | 0.0125663706143592 | +| Oersted to Ampere-turns per meter – Flip the CGS oersted field scale back into ampere-turns per meter. | oersted-to-ampere-turns-per-meter | 79.57747154594767 | | Amps to Milliamps – Translate amperes into milliamperes when tuning circuit currents. | amps-to-milliamps | 1000.0 | | Carats to Grams | carats-to-grams | 0.2 | | Celsius to Fahrenheit | celsius-to-fahrenheit | Linear Offset (1.8x + 32) | @@ -175,6 +180,10 @@ The registry currently contains 416 unique calculator slugs. | Dynes to Pound-force – Turn dynes into the more intuitive pound-force units. | dynes-to-pound-force | 0.0000022480894311287591 | | Dynes to Kilonewtons – Scale dynes all the way into kilonewtons for SI reporting. | dynes-to-kilonewtons | 1e-08 | | Ounces to Grams | ounces-to-grams | 28.3495 | +| Ounces to Grains – Convert avoirdupois ounces into grains. | ounces-to-grains | 437.5 | +| Ounces to Kilograms – Express avoirdupois ounces in kilograms. | ounces-to-kilograms | 0.0283495 | +| Ounces to Milligrams – Move ounces into milligram measurements. | ounces-to-milligrams | 28349.523125 | +| Ounces to Troy Ounces – Convert avoirdupois ounces into troy ounces. | ounces-to-troy-ounces | 0.9114583333333333 | | Kilogram-force Meters to Dyne-centimeters – Flip kilogram-force meters back into dyne-centimeters. | kilogram-force-meters-to-dyne-centimeters | 98066500.0 | | Kilogram-force Meters to Foot-pounds – Express a kilogram-force meter as foot-pounds of torque. | kilogram-force-meters-to-foot-pounds | 7.233013851209897 | | Kilogram-force Meters to Inch-pounds – Turn a kilogram-force meter into inch-pounds. | kilogram-force-meters-to-inch-pounds | 86.79616621451876 | @@ -232,6 +241,10 @@ The registry currently contains 416 unique calculator slugs. | Light years to Astronomical units | light-years-to-astronomical-units | 63241.077 | | Light years to Parsecs | light-years-to-parsecs | 0.306601394 | | Liters per second to Gallons per minute | liters-per-second-to-gallons-per-minute | 15.8503231 | +| Parsecs to Astronomical Units – Translate parsec distances into astronomical units. | parsecs-to-astronomical-units | 206265.0 | +| Parsecs to Kilometers – Turn parsecs into kilometers for cosmic scales. | parsecs-to-kilometers | 3.08567758149137e13 | +| Parsecs to Light Years – Express parsecs as light years. | parsecs-to-light-years | 3.261563777 | +| Parsecs to Miles – Express parsecs in statute miles. | parsecs-to-miles | 1.9181367e13 | | Liters to Gallons | liters-to-gallons | 0.264172052 | | Liters to Pints | liters-to-pints | 2.11337642 | | Liters to Quarts | liters-to-quarts | 1.05668821 | @@ -248,6 +261,12 @@ The registry currently contains 416 unique calculator slugs. | Decimal to Octal | decimal-to-octal | 10_to_8 | | Hex to Binary | hex-to-binary | 16_to_2 | | Hex to Decimal | hex-to-decimal | 16_to_10 | +| Octal to Binary – Convert base-8 digits into binary sequences. | octal-to-binary | 8_to_2 | +| Octal to Decimal – Convert octal numbers into decimal values. | octal-to-decimal | 8_to_10 | +| Octal to Hex – Express octal numbers as hexadecimal digits. | octal-to-hex | 8_to_16 | +| Octal to Binary – Convert base-8 numbers into binary digits. | octal-to-binary | 8_to_2 | +| Octal to Decimal – Convert base-8 digits into decimal values. | octal-to-decimal | 8_to_10 | +| Octal to Hex – Express octal numbers as hexadecimal. | octal-to-hex | 8_to_16 | | Watts to amps | watts-to-amps | Multi-Variable | | Volts to amps | volts-to-amps | Multi-Variable | | Volts to Abvolts – Convert SI volts into CGS abvolts. | volts-to-abvolts | 1e+08 | @@ -309,16 +328,39 @@ The registry currently contains 416 unique calculator slugs. | Rad to gray | rad-to-gray | 0.01 | | PSI to megapascals | psi-to-megapascals | 0.006895 | | PSI to bar | psi-to-bar | 0.068948 | +| PSI to kPa – Convert pounds per square inch into kilopascals. | psi-to-kpa | 6.89476 | +| PSI to Pascals – Convert PSI into pascals for SI clarity. | psi-to-pascal | 6894.76 | +| PSI to mmHg – Express PSI in millimeters of mercury. | psi-to-mmhg | 51.7149 | +| PSI to Torr – Express PSI in torr for vacuum work. | psi-to-torr | 51.7149 | | PPI to DPI | ppi-to-dpi | 1 | | Pounds to tons | pounds-to-tons | 0.0005 | | Pounds to stones | pounds-to-stones | 0.071428 | | Pounds to ounces | pounds-to-ounces | 16 | | Pounds to kilograms | pounds-to-kilograms | 0.45359 | | Pints to liters | pints-to-liters | 0.473176 | +| Pints to Cups – Convert pints into cups for cooking measures. | pints-to-cups | 2 | +| Pints to Gallons – Convert pints into gallons for volume tracking. | pints-to-gallons | 0.125 | +| Pints to Quarts – Convert pints into quarts for canning ratios. | pints-to-quarts | 0.5 | | Percent to PPM | percent-to-ppm | 10000 | | Percent ABV to Proof – Convert alcohol by volume into US proof values (Proof = 2 × ABV). | percent-abv-to-proof | 2 | +| Proof to Percent ABV – Convert US proof back into ABV (ABV = Proof / 2). | proof-to-percent-abv | 0.5 | +| PPB to PPM – Convert parts per billion into ppm. | ppb-to-ppm | 0.001 | +| PPM to mg/L – For dilute aqueous solutions, treat ppm as mg per liter. | ppm-to-mg-per-liter | 1 | +| PPM to Percent – Convert ppm values into percent by mass. | ppm-to-percent | 0.0001 | +| PPM to PPB – Convert parts per million into parts per billion. | ppm-to-ppb | 1000 | +| Planck mass to Kilograms – Convert the Planck mass into SI kilograms. | planck-mass-to-kilograms | 2.176434e-08 | +| Planck time to Seconds – Express Planck time in seconds. | planck-time-to-seconds | 5.391247e-44 | +| Points (compass) to Degrees – Convert compass points into degrees. | points-compass-to-degrees | 11.25 | +| Points to Inches – Translate typography points into inches for layout work. | points-to-inches | 0.0138889 | +| Points to Pixels – Convert typographic points into CSS pixels at 96 DPI. | points-to-pixels | 1.333333 | +| Pixels per centimeter to DPI – Convert pixels per centimeter into dots per inch (multiplying by 2.54). | pixels-per-centimeter-to-dpi | 2.54 | +| Pixels to Points – Convert CSS pixels into typographic points at 96 DPI. | pixels-to-points | 0.75 | | Pennyweights to grams | pennyweights-to-grams | 1.55517 | | Pennyweights to Troy Ounces – Convert pennyweights into troy ounces (1 pennyweight = 0.05 troy ounces). | pennyweights-to-troy-ounces | 0.05 | +| Picocurie to Becquerel – A tiny radiation dose expressed in picocuries converts to becquerels. | picocurie-to-becquerel | 0.037 | +| Picofarads to Microfarads – Convert tiny capacitances into microfarads for circuit design. | picofarads-to-microfarads | 1e-6 | +| Picograms to Nanograms – Express picogram masses as nanograms for lab reporting. | picograms-to-nanograms | 0.001 | +| Picometers to Angstroms – Translate picometers into angstroms for nanoscale distances. | picometers-to-angstroms | 0.01 | | Pascals to inches of water | pascals-to-inches-of-water | 0.004015 | | Pascals to inches of mercury | pascals-to-inches-of-mercury | 0.000295 | | Pascal to atmosphere | pascal-to-atmosphere | 9.869e-06 | @@ -329,6 +371,7 @@ The registry currently contains 416 unique calculator slugs. | Metric tons to long tons | metric-tons-to-long-tons | 0.9842 | | Lumens to candela | lumens-to-candela | 0.079577 | | GSM to Ounces per sq yard – Convert GSM to Ounces per sq yard instantly. | gsm-to-ounces-per-sq-yard | 0.02952 | +| Ounces per sq yard to GSM – Convert fabric weight from ounces per square yard into grams per square meter. | ounces-per-sq-yard-to-gsm | 33.906074 | | Hands to Centimeters – Convert Hands to Centimeters instantly. | hands-to-centimeters | 10.16 | | Hands to Inches – Convert Hands to Inches instantly. | hands-to-inches | 4 | | Hartree to Electron-volts – Convert Hartree to Electron-volts instantly. | hartree-to-electron-volts | 27.2114 | @@ -844,6 +887,10 @@ The registry currently contains 416 unique calculator slugs. - [x] Rad to gray (`rad-to-gray`) - [x] PSI to megapascals (`psi-to-megapascals`) - [x] PSI to bar (`psi-to-bar`) +- [x] PSI to kPa (`psi-to-kpa`) +- [x] PSI to Pascal (`psi-to-pascal`) +- [x] PSI to mmHg (`psi-to-mmhg`) +- [x] PSI to Torr (`psi-to-torr`) - [x] PPI to DPI (`ppi-to-dpi`) - [x] Pounds to tons (`pounds-to-tons`) - [x] Pounds to stones (`pounds-to-stones`) @@ -852,11 +899,31 @@ The registry currently contains 416 unique calculator slugs. - [x] Pints to liters (`pints-to-liters`) - [x] Percent to PPM (`percent-to-ppm`) - [x] Percent ABV to Proof (`percent-abv-to-proof`) +- [x] Proof to Percent ABV (`proof-to-percent-abv`) +- [x] PPB to PPM (`ppb-to-ppm`) +- [x] PPM to mg/L (`ppm-to-mg-per-liter`) +- [x] PPM to Percent (`ppm-to-percent`) +- [x] PPM to PPB (`ppm-to-ppb`) +- [x] Planck mass to Kilograms (`planck-mass-to-kilograms`) +- [x] Planck time to Seconds (`planck-time-to-seconds`) +- [x] Points (compass) to Degrees (`points-compass-to-degrees`) +- [x] Points to Inches (`points-to-inches`) +- [x] Points to Pixels (`points-to-pixels`) +- [x] Pixels per centimeter to DPI (`pixels-per-centimeter-to-dpi`) +- [x] Pixels to Points (`pixels-to-points`) +- [x] Picocurie to Becquerel (`picocurie-to-becquerel`) +- [x] Picofarads to Microfarads (`picofarads-to-microfarads`) +- [x] Picograms to Nanograms (`picograms-to-nanograms`) +- [x] Picometers to Angstroms (`picometers-to-angstroms`) +- [x] Pints to Cups (`pints-to-cups`) +- [x] Pints to Gallons (`pints-to-gallons`) +- [x] Pints to Quarts (`pints-to-quarts`) - [x] Pennyweights to grams (`pennyweights-to-grams`) - [x] Pennyweights to Troy Ounces (`pennyweights-to-troy-ounces`) - [x] Pascals to inches of water (`pascals-to-inches-of-water`) - [x] Pascals to inches of mercury (`pascals-to-inches-of-mercury`) - [x] Pascal to Bar (`pascal-to-bar`) +- [x] Pascal to Barye (`pascal-to-barye`) - [x] Pascal to Dynes per sq cm (`pascal-to-dynes-per-sq-cm`) - [x] Pascal to kPa (`pascal-to-kpa`) - [x] Pascal to Megapascals (`pascal-to-megapascals`) @@ -864,7 +931,9 @@ The registry currently contains 416 unique calculator slugs. - [x] Pascal to PSI (`pascal-to-psi`) - [x] Pascal to Technical atmosphere (`pascal-to-technical-atmosphere`) - [x] Pascal to Torr (`pascal-to-torr`) +- [x] Pascal-seconds to Centipoise (`pascal-seconds-to-centipoise`) - [x] Pascal to atmosphere (`pascal-to-atmosphere`) +- [x] Poise to Pascal-seconds (`poise-to-pascal-seconds`) - [x] Ounces to pounds (`ounces-to-pounds`) - [x] Newton-meters to foot-pounds (`newton-meters-to-foot-pounds`) - [x] Nanometers to micrometers (`nanometers-to-micrometers`) @@ -971,6 +1040,47 @@ The registry currently contains 416 unique calculator slugs. - [x] Zeptograms to Ounces (`zeptograms-to-ounces`) - [x] Zeptograms to Pounds (`zeptograms-to-pounds`) +- [x] Nibbles to Bits (`nibbles-to-bits`) +- [x] Octal to Binary (`octal-to-binary`) +- [x] Octal to Decimal (`octal-to-decimal`) +- [x] Octal to Hex (`octal-to-hex`) +- [x] Oersted to Ampere-turns per meter (`oersted-to-ampere-turns-per-meter`) +- [x] Ounces per sq yard to GSM (`ounces-per-sq-yard-to-gsm`) +- [x] Ounces to Grains (`ounces-to-grains`) +- [x] Ounces to Kilograms (`ounces-to-kilograms`) +- [x] Ounces to Milligrams (`ounces-to-milligrams`) +- [x] Ounces to Troy Ounces (`ounces-to-troy-ounces`) +- [x] Parsecs to Astronomical Units (`parsecs-to-astronomical-units`) +- [x] Parsecs to Kilometers (`parsecs-to-kilometers`) +- [x] Parsecs to Light Years (`parsecs-to-light-years`) +- [x] Parsecs to Miles (`parsecs-to-miles`) +- [x] Planck mass to Kilograms (`planck-mass-to-kilograms`) +- [x] Planck time to Seconds (`planck-time-to-seconds`) +- [x] Points (compass) to Degrees (`points-compass-to-degrees`) +- [x] Points to Inches (`points-to-inches`) +- [x] Points to Pixels (`points-to-pixels`) +- [x] Pixels per centimeter to DPI (`pixels-per-centimeter-to-dpi`) +- [x] Pixels to Points (`pixels-to-points`) +- [x] Proof to Percent ABV (`proof-to-percent-abv`) +- [x] PPB to PPM (`ppb-to-ppm`) +- [x] PPM to mg/L (`ppm-to-mg-per-liter`) +- [x] PPM to Percent (`ppm-to-percent`) +- [x] PPM to PPB (`ppm-to-ppb`) +- [x] PSI to kPa (`psi-to-kpa`) +- [x] PSI to Pascal (`psi-to-pascal`) +- [x] PSI to mmHg (`psi-to-mmhg`) +- [x] PSI to Torr (`psi-to-torr`) +- [x] Pascal to Barye (`pascal-to-barye`) +- [x] Pascal-seconds to Centipoise (`pascal-seconds-to-centipoise`) +- [x] Poise to Pascal-seconds (`poise-to-pascal-seconds`) +- [x] Picocurie to Becquerel (`picocurie-to-becquerel`) +- [x] Picofarads to Microfarads (`picofarads-to-microfarads`) +- [x] Picograms to Nanograms (`picograms-to-nanograms`) +- [x] Picometers to Angstroms (`picometers-to-angstroms`) +- [x] Pints to Cups (`pints-to-cups`) +- [x] Pints to Gallons (`pints-to-gallons`) +- [x] Pints to Quarts (`pints-to-quarts`) + ## Backlog / To-Do - [x] Acres to hectares - [x] Acres to square feet @@ -1565,68 +1675,47 @@ The registry currently contains 416 unique calculator slugs. - [x] Newtons to Kilogram-force (`newtons-to-kilogram-force`) - [x] Newtons to Kilonewtons (`newtons-to-kilonewtons`) - [x] Newtons to Pound-force (`newtons-to-pound-force`) -- [ ] Nibbles to Bits -- [ ] Octal to Binary -- [ ] Octal to Decimal -- [ ] Octal to Hex -- [ ] Oersted to Ampere-turns per meter -- [ ] Ounces per sq yard to GSM -- [ ] Ounces to Grains -- [ ] Ounces to Kilograms -- [ ] Ounces to Milligrams -- [ ] Ounces to Troy Ounces -- [ ] Parsecs to Astronomical Units -- [ ] Parsecs to Kilometers -- [ ] Parsecs to Light Years -- [ ] Parsecs to Miles -- [x] Pascal to Bar (`pascal-to-bar`) -- [ ] Pascal to Barye -- [x] Pascal to Dynes per sq cm (`pascal-to-dynes-per-sq-cm`) -- [x] Pascal to kPa (`pascal-to-kpa`) -- [x] Pascal to Megapascals (`pascal-to-megapascals`) -- [x] Pascal to mmHg (`pascal-to-mmhg`) -- [x] Pascal to PSI (`pascal-to-psi`) -- [x] Pascal to Technical atmosphere (`pascal-to-technical-atmosphere`) -- [x] Pascal to Torr (`pascal-to-torr`) -- [ ] Pascal-seconds to Centipoise +- [x] Nibbles to Bits (`nibbles-to-bits`) +- [x] Octal to Binary (`octal-to-binary`) +- [x] Octal to Decimal (`octal-to-decimal`) +- [x] Octal to Hex (`octal-to-hex`) +- [x] Oersted to Ampere-turns per meter (`oersted-to-ampere-turns-per-meter`) +- [x] Ounces per sq yard to GSM (`ounces-per-sq-yard-to-gsm`) +- [x] Ounces to Grains (`ounces-to-grains`) +- [x] Ounces to Kilograms (`ounces-to-kilograms`) +- [x] Ounces to Milligrams (`ounces-to-milligrams`) +- [x] Ounces to Troy Ounces (`ounces-to-troy-ounces`) +- [x] Parsecs to Astronomical Units (`parsecs-to-astronomical-units`) +- [x] Parsecs to Kilometers (`parsecs-to-kilometers`) +- [x] Parsecs to Light Years (`parsecs-to-light-years`) +[x] Pascal to Bar (`pascal-to-bar`) +[x] Pascal to Dynes per sq cm (`pascal-to-dynes-per-sq-cm`) +[x] Pascal to kPa (`pascal-to-kpa`) +[x] Pascal to Megapascals (`pascal-to-megapascals`) +[x] Pascal to mmHg (`pascal-to-mmhg`) +[x] Pascal to PSI (`pascal-to-psi`) +[x] Pascal to Technical atmosphere (`pascal-to-technical-atmosphere`) +[x] Pascal to Torr (`pascal-to-torr`) +[x] Pascal to Barye (`pascal-to-barye`) +[x] Pascal-seconds to Centipoise (`pascal-seconds-to-centipoise`) [x] Pecks to Liters (`pecks-to-liters`) [x] Pennyweights to Troy Ounces (`pennyweights-to-troy-ounces`) [x] Percent ABV to Proof (`percent-abv-to-proof`) -- [ ] Petabytes to Exabytes -- [ ] Petabytes to Gigabytes -- [ ] Petabytes to Terabytes -- [ ] Picocurie to Becquerel -- [ ] Picofarads to Microfarads -- [ ] Picograms to Nanograms -- [ ] Picometers to Angstroms -- [ ] Pints to Cups -- [ ] Pints to Gallons -- [ ] Pints to Quarts -- [ ] Pixels per centimeter to DPI -- [ ] Pixels to Points -- [ ] Planck mass to Kilograms -- [ ] Planck time to Seconds -- [ ] Points (compass) to Degrees -- [ ] Points to Inches -- [ ] Points to Pixels -- [ ] Poise to Pascal-seconds - [x] Pound-force to Kilogram-force (`pound-force-to-kilogram-force`) - [x] Pound-force to Newtons (`pound-force-to-newtons`) -- [ ] Pounds per cubic foot to Kilograms per cubic meter -- [ ] Pounds to Grams -- [ ] PPB to PPM -- [ ] PPM to mg/L -- [ ] PPM to Percent -- [ ] PPM to PPB -- [ ] Proof (alcohol) to Percent ABV -- [ ] PSI to Atmosphere -- [ ] PSI to Feet of seawater -- [ ] PSI to Feet of Water -- [ ] PSI to Inches of Water -- [ ] PSI to kPa -- [ ] PSI to mmHg -- [ ] PSI to Pascal -- [ ] PSI to Torr +[x] PPB to PPM (`ppb-to-ppm`) +[x] PPM to mg/L (`ppm-to-mg-per-liter`) +[x] PPM to Percent (`ppm-to-percent`) +[x] PPM to PPB (`ppm-to-ppb`) +[x] Proof (alcohol) to Percent ABV (`proof-to-percent-abv`) +[x] PSI to Atmosphere (`psi-to-atmosphere`) +[x] PSI to Feet of seawater (`psi-to-feet-of-seawater`) +[x] PSI to Feet of Water (`psi-to-feet-of-water`) +[x] PSI to Inches of Water (`psi-to-inches-of-water`) +[x] PSI to kPa (`psi-to-kpa`) +[x] PSI to mmHg (`psi-to-mmhg`) +[x] PSI to Pascal (`psi-to-pascal`) +[x] PSI to Torr (`psi-to-torr`) - [ ] Quadrants to Degrees - [ ] Quarters to Kilograms - [ ] Quarts to Gallons diff --git a/hdyc-svelte/src/lib/components/QuickDefinitionCard.svelte b/hdyc-svelte/src/lib/components/QuickDefinitionCard.svelte index 745850a..dab4d7c 100644 --- a/hdyc-svelte/src/lib/components/QuickDefinitionCard.svelte +++ b/hdyc-svelte/src/lib/components/QuickDefinitionCard.svelte @@ -11,8 +11,8 @@ $: label1 = config.labels.in1 || 'Unit 1'; $: label2 = config.labels.in2 || 'Unit 2'; - $: def1 = getDefinition(label1); - $: def2 = getDefinition(label2); + $: def1 = getDefinition(label1, config.category); + $: def2 = getDefinition(label2, config.category);
diff --git a/hdyc-svelte/src/lib/data/calculators.ts b/hdyc-svelte/src/lib/data/calculators.ts index 2b86b8c..0ba187d 100644 --- a/hdyc-svelte/src/lib/data/calculators.ts +++ b/hdyc-svelte/src/lib/data/calculators.ts @@ -63,17 +63,21 @@ export const calculators: CalculatorDef[] = [ {"slug": "attograms-to-femtograms", "name": "Attograms to Femtograms", "category": "weight", "type": "standard", "teaser": "To compare particle masses, convert 150 attograms into femtograms.", "labels": {"in1": "Attograms", "in2": "Femtograms"}, "factor": 0.001, "hidden": true}, {"slug": "bar-to-pascal", "name": "Bar to Pascal", "category": "pressure", "type": "standard", "labels": {"in1": "Bar", "in2": "Pascal"}, "factor": 100000.0}, {"slug": "bar-to-psi", "name": "Bar to PSI", "category": "pressure", "type": "standard", "labels": {"in1": "Bar", "in2": "PSI"}, "factor": 14.5037738}, + {"slug": "pascal-to-barye", "name": "Pascal to Barye", "category": "pressure", "type": "standard", "teaser": "Convert pascals into CGS barye units for historical reference.", "labels": {"in1": "Pascal", "in2": "Barye"}, "factor": 10.0}, {"slug": "pascal-to-bar", "name": "Pascal to Bar", "category": "pressure", "type": "standard", "teaser": "Convert pascals back into bars for quick pressure comparisons.", "labels": {"in1": "Pascal", "in2": "Bar"}, "factor": 1e-05, "hidden": true}, {"slug": "pascal-to-dynes-per-sq-cm", "name": "Pascal to Dynes per sq cm", "category": "force", "type": "standard", "teaser": "Translate SI pressure into CGS dynes per square centimeter.", "labels": {"in1": "Pascal", "in2": "Dynes per sq cm"}, "factor": 10.0}, {"slug": "pascal-to-kpa", "name": "Pascal to kPa", "category": "pressure", "type": "standard", "teaser": "Convert pascals into kilopascals.", "labels": {"in1": "Pascal", "in2": "kPa"}, "factor": 0.001, "hidden": true}, {"slug": "pascal-to-megapascals", "name": "Pascal to Megapascals", "category": "pressure", "type": "standard", "teaser": "Express pascals as megapascals.", "labels": {"in1": "Pascal", "in2": "Megapascals"}, "factor": 1e-06, "hidden": true}, {"slug": "pascal-to-mmhg", "name": "Pascal to mmHg", "category": "pressure", "type": "standard", "teaser": "Turn pascals into millimeters of mercury.", "labels": {"in1": "Pascal", "in2": "mmHg"}, "factor": 0.00750062}, - {"slug": "pascal-to-psi", "name": "Pascal to PSI", "category": "pressure", "type": "standard", "teaser": "Convert pascals to pounds per square inch.", "labels": {"in1": "Pascal", "in2": "PSI"}, "factor": 0.000145038}, + {"slug": "pascal-to-psi", "name": "Pascal to PSI", "category": "pressure", "type": "standard", "teaser": "Convert pascals to pounds per square inch.", "labels": {"in1": "Pascal", "in2": "PSI"}, "factor": 0.000145038, "hidden": true}, {"slug": "pascal-to-technical-atmosphere", "name": "Pascal to Technical atmosphere", "category": "pressure", "type": "standard", "teaser": "Convert pascals to technical atmospheres (kgf/cm\u00b2).", "labels": {"in1": "Pascal", "in2": "Technical atmosphere"}, "factor": 1.0197162e-05}, {"slug": "pascal-to-torr", "name": "Pascal to Torr", "category": "pressure", "type": "standard", "teaser": "Convert pascals into torr for vacuum work.", "labels": {"in1": "Pascal", "in2": "Torr"}, "factor": 0.00750062, "hidden": true}, + {"slug": "pascal-seconds-to-centipoise", "name": "Pascal-seconds to Centipoise", "category": "pressure", "type": "standard", "teaser": "Convert Pascal-second viscosity into centipoise.", "labels": {"in1": "Pascal-seconds", "in2": "Centipoise"}, "factor": 1000.0}, + {"slug": "poise-to-pascal-seconds", "name": "Poise to Pascal-seconds", "category": "pressure", "type": "standard", "teaser": "Express CGS poise viscosity in Pascal-seconds.", "labels": {"in1": "Poise", "in2": "Pascal-seconds"}, "factor": 0.1}, {"slug": "becquerel-to-curie", "name": "Becquerel to Curie", "category": "radiation", "type": "standard", "labels": {"in1": "Becquerel", "in2": "Curie"}, "factor": 2.7027027e-11, "hidden": true}, {"slug": "becquerel-to-rutherford", "name": "Becquerel to Rutherford", "category": "radiation", "type": "standard", "labels": {"in1": "Becquerel", "in2": "Rutherford"}, "factor": 1e-06, "hidden": true}, {"slug": "bits-to-bytes", "name": "Bits to Bytes", "category": "data", "type": "standard", "labels": {"in1": "Bits", "in2": "Bytes"}, "factor": 0.1}, + {"slug": "nibbles-to-bits", "name": "Nibbles to Bits", "category": "data", "type": "standard", "teaser": "Each 4-bit nibble stores exactly four bits in digital streams.", "labels": {"in1": "Nibbles", "in2": "Bits"}, "factor": 4.0}, {"slug": "words-16-bit-to-bits", "name": "Words (16-bit) to Bits", "category": "data", "type": "standard", "teaser": "Convert 16-bit words into raw bits for archive calculations.", "labels": {"in1": "Words (16-bit)", "in2": "Bits"}, "factor": 16.0}, {"slug": "words-16-bit-to-bytes", "name": "Words (16-bit) to Bytes", "category": "data", "type": "standard", "teaser": "Express a 16-bit word as a pair of bytes.", "labels": {"in1": "Words (16-bit)", "in2": "Bytes"}, "factor": 2.0}, {"slug": "words-32-bit-to-bits", "name": "Words (32-bit) to Bits", "category": "data", "type": "standard", "teaser": "Convert 32-bit words into bits for framing larger registers.", "labels": {"in1": "Words (32-bit)", "in2": "Bits"}, "factor": 32.0}, @@ -97,7 +101,8 @@ export const calculators: CalculatorDef[] = [ {"slug": "amps-to-watts", "name": "Amps to Watts", "category": "power", "type": "3col-mul", "labels": {"in1": "Amps", "in2": "Watts", "in3": "Volts"}}, {"slug": "amps-to-kilowatts", "name": "Amps to Kilowatts", "category": "power", "type": "3col", "labels": {"in1": "Amps", "in2": "Kilowatts", "in3": "Volts"}}, {"slug": "amps-to-kva", "name": "Amps to kVA", "category": "electrical", "type": "3col", "labels": {"in1": "Amps", "in2": "kVA", "in3": "Result"}}, - {"slug": "ampere-turns-per-meter-to-oersted", "name": "Ampere-turns per meter to Oersted", "category": "length", "type": "standard", "teaser": "Convert magnetomotive force per meter into oersted units.", "labels": {"in1": "Ampere-turns per meter", "in2": "Oersted"}, "factor": 0.0125663706143592}, + {"slug": "ampere-turns-per-meter-to-oersted", "name": "Ampere-turns per meter to Oersted", "category": "length", "type": "standard", "teaser": "Convert magnetomotive force per meter into oersted units.", "labels": {"in1": "Ampere-turns per meter", "in2": "Oersted"}, "factor": 0.0125663706143592, "hidden": true}, + {"slug": "oersted-to-ampere-turns-per-meter", "name": "Oersted to Ampere-turns per meter", "category": "length", "type": "standard", "teaser": "Flip the CGS oersted field scale back into ampere-turns per meter.", "labels": {"in1": "Oersted", "in2": "Ampere-turns per meter"}, "factor": 79.57747154594767}, {"slug": "amps-to-milliamps", "name": "Amps to Milliamps", "category": "electrical", "type": "standard", "teaser": "Translate amperes into milliamperes when tuning circuit currents.", "labels": {"in1": "Amps", "in2": "Milliamps"}, "factor": 1000.0}, {"slug": "carats-to-grams", "name": "Carats to Grams", "category": "weight", "type": "standard", "labels": {"in1": "Carats", "in2": "Grams"}, "factor": 0.2, "hidden": true}, {"slug": "celsius-to-fahrenheit", "name": "Celsius to Fahrenheit", "category": "temperature", "type": "standard", "labels": {"in1": "Celsius", "in2": "Fahrenheit"}, "factor": 1.8, "offset": 32.0}, @@ -207,6 +212,10 @@ export const calculators: CalculatorDef[] = [ {"slug": "dynes-to-pound-force", "name": "Dynes to Pound-force", "category": "force", "type": "standard", "teaser": "Turn dynes into the more intuitive pound-force units.", "labels": {"in1": "Dynes", "in2": "Pound-force"}, "factor": 2.248089431128759e-06, "hidden": true}, {"slug": "dynes-to-kilonewtons", "name": "Dynes to Kilonewtons", "category": "force", "type": "standard", "teaser": "Scale dynes all the way into kilonewtons for SI reporting.", "labels": {"in1": "Dynes", "in2": "Kilonewtons"}, "factor": 1e-08, "hidden": true}, {"slug": "ounces-to-grams", "name": "Ounces to Grams", "category": "weight", "type": "standard", "labels": {"in1": "Ounces", "in2": "Grams"}, "factor": 28.3495}, + {"slug": "ounces-to-grains", "name": "Ounces to Grains", "category": "weight", "type": "standard", "teaser": "Convert avoirdupois ounces into grains.", "labels": {"in1": "Ounces", "in2": "Grains"}, "factor": 437.5}, + {"slug": "ounces-to-kilograms", "name": "Ounces to Kilograms", "category": "weight", "type": "standard", "teaser": "Express avoirdupois ounces in kilograms.", "labels": {"in1": "Ounces", "in2": "Kilograms"}, "factor": 0.0283495}, + {"slug": "ounces-to-milligrams", "name": "Ounces to Milligrams", "category": "weight", "type": "standard", "teaser": "Move ounces into milligram measurements.", "labels": {"in1": "Ounces", "in2": "Milligrams"}, "factor": 28349.523125}, + {"slug": "ounces-to-troy-ounces", "name": "Ounces to Troy Ounces", "category": "weight", "type": "standard", "teaser": "Convert avoirdupois ounces into troy ounces.", "labels": {"in1": "Ounces", "in2": "Troy Ounces"}, "factor": 0.9114583333333333}, {"slug": "kilogram-force-meters-to-dyne-centimeters", "name": "Kilogram-force Meters to Dyne-centimeters", "category": "force", "type": "standard", "teaser": "Flip kilogram-force meters back into dyne-centimeters.", "labels": {"in1": "Kilogram-force Meters", "in2": "Dyne-centimeters"}, "factor": 98066500.0}, {"slug": "kilogram-force-meters-to-foot-pounds", "name": "Kilogram-force Meters to Foot-pounds", "category": "force", "type": "standard", "teaser": "Express a kilogram-force meter as foot-pounds of torque.", "labels": {"in1": "Kilogram-force Meters", "in2": "Foot-pounds"}, "factor": 7.233013851209897}, {"slug": "kilogram-force-meters-to-inch-pounds", "name": "Kilogram-force Meters to Inch-pounds", "category": "force", "type": "standard", "teaser": "Turn a kilogram-force meter into inch-pounds.", "labels": {"in1": "Kilogram-force Meters", "in2": "Inch-pounds"}, "factor": 86.79616621451876}, @@ -262,8 +271,12 @@ export const calculators: CalculatorDef[] = [ {"slug": "kilowatt-hours-to-megajoules", "name": "Kilowatt-hours to Megajoules", "category": "energy", "type": "standard", "labels": {"in1": "Kilowatt-hours", "in2": "Megajoules"}, "factor": 3.6}, {"slug": "knots-to-miles-per-hour", "name": "Knots to Miles per hour", "category": "length", "type": "standard", "labels": {"in1": "Knots", "in2": "Miles per hour"}, "factor": 1.15077945}, {"slug": "light-years-to-astronomical-units", "name": "Light years to Astronomical units", "category": "time", "type": "standard", "labels": {"in1": "Light years", "in2": "Astronomical units"}, "factor": 63241.077}, - {"slug": "light-years-to-parsecs", "name": "Light years to Parsecs", "category": "time", "type": "standard", "labels": {"in1": "Light years", "in2": "Parsecs"}, "factor": 0.306601394}, + {"slug": "light-years-to-parsecs", "name": "Light years to Parsecs", "category": "time", "type": "standard", "labels": {"in1": "Light years", "in2": "Parsecs"}, "factor": 0.306601394, "hidden": true}, {"slug": "liters-per-second-to-gallons-per-minute", "name": "Liters per second to Gallons per minute", "category": "volume", "type": "standard", "labels": {"in1": "Liters per second", "in2": "Gallons per minute"}, "factor": 15.8503231}, + {"slug": "parsecs-to-astronomical-units", "name": "Parsecs to Astronomical Units", "category": "other", "type": "standard", "teaser": "Translate parsec distances into astronomical units.", "labels": {"in1": "Parsecs", "in2": "Astronomical Units"}, "factor": 206265.0}, + {"slug": "parsecs-to-kilometers", "name": "Parsecs to Kilometers", "category": "length", "type": "standard", "teaser": "Turn parsecs into kilometers for cosmic scales.", "labels": {"in1": "Parsecs", "in2": "Kilometers"}, "factor": 30856775814913.7}, + {"slug": "parsecs-to-light-years", "name": "Parsecs to Light Years", "category": "time", "type": "standard", "teaser": "Express parsecs as light years.", "labels": {"in1": "Parsecs", "in2": "Light Years"}, "factor": 3.261563777}, + {"slug": "parsecs-to-miles", "name": "Parsecs to Miles", "category": "length", "type": "standard", "teaser": "Express parsecs in statute miles.", "labels": {"in1": "Parsecs", "in2": "Miles"}, "factor": 19181367000000.0}, {"slug": "liters-to-gallons", "name": "Liters to Gallons", "category": "volume", "type": "standard", "labels": {"in1": "Liters", "in2": "Gallons"}, "factor": 0.264172052, "hidden": true}, {"slug": "liters-to-pints", "name": "Liters to Pints", "category": "volume", "type": "standard", "labels": {"in1": "Liters", "in2": "Pints"}, "factor": 2.11337642}, {"slug": "liters-to-quarts", "name": "Liters to Quarts", "category": "volume", "type": "standard", "labels": {"in1": "Liters", "in2": "Quarts"}, "factor": 1.05668821}, @@ -280,6 +293,9 @@ export const calculators: CalculatorDef[] = [ {"slug": "decimal-to-octal", "name": "Decimal to Octal", "category": "number-systems", "type": "standard", "labels": {"in1": "Decimal", "in2": "Octal"}}, {"slug": "hex-to-binary", "name": "Hex to Binary", "category": "number-systems", "type": "base", "labels": {"in1": "Hex", "in2": "Binary"}, "toBase": 2, "fromBase": 16, "hidden": true}, {"slug": "hex-to-decimal", "name": "Hex to Decimal", "category": "number-systems", "type": "standard", "labels": {"in1": "Hex", "in2": "Decimal"}, "hidden": true}, + {"slug": "octal-to-binary", "name": "Octal to Binary", "category": "number-systems", "type": "standard", "teaser": "Convert base-8 numbers into binary digits.", "labels": {"in1": "Octal", "in2": "Binary"}}, + {"slug": "octal-to-decimal", "name": "Octal to Decimal", "category": "number-systems", "type": "standard", "teaser": "Convert base-8 digits into decimal values.", "labels": {"in1": "Octal", "in2": "Decimal"}, "hidden": true}, + {"slug": "octal-to-hex", "name": "Octal to Hex", "category": "number-systems", "type": "standard", "teaser": "Express octal numbers as hexadecimal.", "labels": {"in1": "Octal", "in2": "Hex"}, "hidden": true}, {"slug": "watts-to-amps", "name": "Watts to amps", "category": "power", "type": "3col", "labels": {"in1": "Watts", "in2": "amps", "in3": "Volts"}, "hidden": true}, {"slug": "volts-to-amps", "name": "Volts to amps", "category": "electrical", "type": "3col", "labels": {"in1": "Volts", "in2": "amps", "in3": "Result"}, "hidden": true}, {"slug": "volts-to-abvolts", "name": "Volts to Abvolts", "category": "electrical", "type": "standard", "teaser": "Convert SI volts into CGS abvolts.", "labels": {"in1": "Volts", "in2": "Abvolts"}, "factor": 100000000.0}, @@ -341,16 +357,39 @@ export const calculators: CalculatorDef[] = [ {"slug": "rad-to-gray", "name": "Rad to gray", "category": "radiation", "type": "standard", "labels": {"in1": "Rad", "in2": "gray"}, "factor": 0.01, "hidden": true}, {"slug": "psi-to-megapascals", "name": "PSI to megapascals", "category": "pressure", "type": "standard", "labels": {"in1": "PSI", "in2": "megapascals"}, "factor": 0.006895, "hidden": true}, {"slug": "psi-to-bar", "name": "PSI to bar", "category": "pressure", "type": "standard", "labels": {"in1": "PSI", "in2": "bar"}, "factor": 0.068948, "hidden": true}, + {"slug": "psi-to-kpa", "name": "PSI to kPa", "category": "pressure", "type": "standard", "teaser": "Convert pounds per square inch into kilopascals.", "labels": {"in1": "PSI", "in2": "kPa"}, "factor": 6.89476}, + {"slug": "psi-to-pascal", "name": "PSI to Pascals", "category": "pressure", "type": "standard", "teaser": "Convert PSI into pascals for SI clarity.", "labels": {"in1": "PSI", "in2": "Pascals"}, "factor": 6894.76}, + {"slug": "psi-to-mmhg", "name": "PSI to mmHg", "category": "pressure", "type": "standard", "teaser": "Express PSI in millimeters of mercury.", "labels": {"in1": "PSI", "in2": "mmHg"}, "factor": 51.7149}, + {"slug": "psi-to-torr", "name": "PSI to Torr", "category": "pressure", "type": "standard", "teaser": "Express PSI in torr for vacuum work.", "labels": {"in1": "PSI", "in2": "Torr"}, "factor": 51.7149}, {"slug": "ppi-to-dpi", "name": "PPI to DPI", "category": "other", "type": "standard", "labels": {"in1": "PPI", "in2": "DPI"}}, {"slug": "pounds-to-tons", "name": "Pounds to tons", "category": "weight", "type": "standard", "labels": {"in1": "Pounds", "in2": "tons"}, "factor": 0.0005, "hidden": true}, {"slug": "pounds-to-stones", "name": "Pounds to stones", "category": "weight", "type": "standard", "labels": {"in1": "Pounds", "in2": "stones"}, "factor": 0.071428, "hidden": true}, {"slug": "pounds-to-ounces", "name": "Pounds to ounces", "category": "weight", "type": "standard", "labels": {"in1": "Pounds", "in2": "ounces"}, "factor": 16.0}, {"slug": "pounds-to-kilograms", "name": "Pounds to kilograms", "category": "weight", "type": "standard", "labels": {"in1": "Pounds", "in2": "kilograms"}, "factor": 0.45359, "hidden": true}, {"slug": "pints-to-liters", "name": "Pints to liters", "category": "volume", "type": "standard", "labels": {"in1": "Pints", "in2": "liters"}, "factor": 0.473176, "hidden": true}, + {"slug": "pints-to-cups", "name": "Pints to Cups", "category": "volume", "type": "standard", "teaser": "Convert pints into cups for cooking measures.", "labels": {"in1": "Pints", "in2": "Cups"}, "factor": 2.0}, + {"slug": "pints-to-gallons", "name": "Pints to Gallons", "category": "volume", "type": "standard", "teaser": "Convert pints into gallons for volume tracking.", "labels": {"in1": "Pints", "in2": "Gallons"}, "factor": 0.125, "hidden": true}, + {"slug": "pints-to-quarts", "name": "Pints to Quarts", "category": "volume", "type": "standard", "teaser": "Convert pints into quarts for canning ratios.", "labels": {"in1": "Pints", "in2": "Quarts"}, "factor": 0.5}, {"slug": "percent-to-ppm", "name": "Percent to PPM", "category": "other", "type": "standard", "labels": {"in1": "Percent", "in2": "PPM"}, "factor": 10000.0}, {"slug": "percent-abv-to-proof", "name": "Percent ABV to Proof", "category": "other", "type": "standard", "teaser": "Convert alcohol by volume into US proof values (Proof = 2 \u00d7 ABV).", "labels": {"in1": "Percent ABV", "in2": "Proof"}, "factor": 2.0}, + {"slug": "proof-to-percent-abv", "name": "Proof to Percent ABV", "category": "other", "type": "standard", "teaser": "Convert US proof back into ABV (ABV = Proof / 2).", "labels": {"in1": "Proof", "in2": "Percent ABV"}, "factor": 0.5, "hidden": true}, + {"slug": "ppb-to-ppm", "name": "PPB to PPM", "category": "other", "type": "standard", "teaser": "Convert parts per billion into ppm.", "labels": {"in1": "PPB", "in2": "PPM"}, "factor": 0.001, "hidden": true}, + {"slug": "ppm-to-mg-per-liter", "name": "PPM to mg/L", "category": "other", "type": "standard", "teaser": "For dilute aqueous solutions, treat ppm as mg per liter.", "labels": {"in1": "PPM", "in2": "mg/L"}}, + {"slug": "ppm-to-percent", "name": "PPM to Percent", "category": "other", "type": "standard", "teaser": "Convert ppm values into percent by mass.", "labels": {"in1": "PPM", "in2": "Percent"}, "factor": 0.0001, "hidden": true}, + {"slug": "ppm-to-ppb", "name": "PPM to PPB", "category": "other", "type": "standard", "teaser": "Convert parts per million into parts per billion.", "labels": {"in1": "PPM", "in2": "PPB"}, "factor": 1000.0}, + {"slug": "planck-mass-to-kilograms", "name": "Planck mass to Kilograms", "category": "weight", "type": "standard", "teaser": "Convert the Planck mass into SI kilograms.", "labels": {"in1": "Planck mass", "in2": "Kilograms"}, "factor": 2.176434e-08}, + {"slug": "planck-time-to-seconds", "name": "Planck time to Seconds", "category": "time", "type": "standard", "teaser": "Express Planck time in seconds.", "labels": {"in1": "Planck time", "in2": "Seconds"}, "factor": 5.391247e-44}, + {"slug": "points-compass-to-degrees", "name": "Points (compass) to Degrees", "category": "angle", "type": "standard", "teaser": "Convert compass points into degrees.", "labels": {"in1": "Points (compass)", "in2": "Degrees"}, "factor": 11.25}, + {"slug": "points-to-inches", "name": "Points to Inches", "category": "length", "type": "standard", "teaser": "Translate typography points into inches for layout work.", "labels": {"in1": "Points", "in2": "Inches"}, "factor": 0.0138889, "hidden": true}, + {"slug": "points-to-pixels", "name": "Points to Pixels", "category": "other", "type": "standard", "teaser": "Convert typographic points into CSS pixels at 96 DPI.", "labels": {"in1": "Points", "in2": "Pixels"}, "factor": 1.333333}, + {"slug": "pixels-per-centimeter-to-dpi", "name": "Pixels per centimeter to DPI", "category": "length", "type": "standard", "teaser": "Convert pixels per centimeter into dots per inch (multiplying by 2.54).", "labels": {"in1": "Pixels per centimeter", "in2": "DPI"}, "factor": 2.54}, + {"slug": "pixels-to-points", "name": "Pixels to Points", "category": "other", "type": "standard", "teaser": "Convert CSS pixels into typographic points at 96 DPI.", "labels": {"in1": "Pixels", "in2": "Points"}, "factor": 0.75, "hidden": true}, {"slug": "pennyweights-to-grams", "name": "Pennyweights to grams", "category": "weight", "type": "standard", "labels": {"in1": "Pennyweights", "in2": "grams"}, "factor": 1.55517}, {"slug": "pennyweights-to-troy-ounces", "name": "Pennyweights to Troy Ounces", "category": "weight", "type": "standard", "teaser": "Convert pennyweights into troy ounces (1 pennyweight = 0.05 troy ounces).", "labels": {"in1": "Pennyweights", "in2": "Troy Ounces"}, "factor": 0.05}, + {"slug": "picocurie-to-becquerel", "name": "Picocurie to Becquerel", "category": "radiation", "type": "standard", "teaser": "A tiny radiation dose expressed in picocuries converts to becquerels.", "labels": {"in1": "Picocurie", "in2": "Becquerel"}, "factor": 0.037}, + {"slug": "picofarads-to-microfarads", "name": "Picofarads to Microfarads", "category": "radiation", "type": "standard", "teaser": "Convert tiny capacitances into microfarads for circuit design.", "labels": {"in1": "Picofarads", "in2": "Microfarads"}, "factor": 1e-06, "hidden": true}, + {"slug": "picograms-to-nanograms", "name": "Picograms to Nanograms", "category": "weight", "type": "standard", "teaser": "Express picogram masses as nanograms for lab reporting.", "labels": {"in1": "Picograms", "in2": "Nanograms"}, "factor": 0.001, "hidden": true}, + {"slug": "picometers-to-angstroms", "name": "Picometers to Angstroms", "category": "length", "type": "standard", "teaser": "Translate picometers into angstroms for nanoscale distances.", "labels": {"in1": "Picometers", "in2": "Angstroms"}, "factor": 0.01}, {"slug": "pascals-to-inches-of-water", "name": "Pascals to inches of water", "category": "length", "type": "standard", "labels": {"in1": "Pascals", "in2": "inches of water"}, "factor": 0.004015, "hidden": true}, {"slug": "pascals-to-inches-of-mercury", "name": "Pascals to inches of mercury", "category": "length", "type": "standard", "labels": {"in1": "Pascals", "in2": "inches of mercury"}, "factor": 0.000295, "hidden": true}, {"slug": "pascal-to-atmosphere", "name": "Pascal to atmosphere", "category": "pressure", "type": "standard", "labels": {"in1": "Pascal", "in2": "atmosphere"}, "factor": 9.869e-06}, @@ -360,7 +399,8 @@ export const calculators: CalculatorDef[] = [ {"slug": "nanograms-to-picograms", "name": "Nanograms to picograms", "category": "weight", "type": "standard", "labels": {"in1": "Nanograms", "in2": "picograms"}, "factor": 1000.0}, {"slug": "metric-tons-to-long-tons", "name": "Metric tons to long tons", "category": "weight", "type": "standard", "labels": {"in1": "Metric tons", "in2": "long tons"}, "factor": 0.9842}, {"slug": "lumens-to-candela", "name": "Lumens to candela", "category": "light", "type": "standard", "labels": {"in1": "Lumens", "in2": "candela"}, "factor": 0.079577, "hidden": true}, - {"slug": "gsm-to-ounces-per-sq-yard", "name": "GSM to Ounces per sq yard", "category": "length", "type": "standard", "teaser": "Convert GSM to Ounces per sq yard instantly.", "labels": {"in1": "GSM", "in2": "Ounces per sq yard"}, "factor": 0.02952}, + {"slug": "gsm-to-ounces-per-sq-yard", "name": "GSM to Ounces per sq yard", "category": "length", "type": "standard", "teaser": "Convert GSM to Ounces per sq yard instantly.", "labels": {"in1": "GSM", "in2": "Ounces per sq yard"}, "factor": 0.02952, "hidden": true}, + {"slug": "ounces-per-sq-yard-to-gsm", "name": "Ounces per sq yard to GSM", "category": "length", "type": "standard", "teaser": "Convert fabric weight from ounces per square yard into grams per square meter.", "labels": {"in1": "Ounces per sq yard", "in2": "GSM"}, "factor": 33.906074}, {"slug": "hands-to-centimeters", "name": "Hands to Centimeters", "category": "length", "type": "standard", "teaser": "Convert Hands to Centimeters instantly.", "labels": {"in1": "Hands", "in2": "Centimeters"}, "factor": 10.16}, {"slug": "hands-to-inches", "name": "Hands to Inches", "category": "length", "type": "standard", "teaser": "Convert Hands to Inches instantly.", "labels": {"in1": "Hands", "in2": "Inches"}, "factor": 4.0}, {"slug": "hartree-to-electron-volts", "name": "Hartree to Electron-volts", "category": "energy", "type": "standard", "teaser": "Convert Hartree to Electron-volts instantly.", "labels": {"in1": "Hartree", "in2": "Electron-volts"}, "factor": 27.2114}, @@ -433,7 +473,7 @@ export const calculators: CalculatorDef[] = [ {"slug": "gill-to-milliliters", "name": "Gill to Milliliters", "category": "volume", "type": "standard", "teaser": "A bartender pours two US gills; how many milliliters should the glass hold?", "labels": {"in1": "Gill", "in2": "Milliliters"}, "factor": 118.294}, {"slug": "gradians-to-degrees", "name": "Gradians to Degrees", "category": "angle", "type": "standard", "teaser": "A surveyor logs 100 gradians; what is that angle in degrees?", "labels": {"in1": "Gradians", "in2": "Degrees"}, "factor": 0.9}, {"slug": "gradians-to-radians", "name": "Gradians to Radians", "category": "angle", "type": "standard", "teaser": "A control dial sweeps 200 gradians; what is that rotation in radians?", "labels": {"in1": "Gradians", "in2": "Radians"}, "factor": 0.01570796}, - {"slug": "grains-to-ounces", "name": "Grains to Ounces", "category": "weight", "type": "standard", "teaser": "A jewelry batch weighs 100 grains; how many ounces is that?", "labels": {"in1": "Grains", "in2": "Ounces"}, "factor": 0.002285714}, + {"slug": "grains-to-ounces", "name": "Grains to Ounces", "category": "weight", "type": "standard", "teaser": "A jewelry batch weighs 100 grains; how many ounces is that?", "labels": {"in1": "Grains", "in2": "Ounces"}, "factor": 0.002285714, "hidden": true}, {"slug": "grams-per-cubic-centimeter-to-kilograms-per-liter", "name": "Grams per cubic centimeter to Kilograms per liter", "category": "length", "type": "standard", "teaser": "A fluid density of 1 g/cm\u00b3 equals how many kg/L?", "labels": {"in1": "Grams per cubic centimeter", "in2": "Kilograms per liter"}}, {"slug": "grams-per-milliliter-to-kilograms-per-cubic-meter", "name": "Grams per milliliter to Kilograms per cubic meter", "category": "length", "type": "standard", "teaser": "A solution at 1.2 g/mL corresponds to how many kg/m\u00b3?", "labels": {"in1": "Grams per milliliter", "in2": "Kilograms per cubic meter"}, "factor": 1000.0}, {"slug": "grams-to-drams", "name": "Grams to Drams", "category": "weight", "type": "standard", "teaser": "A tea blend calls for 2 grams; how many drams should you measure?", "labels": {"in1": "Grams", "in2": "Drams"}, "factor": 0.564383}, @@ -465,7 +505,7 @@ export const calculators: CalculatorDef[] = [ {"slug": "kpa-to-atmosphere", "name": "kPa to Atmosphere", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to atmospheres.", "labels": {"in1": "kPa", "in2": "Atmosphere"}, "factor": 0.00986923, "hidden": true}, {"slug": "kpa-to-bar", "name": "kPa to Bar", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to bar.", "labels": {"in1": "kPa", "in2": "Bar"}, "factor": 0.01}, {"slug": "kpa-to-pascal", "name": "kPa to Pascal", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to pascals.", "labels": {"in1": "kPa", "in2": "Pascal"}, "factor": 1000.0}, - {"slug": "kpa-to-psi", "name": "kPa to PSI", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to pounds per square inch.", "labels": {"in1": "kPa", "in2": "PSI"}, "factor": 0.1450377377}, + {"slug": "kpa-to-psi", "name": "kPa to PSI", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to pounds per square inch.", "labels": {"in1": "kPa", "in2": "PSI"}, "factor": 0.1450377377, "hidden": true}, {"slug": "kva-to-kilowatts", "name": "kVA to Kilowatts", "category": "power", "type": "standard", "teaser": "Convert apparent power to real power assuming unity power factor.", "labels": {"in1": "kVA", "in2": "Kilowatts"}}, {"slug": "leagues-per-hour-to-kmh", "name": "Leagues per Hour to Kilometers per Hour", "category": "length", "type": "standard", "teaser": "Convert leagues per hour into kilometers per hour.", "labels": {"in1": "Leagues per Hour", "in2": "Kilometers per Hour"}, "factor": 4.82803}, {"slug": "leagues-to-kilometers", "name": "Leagues to Kilometers", "category": "length", "type": "standard", "teaser": "Convert leagues to kilometers.", "labels": {"in1": "Leagues", "in2": "Kilometers"}, "factor": 4.82803}, @@ -543,7 +583,7 @@ export const calculators: CalculatorDef[] = [ {"slug": "kpa-to-atmosphere", "name": "kPa to Atmosphere", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to atmospheres.", "labels": {"in1": "kPa", "in2": "Atmosphere"}, "factor": 0.00986923, "hidden": true}, {"slug": "kpa-to-bar", "name": "kPa to Bar", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to bar.", "labels": {"in1": "kPa", "in2": "Bar"}, "factor": 0.01}, {"slug": "kpa-to-pascal", "name": "kPa to Pascal", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to pascals.", "labels": {"in1": "kPa", "in2": "Pascal"}, "factor": 1000.0}, - {"slug": "kpa-to-psi", "name": "kPa to PSI", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to pounds per square inch.", "labels": {"in1": "kPa", "in2": "PSI"}, "factor": 0.1450377377}, + {"slug": "kpa-to-psi", "name": "kPa to PSI", "category": "pressure", "type": "standard", "teaser": "Convert kilopascals to pounds per square inch.", "labels": {"in1": "kPa", "in2": "PSI"}, "factor": 0.1450377377, "hidden": true}, {"slug": "kva-to-kilowatts", "name": "kVA to Kilowatts", "category": "power", "type": "standard", "teaser": "Convert apparent power to real power assuming unity power factor.", "labels": {"in1": "kVA", "in2": "Kilowatts"}}, {"slug": "leagues-per-hour-to-kmh", "name": "Leagues per Hour to Kilometers per Hour", "category": "length", "type": "standard", "teaser": "Convert leagues per hour into kilometers per hour.", "labels": {"in1": "Leagues per Hour", "in2": "Kilometers per Hour"}, "factor": 4.82803}, {"slug": "leagues-to-kilometers", "name": "Leagues to Kilometers", "category": "length", "type": "standard", "teaser": "Convert leagues to kilometers.", "labels": {"in1": "Leagues", "in2": "Kilometers"}, "factor": 4.82803}, diff --git a/hdyc-svelte/src/lib/data/unitDefinitions.ts b/hdyc-svelte/src/lib/data/unitDefinitions.ts index 428ec48..5ec69b0 100644 --- a/hdyc-svelte/src/lib/data/unitDefinitions.ts +++ b/hdyc-svelte/src/lib/data/unitDefinitions.ts @@ -75,7 +75,8 @@ const domainDefinitions: Record = }, }; -const definitions: Record = {}; +const definitions: Record> = {}; +const categoryPriority = [...Object.keys(domainDefinitions)]; const buildDefinition = (label: string, categoryKey: string): string => { if (!label) return ''; @@ -88,14 +89,26 @@ calculators.forEach(calc => { const { category, labels } = calc; Object.values(labels).forEach(label => { if (!label) return; - if (!definitions[label]) { - definitions[label] = buildDefinition(label, category); - } + const bucket = definitions[label] || {}; + const text = buildDefinition(label, category); + bucket[category] = text; + definitions[label] = bucket; }); }); -export function getDefinition(label: string): string | undefined { - return definitions[label]; +const findByPriority = (entries: Record, preferred?: string): string | undefined => { + if (!entries) return undefined; + if (preferred && entries[preferred]) return entries[preferred]; + for (const category of categoryPriority) { + if (entries[category]) return entries[category]; + } + const fallback = Object.values(entries).filter(Boolean); + return fallback.length ? fallback[0] : undefined; +}; + +export function getDefinition(label: string, category?: string): string | undefined { + const entries = definitions[label]; + return findByPriority(entries, category); } export const unitDefinitions = definitions;