@@ -46,13 +46,11 @@ exports.error = (msg) => {
46
46
* throw an exception.
47
47
*
48
48
* @param {boolean } b - assertion condition
49
- * @param {...any } msgParts - error message to include in the exception
50
- * @type {(b: boolean, ...msgParts: any[] ) => asserts b }
49
+ * @param {string } msg - error message to include in the exception
50
+ * @type {(b: boolean, msg: string ) => asserts b }
51
51
*/
52
- exports . assert = ( b , ...msgParts ) => {
53
- if ( ! b ) {
54
- exports . error ( `Failed assertion: ${ msgParts . join ( '' ) } ` ) ;
55
- }
52
+ exports . assert = ( b , msg ) => {
53
+ if ( ! b ) exports . error ( `Failed assertion: ${ msg } ` ) ;
56
54
} ;
57
55
58
56
/**
@@ -282,13 +280,13 @@ exports.checkRep = (cs) => {
282
280
break ;
283
281
case '-' :
284
282
oldPos += o . chars ;
285
- exports . assert ( oldPos <= oldLen , oldPos , ' > ' , oldLen , ' in ' , cs ) ;
283
+ exports . assert ( oldPos <= oldLen , ` ${ oldPos } > ${ oldLen } in ${ cs } ` ) ;
286
284
break ;
287
285
case '+' :
288
286
{
289
287
calcNewLen += o . chars ;
290
288
numInserted += o . chars ;
291
- exports . assert ( calcNewLen <= newLen , calcNewLen , ' > ' , newLen , ' in ' , cs ) ;
289
+ exports . assert ( calcNewLen <= newLen , ` ${ calcNewLen } > ${ newLen } in ${ cs } ` ) ;
292
290
break ;
293
291
}
294
292
}
@@ -538,7 +536,7 @@ exports.stringIterator = (str) => {
538
536
const getnewLines = ( ) => newLines ;
539
537
540
538
const assertRemaining = ( n ) => {
541
- exports . assert ( n <= remaining ( ) , '!(' , n , ' <= ' , remaining ( ) , ')' ) ;
539
+ exports . assert ( n <= remaining ( ) , `!( ${ n } <= ${ remaining ( ) } )` ) ;
542
540
} ;
543
541
544
542
const take = ( n ) => {
@@ -1066,8 +1064,8 @@ exports.pack = (oldLen, newLen, opsStr, bank) => {
1066
1064
*/
1067
1065
exports . applyToText = ( cs , str ) => {
1068
1066
const unpacked = exports . unpack ( cs ) ;
1069
- exports . assert ( str . length === unpacked . oldLen , 'mismatched apply: ' , str . length ,
1070
- ' / ' , unpacked . oldLen ) ;
1067
+ exports . assert (
1068
+ str . length === unpacked . oldLen , `mismatched apply: ${ str . length } / ${ unpacked . oldLen } ` ) ;
1071
1069
const csIter = exports . opIterator ( unpacked . ops ) ;
1072
1070
const bankIter = exports . stringIterator ( unpacked . charBank ) ;
1073
1071
const strIter = exports . stringIterator ( str ) ;
@@ -1338,7 +1336,7 @@ exports.mutateAttributionLines = (cs, lines, pool) => {
1338
1336
}
1339
1337
lineAssem . append ( op ) ;
1340
1338
if ( op . lines > 0 ) {
1341
- exports . assert ( op . lines === 1 , " Can't have op.lines of " , op . lines , ' in attribution lines' ) ;
1339
+ exports . assert ( op . lines === 1 , ` Can't have op.lines of ${ op . lines } in attribution lines` ) ;
1342
1340
// ship it to the mut
1343
1341
mut . insert ( lineAssem . toString ( ) , 1 ) ;
1344
1342
lineAssem = null ;
0 commit comments