Page 153 - JavaScript
P. 153

}
           };

           ArrayBufferCursor.prototype.hasNext = function() {
             return this.index < this.size;
           }

           return ArrayBufferCursor;
         });


        You can then create an iterator like this:


         var cursor = new ArrayBufferCursor(arrayBuffer);


        You can use the hasNext to check if there's still items


         for(;cursor.hasNext();) {
             // There's still items to process
         }


        You can use the next method to take the next value:


         var nextValue = cursor.next('Float');


        With such an iterator, writing your own parser to process binary data becomes pretty easy.

        Read Binary Data online: https://riptutorial.com/javascript/topic/417/binary-data















































        https://riptutorial.com/                                                                             110
   148   149   150   151   152   153   154   155   156   157   158