<commit_before>/* eslint-env mocha */
/* eslint max-nested-callbacks: ['error', 8] */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const series = require('async/series')
const each = require('async/each')
const parallel = require('async/parallel')
const whilst = require('async/whilst')
const hat = require('hat')
const { spawnNodesWithId } = require('./utils/spawn')

// On Browsers it will be false, but the tests currently aren't run
// there anyway
let isWindows = process.platform && process.platform === 'win32'

function waitForPeers (ipfs, topic, peersToWait, callback) {
  const i = setInterval(() => {
    ipfs.pubsub.peers(topic, (err, peers) => {
      if (err) {
        return callback(err)
      }

      const missingPeers = peersToWait
        .map((e) => peers.indexOf(e) !== -1)
        .filter((e) => !e)

      if (missingPeers.length === 0) {
        clearInterval(i)
        callback()
      }
    })
  }, 500)
}

function makeCheck (n, done) {
  let i = 0
  return (err) => {
    if (err) {
      return done(err)
    }

    if (++i === n) {
      done()
    }
  }<commit_msg>fix(pubsub): clear interval on error<commit_after>/* eslint-env mocha */
/* eslint max-nested-callbacks: ['error', 8] */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const series = require('async/series')
const each = require('async/each')
const parallel = require('async/parallel')
const whilst = require('async/whilst')
const hat = require('hat')
const { spawnNodesWithId } = require('./utils/spawn')

// On Browsers it will be false, but the tests currently aren't run
// there anyway
let isWindows = process.platform && process.platform === 'win32'

function waitForPeers (ipfs, topic, peersToWait, callback) {
  const i = setInterval(() => {
    ipfs.pubsub.peers(topic, (err, peers) => {
      if (err) {
        clearInterval(i)
        return callback(err)
      }

      const missingPeers = peersToWait
        .map((e) => peers.indexOf(e) !== -1)
        .filter((e) => !e)

      if (missingPeers.length === 0) {
        clearInterval(i)
        callback()
      }
    })
  }, 500)
}

function makeCheck (n, done) {
  let i = 0
  return (err) => {
    if (err) {
      return done(err)
    }

    if (++i === n) {
      done()
    }
  }
{'fraction_non_alphanumeric': 0.1600496277915633, 'fraction_numerical': 0.007444168734491315, 'mean_word_length': 2.914239482200647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '572108', 'n_tokens_mistral': 818, 'n_tokens_neox': 794, 'n_words': 211}