MCPcopy Index your code
hub / github.com/Packstack-Tech/packstack / unitConversion

Function unitConversion

api/utils/dictionary.js:1–25  ·  view source on GitHub ↗
(unit)

Source from the content-addressed store, hash-verified

1export function unitConversion(unit) {
2 const u = unit.toLowerCase();
3 const grams = ['grams', 'gram', 'g'];
4 const pounds = ['pounds', 'pound', 'lbs', 'lb'];
5 const ounces = ['ounces', 'ounce', 'oz', 'o'];
6 const kilograms = ['kilograms', 'kilogram', 'kg'];
7
8 if (grams.includes(u)) {
9 return 'g';
10 }
11
12 if (pounds.includes(u)) {
13 return 'lbs';
14 }
15
16 if (ounces.includes(u)) {
17 return 'oz';
18 }
19
20 if (kilograms.includes(u)) {
21 return 'kg';
22 }
23
24 return null;
25}

Callers 1

item.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected