@@ -71,8 +71,7 @@ const defaultMethods = {
71
71
return res
72
72
} ,
73
73
'*' : ( data ) => {
74
- // eslint-disable-next-line no-throw-literal
75
- if ( data . length === 0 ) throw INVALID_ARGUMENTS
74
+ if ( data . length === 0 ) return 1
76
75
let res = 1
77
76
for ( let i = 0 ; i < data . length ; i ++ ) {
78
77
if ( data [ i ] && typeof data [ i ] === 'object' ) throw NaN
@@ -83,7 +82,7 @@ const defaultMethods = {
83
82
} ,
84
83
'/' : ( data ) => {
85
84
if ( data [ 0 ] && typeof data [ 0 ] === 'object' ) throw NaN
86
- // eslint-disable-next-line no-throw-literal
85
+
87
86
if ( data . length === 0 ) throw INVALID_ARGUMENTS
88
87
if ( data . length === 1 ) {
89
88
if ( ! + data [ 0 ] || ( data [ 0 ] && typeof data [ 0 ] === 'object' ) ) throw NaN
@@ -116,7 +115,7 @@ const defaultMethods = {
116
115
} ,
117
116
'%' : ( data ) => {
118
117
if ( data [ 0 ] && typeof data [ 0 ] === 'object' ) throw NaN
119
- // eslint-disable-next-line no-throw-literal
118
+
120
119
if ( data . length < 2 ) throw INVALID_ARGUMENTS
121
120
let res = + data [ 0 ]
122
121
for ( let i = 1 ; i < data . length ; i ++ ) {
@@ -129,6 +128,7 @@ const defaultMethods = {
129
128
throw : ( type ) => {
130
129
if ( Array . isArray ( type ) ) type = type [ 0 ]
131
130
if ( typeof type === 'object' ) throw type
131
+
132
132
// eslint-disable-next-line no-throw-literal
133
133
throw { type }
134
134
} ,
@@ -1042,11 +1042,10 @@ defaultMethods['/'].compile = function (data, buildState) {
1042
1042
// @ts -ignore Allow custom attribute
1043
1043
defaultMethods [ '*' ] . compile = function ( data , buildState ) {
1044
1044
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'
1047
1046
return `precoerceNumber(${ data . map ( i => numberCoercion ( i , buildState ) ) . join ( ' * ' ) } )`
1048
1047
}
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 )`
1050
1049
}
1051
1050
1052
1051
// @ts -ignore Allow custom attribute
0 commit comments