@@ -30,52 +30,48 @@ export function quantityToScalar(quantity: string): number | bigint {
3030 }
3131 switch ( suffix ) {
3232 case 'n' :
33- return Number ( quantity . substr ( 0 , quantity . length - 1 ) ) . valueOf ( ) / 1_000_000_000.0 ;
33+ return Number ( quantity . slice ( 0 , quantity . length - 1 ) ) . valueOf ( ) / 1_000_000_000.0 ;
3434 case 'u' :
35- return Number ( quantity . substr ( 0 , quantity . length - 1 ) ) . valueOf ( ) / 1_000_000.0 ;
35+ return Number ( quantity . slice ( 0 , quantity . length - 1 ) ) . valueOf ( ) / 1_000_000.0 ;
3636 case 'm' :
37- return Number ( quantity . substr ( 0 , quantity . length - 1 ) ) . valueOf ( ) / 1000.0 ;
37+ return Number ( quantity . slice ( 0 , quantity . length - 1 ) ) . valueOf ( ) / 1000.0 ;
3838 case 'k' :
39- return BigInt ( quantity . substr ( 0 , quantity . length - 1 ) ) * BigInt ( 1000 ) ;
39+ return BigInt ( quantity . slice ( 0 , quantity . length - 1 ) ) * BigInt ( 1000 ) ;
4040 case 'M' :
41- return BigInt ( quantity . substr ( 0 , quantity . length - 1 ) ) * BigInt ( 1000 * 1000 ) ;
41+ return BigInt ( quantity . slice ( 0 , quantity . length - 1 ) ) * BigInt ( 1000 * 1000 ) ;
4242 case 'G' :
43- return BigInt ( quantity . substr ( 0 , quantity . length - 1 ) ) * BigInt ( 1000 * 1000 * 1000 ) ;
43+ return BigInt ( quantity . slice ( 0 , quantity . length - 1 ) ) * BigInt ( 1000 * 1000 * 1000 ) ;
4444 case 'T' :
45- return (
46- BigInt ( quantity . substr ( 0 , quantity . length - 1 ) ) * BigInt ( 1000 * 1000 * 1000 ) * BigInt ( 1000 )
47- ) ;
45+ return BigInt ( quantity . slice ( 0 , quantity . length - 1 ) ) * BigInt ( 1000 * 1000 * 1000 ) * BigInt ( 1000 ) ;
4846 case 'P' :
4947 return (
50- BigInt ( quantity . substr ( 0 , quantity . length - 1 ) ) *
48+ BigInt ( quantity . slice ( 0 , quantity . length - 1 ) ) *
5149 BigInt ( 1000 * 1000 * 1000 ) *
5250 BigInt ( 1000 * 1000 )
5351 ) ;
5452 case 'E' :
5553 return (
56- BigInt ( quantity . substr ( 0 , quantity . length - 1 ) ) *
54+ BigInt ( quantity . slice ( 0 , quantity . length - 1 ) ) *
5755 BigInt ( 1000 * 1000 * 1000 ) *
5856 BigInt ( 1000 * 1000 * 1000 )
5957 ) ;
6058 case 'Ki' :
61- return BigInt ( quantity . substr ( 0 , quantity . length - 2 ) ) * BigInt ( 1024 ) ;
59+ return BigInt ( quantity . slice ( 0 , quantity . length - 2 ) ) * BigInt ( 1024 ) ;
6260 case 'Mi' :
63- return BigInt ( quantity . substr ( 0 , quantity . length - 2 ) ) * BigInt ( 1024 * 1024 ) ;
61+ return BigInt ( quantity . slice ( 0 , quantity . length - 2 ) ) * BigInt ( 1024 * 1024 ) ;
6462 case 'Gi' :
65- return BigInt ( quantity . substr ( 0 , quantity . length - 2 ) ) * BigInt ( 1024 * 1024 * 1024 ) ;
63+ return BigInt ( quantity . slice ( 0 , quantity . length - 2 ) ) * BigInt ( 1024 * 1024 * 1024 ) ;
6664 case 'Ti' :
67- return (
68- BigInt ( quantity . substr ( 0 , quantity . length - 2 ) ) * BigInt ( 1024 * 1024 * 1024 ) * BigInt ( 1024 )
69- ) ;
65+ return BigInt ( quantity . slice ( 0 , quantity . length - 2 ) ) * BigInt ( 1024 * 1024 * 1024 ) * BigInt ( 1024 ) ;
7066 case 'Pi' :
7167 return (
72- BigInt ( quantity . substr ( 0 , quantity . length - 2 ) ) *
68+ BigInt ( quantity . slice ( 0 , quantity . length - 2 ) ) *
7369 BigInt ( 1024 * 1024 * 1024 ) *
7470 BigInt ( 1024 * 1024 )
7571 ) ;
7672 case 'Ei' :
7773 return (
78- BigInt ( quantity . substr ( 0 , quantity . length - 2 ) ) *
74+ BigInt ( quantity . slice ( 0 , quantity . length - 2 ) ) *
7975 BigInt ( 1024 * 1024 * 1024 ) *
8076 BigInt ( 1024 * 1024 * 1024 )
8177 ) ;
0 commit comments