@@ -71,8 +71,7 @@ const defaultMethods = {
7171 return res
7272 } ,
7373 '*' : ( data ) => {
74- // eslint-disable-next-line no-throw-literal
75- if ( data . length === 0 ) throw INVALID_ARGUMENTS
74+ if ( data . length === 0 ) return 1
7675 let res = 1
7776 for ( let i = 0 ; i < data . length ; i ++ ) {
7877 if ( data [ i ] && typeof data [ i ] === 'object' ) throw NaN
@@ -83,7 +82,7 @@ const defaultMethods = {
8382 } ,
8483 '/' : ( data ) => {
8584 if ( data [ 0 ] && typeof data [ 0 ] === 'object' ) throw NaN
86- // eslint-disable-next-line no-throw-literal
85+
8786 if ( data . length === 0 ) throw INVALID_ARGUMENTS
8887 if ( data . length === 1 ) {
8988 if ( ! + data [ 0 ] || ( data [ 0 ] && typeof data [ 0 ] === 'object' ) ) throw NaN
@@ -116,7 +115,7 @@ const defaultMethods = {
116115 } ,
117116 '%' : ( data ) => {
118117 if ( data [ 0 ] && typeof data [ 0 ] === 'object' ) throw NaN
119- // eslint-disable-next-line no-throw-literal
118+
120119 if ( data . length < 2 ) throw INVALID_ARGUMENTS
121120 let res = + data [ 0 ]
122121 for ( let i = 1 ; i < data . length ; i ++ ) {
@@ -129,6 +128,7 @@ const defaultMethods = {
129128 throw : ( type ) => {
130129 if ( Array . isArray ( type ) ) type = type [ 0 ]
131130 if ( typeof type === 'object' ) throw type
131+
132132 // eslint-disable-next-line no-throw-literal
133133 throw { type }
134134 } ,
@@ -1042,11 +1042,10 @@ defaultMethods['/'].compile = function (data, buildState) {
10421042// @ts -ignore Allow custom attribute
10431043defaultMethods [ '*' ] . compile = function ( data , buildState ) {
10441044 if ( Array . isArray ( data ) ) {
1045- // eslint-disable-next-line no-throw-literal
1046- if ( data . length === 0 ) throw INVALID_ARGUMENTS
1045+ if ( data . length === 0 ) return '1'
10471046 return `precoerceNumber(${ data . map ( i => numberCoercion ( i , buildState ) ) . join ( ' * ' ) } )`
10481047 }
1049- return `assertSize (${ buildString ( data , buildState ) } , 1 ).reduce((a,b) => (+precoerceNumber(a))*(+precoerceNumber(b)))`
1048+ return `(${ buildString ( data , buildState ) } ).reduce((a,b) => (+precoerceNumber(a))*(+precoerceNumber(b)), 1 )`
10501049}
10511050
10521051// @ts -ignore Allow custom attribute
0 commit comments