format-si-unit 0.0.11
“A lightweight utility to format and parse numbers with SI unit prefixes (k, M, G, etc.).”
JavaScript source mapReverses string with split reverse join
SHA-256c20790d9e2f45a551f4ef9ea0da983972842624f782eb5ce6cbac98eaad2fea6
MaleculeO(As)H₂(DbPo)Md
Evidence
172:15… gAndVariantSuffixes = /* @__PURE__ */ new Set();
173for (const [baseUnit, info] of Object.entries(unitMappings)) {
174 unitMappingAndVariantSuffixes.add(baseUnit);
175 for (const variant of Object.keys(info.variants)) {
⋯5 lines
188:19… dsWith(variant)) continue;
189 const prefix = unit.slice(0, -variant.length);
190 const prefixMultiplier = getSiPrefixMultiplier(prefix);
191 if (pr …
217:29… ConvertSiUnit(v.y, unitOfValue);
218 if (xResult.value === null || yResult.value === null) {
219 return { parsedUnit: null, unitOfValue: null, value …
226:11… yResult.value
227 }
228 };
229 }
230 const reversedInputString = v.toString().split("").reverse().join("");
231 const unitReversed = reversedInputString.match(/[^\d\s]+/)?.[0];
232 if (!unitReversed) {
233 throw new Error(`Could not determine unit: "${v}"`);
234 }
235 const unit = unitReversed.split("").reverse().join("");
236 const numberPart = v.slice(0, -unit.length);
237 const bareSiPrefixMultiplier = getSiPrefixMultiplier(unit);
238 if (unitOfVal …
1{
2 "name": "format-si-unit",
3 "main": "dist/index.js",
4 "type": "module",
5 "version": "0.0.11",
6 "files": [
7 "dist"
8 ],
9 "scripts": {
10 "build": "tsup-node ./index.ts --format esm --sourcemap --dts"
11 },
12 "devDependencies": {
13 "@biomejs/biome": "^1.9.4",
14 "@types/bun": "latest",
15 "tsup": "^8.3.5"
16 },
⋯4 lines
No evidence locations were recorded for this file. Raw result