* Try to split `symbol` into an SI prefix + a prefixable base unit. * * Strategy: try a 2-character prefix first (e.g. "da"), then 1-character. * The remaining suffix must be a member of `PREFIXABLE_UNITS`. * * Returns `{ prefix, prefixScale, baseEntry }` or `null`.
( symbol: string )
| 240 | ); |
| 241 | } |
| 242 | |
| 243 | export function isDimensionless(dim: DimensionVector): boolean { |
| 244 | return ( |
| 245 | dim[0] === 0 && |
| 246 | dim[1] === 0 && |
| 247 | dim[2] === 0 && |
| 248 | dim[3] === 0 && |
| 249 | dim[4] === 0 && |
| 250 | dim[5] === 0 && |
| 251 | dim[6] === 0 && |
| 252 | dim[7] === 0 |
| 253 | ); |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Try to split `symbol` into an SI prefix + a prefixable base unit. |
| 258 | * |
| 259 | * Strategy: try a 2-character prefix first (e.g. "da"), then 1-character. |
| 260 | * The remaining suffix must be a member of `PREFIXABLE_UNITS`. |
| 261 | * |
| 262 | * Returns `{ prefix, prefixScale, baseEntry }` or `null`. |
| 263 | */ |
| 264 | function parsePrefixedUnit( |
| 265 | symbol: string |
| 266 | ): { prefixScale: number; baseEntry: UnitEntry } | null { |
| 267 | // Try 2-char prefix first (only "da" currently, but future-proof) |
| 268 | if (symbol.length > 2) { |
| 269 | const p2 = symbol.slice(0, 2); |
no test coverage detected