<commit_before>"use strict";
/* eslint-env node,mocha */


const expect = require('expect.js');

const throttlePeriod = require('../../async/throttlePeriod');
const setImmediate   = require('../../async/setImmediate');

const each  = require('../../async/each');

const range = require('mout/array/range');

describe('throttlePeriod', function() {

  this.timeout(10 * 1000);
  it('basics', async function() {

    var results    = {};
    var a          = 0;
    var b          = 0;
    var fn         = async function (c) {
      results[a++] = c;
    };
    var p          = throttlePeriod(fn, 1000);

    await each(range(1, 10), async function() {
      await p(b++);
    });

    expect(results).to.eql({0 : 0, 1 : 9});
  });

  it('with no period', async function() {

    var results    = {};
    var a          = 0;
    var b          = 0;
    /* eslint-disable */
    var d          = 0;
    /* eslint-enable */
    var fn         = async function (c) {
      d++;
      results[a++] = c;
    };
    var p          = throttlePeriod(fn);

    setImmediate(function() {
      d++;
    });

    await each(range(1, 10), async function() {
      await p(b++);
    });

    expect(results).to.eql({0 : 0, 1 : 9});
  });

});
<commit_msg>Cleanup deprecated code<commit_after>"use strict";
/* eslint-env node,mocha */


const expect = require('expect.js');

const throttlePeriod = require('../../async/throttlePeriod');

const each  = require('../../async/each');

const range = require('mout/array/range');

describe('throttlePeriod', function() {

  this.timeout(10 * 1000);
  it('basics', async function() {

    var results    = {};
    var a          = 0;
    var b          = 0;
    var fn         = async function (c) {
      results[a++] = c;
    };
    var p          = throttlePeriod(fn, 1000);

    await each(range(1, 10), async function() {
      await p(b++);
    });

    expect(results).to.eql({0 : 0, 1 : 9});
  });

  it('with no period', async function() {

    var results    = {};
    var a          = 0;
    var b          = 0;
    var fn         = async function (c) {
      results[a++] = c;
    };
    var p          = throttlePeriod(fn);

    await each(range(1, 10), async function() {
      await p(b++);
    });

    expect(results).to.eql({0 : 0, 1 : 9});
  });

});

{'fraction_non_alphanumeric': 0.18434782608695652, 'fraction_numerical': 0.024782608695652172, 'mean_word_length': 1.9613899613899615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '492333', 'n_tokens_mistral': 825, 'n_tokens_neox': 749, 'n_words': 187}