33 * The pad object, defined with joose
44 */
55
6-
6+ const AttributeMap = require ( '../../static/js/AttributeMap' ) ;
77const Changeset = require ( '../../static/js/Changeset' ) ;
88const ChatMessage = require ( '../../static/js/ChatMessage' ) ;
99const AttributePool = require ( '../../static/js/AttributePool' ) ;
@@ -647,16 +647,6 @@ Pad.prototype.check = async function () {
647647 assert ( pool instanceof AttributePool ) ;
648648 await pool . check ( ) ;
649649
650- const decodeAttribString = function * ( str ) {
651- const re = / \* ( [ 0 - 9 a - z ] + ) | ./ gy;
652- let match ;
653- while ( ( match = re . exec ( str ) ) != null ) {
654- const [ m , n ] = match ;
655- if ( n == null ) throw new Error ( `invalid character in attribute string: ${ m } ` ) ;
656- yield Number . parseInt ( n , 36 ) ;
657- }
658- } ;
659-
660650 const authors = new Set ( ) ;
661651 pool . eachAttrib ( ( k , v ) => {
662652 if ( k === 'author' && v ) authors . add ( v ) ;
@@ -681,9 +671,7 @@ Pad.prototype.check = async function () {
681671 Changeset . checkRep ( changeset ) ;
682672 const unpacked = Changeset . unpack ( changeset ) ;
683673 let text = atext . text ;
684- const iter = Changeset . opIterator ( unpacked . ops ) ;
685- while ( iter . hasNext ( ) ) {
686- const op = iter . next ( ) ;
674+ for ( const op of Changeset . deserializeOps ( unpacked . ops ) ) {
687675 if ( [ '=' , '-' ] . includes ( op . opcode ) ) {
688676 assert ( text . length >= op . chars ) ;
689677 const consumed = text . slice ( 0 , op . chars ) ;
@@ -692,14 +680,7 @@ Pad.prototype.check = async function () {
692680 if ( op . lines > 0 ) assert ( consumed . endsWith ( '\n' ) ) ;
693681 text = text . slice ( op . chars ) ;
694682 }
695- let prevK = null ;
696- for ( const n of decodeAttribString ( op . attribs ) ) {
697- const attrib = pool . getAttrib ( n ) ;
698- assert ( attrib != null ) ;
699- const [ k ] = attrib ;
700- assert ( prevK == null || prevK < k ) ;
701- prevK = k ;
702- }
683+ assert . equal ( op . attribs , AttributeMap . fromString ( op . attribs , pool ) . toString ( ) ) ;
703684 }
704685 atext = Changeset . applyToAText ( changeset , atext , pool ) ;
705686 assert . deepEqual ( await this . getInternalRevisionAText ( r ) , atext ) ;
0 commit comments