@@ -123,24 +123,21 @@ const strings = [
123123 'I' ,
124124] ;
125125
126- const app = document . getElementById ( 'app' ) ! ;
126+ const tbodyInnerHTML = strings
127+ . map ( str => {
128+ const nq = `${ numericQuantity ( str ) } ` ;
129+ const nqa = `${ numericQuantity ( str , { allowTrailingInvalid : true } ) } ` ;
130+ const nqr = `${ numericQuantity ( str , { romanNumerals : true } ) } ` ;
131+ return `<tr><td>numericQuantity("${ str } ")</td><td>${ nq } </td><td${ nqa !== nq ? ' class="diff"' : '' } >${ nqa } </td><td${ nqr !== nq ? ' class="diff"' : '' } >${ nqr } </td></tr>` ;
132+ } )
133+ . join ( '' ) ;
127134
128- app . innerHTML = `<h1>numeric-quantity CI</h1>
135+ document . getElementById ( ' app' ) ! . innerHTML = `<h1>numeric-quantity CI</h1>
129136<table>
130- <thead><tr><th>Expression</th><th>Result</th></tr></thead>
137+ <thead><tr><th>Expression</th><th>Default</th><th>allowTrailingInvalid</th><th>romanNumerals</th></tr></thead>
138+ <tbody>${ tbodyInnerHTML } </tbody>
131139</table>` ;
132140
133- const table = document . querySelector ( 'table' ) ! ;
134- const tbody = document . createElement ( 'tbody' ) ! ;
135-
136- for ( const s of strings ) {
137- const tr = document . createElement ( 'tr' ) ;
138- const result = numericQuantity ( s , {
139- romanNumerals : true ,
140- allowTrailingInvalid : true ,
141- } ) ;
142- tr . innerHTML = `<td>numericQuantity("${ s } ")</td><td>${ result } </td>` ;
143- tbody . appendChild ( tr ) ;
144- }
145-
146- table . appendChild ( tbody ) ;
141+ Object . defineProperty ( globalThis , 'numericQuantity' , {
142+ value : numericQuantity ,
143+ } ) ;
0 commit comments