<commit_before>/* aaa Artem : done. implement */
let _;

if( typeof module !== 'undefined' )
{
  _ = require( 'wTools' );
  require( 'wConsequence' );
}

let hydTotal = 20;
let oxTotal = 10;
const formedMolecules = [];

const waitingAtoms = { hyd : 0, ox : 0 }

let hyd = new _.Consequence();
let ox = new _.Consequence();
let con = new _.Consequence().take( null );

run( hydTotal, oxTotal );

let l = hydTotal / 2 < oxTotal ? hydTotal / 2 : oxTotal;
for( let i = 0; i < l; i++ )
con.then( () =>
{
  formedMolecules.push( [ Hydrogen(), Hydrogen(), Oxygen() ] );
  console.log( formedMolecules );

  hyd = new _.Consequence();
  ox = new _.Consequence();
  return null;
} );

//

function formMolecule()
{
  hyd.take( 'h' );
  ox.take( 'o' );

  waitingAtoms.hyd -= 2;
  waitingAtoms.ox -= 1;
}

//

function run( h, o )
{
  for( let i = 1; i <= h; i++ )
  _.time.out( 1000 * i, addHyd );

  for( let i = 1; i <= o; i++ )
  _.time.out( 500 * i, addOx );
}

//

function addHyd()
{
  waitingAtoms.hyd += 1;

  if( waitingAtoms.hyd >= 2 && waitingAtoms.ox )
  formMolecule();
}

//

function addOx()
{
  waitingAtoms.ox += 1;

  if( waitingAtoms.hyd >= 2 )
  formMolecule();
}

//

function Hydrogen()
{
  hyd.deasync();
  return hyd.sync();
}

//

function Oxygen()
{
  ox.deasync();
  return ox.sync();
}<commit_msg>BuildingH2O logs task, logs added<commit_after>/* aaa Artem : done. implement */
let _;

if( typeof module !== 'undefined' )
{
  _ = require( 'wTools' );
  require( 'wConsequence' );
}

let hydTotal = 20;
let oxTotal = 10;
const formedMolecules = [];
const startTime = _.time.now();

const waitingAtoms = { hyd : 0, ox : 0 }

let hyd = new _.Consequence();
let ox = new _.Consequence();
let con = new _.Consequence().take( null );

run( hydTotal, oxTotal );

let l = hydTotal / 2 < oxTotal ? hydTotal / 2 : oxTotal;
for( let i = 0; i < l; i++ )
con.then( () =>
{
  formedMolecules.push( [ Hydrogen(), Hydrogen(), Oxygen() ] );
  console.log( `+ new molecule was formed - ${status()}` );
  console.log();
  hyd = new _.Consequence();
  ox = new _.Consequence();
  return null;
} );

//

function status()
{
  return `time: ${_.time.spent( startTime )}, molecules: ${formedMolecules.length}, hydrogen: ${waitingAtoms.hyd}, oxygen: ${waitingAtoms.ox}`;
}

//

function formMolecule()
{
  hyd.take( 'h' );
  ox.take( 'o' );

  waitingAtoms.hyd -= 2;
  waitingAtoms.ox -= 1;
}

//

function run( h, o )
{
  for( let i = 1; i <= h; i++ )
  _.time.out( 1250 * i, addHyd );

  for( let i = 1; i <= o; i++ )
  _.time.out( 1750 * i, addOx );
}

//

function addHyd()
{
  waitingAtoms.hyd += 1;
  console.log( `+ hydrogen - ${status()}` );

  if( waitingAtoms.hyd >= 2 && waitingAtoms.ox )
  formMolecule();
}

//

function addOx()
{
  waitingAtoms.ox += 1;
  console.log( `+ oxygen - ${status()}` );

  if( waitingAtoms.hyd >= 2 )
  formMolecule();
}

//

function Hydrogen()
{
  hyd.deasync();
  return hyd.sync();
}

//

function Oxygen()
{
  ox.deasync();
  return ox.sync();
}
{'fraction_non_alphanumeric': 0.19591426657736102, 'fraction_numerical': 0.016744809109176157, 'mean_word_length': 3.0040214477211795, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '960594', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1160, 'n_words': 304}