Skip to content

Commit

Permalink
docs(read-core-model): add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayaksaxena committed Feb 7, 2022
1 parent e153b02 commit cc5d0d1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/read-core-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
const originalModel = require( './languages/cur/models/eng-core-web-model.json' );

/**
* Converts `base64` string into an array buffer. It works as a replacement for
* `Buffer.from( data, 'base64' )` of Node.js and delivers better browser
* compatibility.
*
* @param {string} data - base64 string of data to be converted
* @returns {ArrayBuffer} an ArrayBuffer of the data
*/
Expand All @@ -60,10 +64,10 @@ var readModel = function ( ) {
var packing = model.packing;
var featuresData = model.features;
var pos = model.pos;
// Read the lexicon block.
model.lexicon = new Uint32Array(bufferFromBase64(model.lexicon));
// Read the lexicon & expansions blocks and convert them into `Uint32Array`.
model.lexicon = new Uint32Array( bufferFromBase64( model.lexicon ) );

model.xpansions = new Uint32Array(bufferFromBase64(model.xpansions));
model.xpansions = new Uint32Array( bufferFromBase64( model.xpansions ) );

// Rebuild hash from list for the required features.
for ( const f in model.packing.layout ) {
Expand Down

0 comments on commit cc5d0d1

Please sign in to comment.