@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33 return ( mod && mod . __esModule ) ? mod : { "default" : mod } ;
44} ;
55Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
6- exports . math = exports . roundCustom = exports . RoundingMethod = void 0 ;
6+ exports . math = exports . roundCustom = exports . RoundingMethodEnum = void 0 ;
77exports . numberToPrecision = numberToPrecision ;
88/* eslint-disable */
99const mathjs_1 = __importDefault ( require ( "mathjs" ) ) ;
@@ -20,7 +20,10 @@ const EPSILON = 1e-8;
2020 * @param v2 Vector 2
2121 */
2222const product = ( v1 , v2 ) => {
23- return exports . math . multiply ( v1 , exports . math . transpose ( v2 ) ) ;
23+ if ( v1 . length !== v2 . length ) {
24+ throw new Error ( "Vectors must be of the same length" ) ;
25+ }
26+ return Number ( exports . math . multiply ( v1 , exports . math . transpose ( v2 ) ) ) ;
2427} ;
2528/**
2629 * @summary Returns length of a vector.
@@ -171,22 +174,22 @@ const roundValueToNDecimals = (value, decimals = 3) => {
171174 return parseFloat ( value . toFixed ( decimals ) ) ;
172175} ;
173176// See: https://en.wikipedia.org/wiki/Rounding
174- var RoundingMethod ;
175- ( function ( RoundingMethod ) {
176- RoundingMethod [ "Bankers" ] = "bankers" ;
177- RoundingMethod [ "HalfAwayFromZero" ] = "halfAwayFromZero" ;
178- } ) ( RoundingMethod || ( exports . RoundingMethod = RoundingMethod = { } ) ) ;
179- const roundCustom = ( value , decimals = 0 , method = RoundingMethod . HalfAwayFromZero ) => {
177+ var RoundingMethodEnum ;
178+ ( function ( RoundingMethodEnum ) {
179+ RoundingMethodEnum [ "Bankers" ] = "bankers" ;
180+ RoundingMethodEnum [ "HalfAwayFromZero" ] = "halfAwayFromZero" ;
181+ } ) ( RoundingMethodEnum || ( exports . RoundingMethodEnum = RoundingMethodEnum = { } ) ) ;
182+ const roundCustom = ( value , decimals = 0 , method = RoundingMethodEnum . HalfAwayFromZero ) => {
180183 const factor = Math . pow ( 10 , decimals ) ;
181184 const scaledValue = value * factor ;
182185 const absValue = Math . abs ( scaledValue ) ;
183186 const sign = scaledValue < 0 ? - 1 : 1 ;
184187 let roundedAbs ;
185188 switch ( method ) {
186- case RoundingMethod . HalfAwayFromZero :
189+ case RoundingMethodEnum . HalfAwayFromZero :
187190 roundedAbs = Math . round ( absValue ) ;
188191 break ;
189- case RoundingMethod . Bankers :
192+ case RoundingMethodEnum . Bankers :
190193 const floorValue = Math . floor ( absValue ) ;
191194 const fractional = absValue - floorValue ;
192195 if ( Math . abs ( fractional - 0.5 ) < Number . EPSILON ) {
@@ -261,5 +264,5 @@ exports.math = {
261264 roundValueToNDecimals,
262265 numberToPrecision,
263266 roundCustom : exports . roundCustom ,
264- RoundingMethod,
267+ RoundingMethod : RoundingMethodEnum ,
265268} ;
0 commit comments