<commit_before>
var bucket = require('..')
var assert = require('assert')

var alphabet = '<KEY>-'

function random(n) {
  var a = alphabet[~~(Math.random()*alphabet.length)]
  return ( n ? a + random(n - 1) : a )
}

var b = bucket('BUCKET')

assert.equal(typeof b, 'function')
assert.equal(typeof b.range, 'function')

function within(range, key) {
  return range.start <= key && key < range.end
}

function times (n, iter) {
  while(n-- > 0) iter(n)
}

times(1000, function () {
  var b  = bucket(random(6))
  var _b = bucket(random(6))
  var K  = random(6)
  var k  = b (K)
  var _k = _b(K)

  assert( b.range().within(k))
  //keys for a different bucket *must* fall outside the range.
  assert( !_b.range().within(k) )
  assert( _b.range().within(_k) )
})

times(1000, function () {
  var b  = bucket(random(6))
  var _b = bucket(random(6))
  var K  = random(6)
  var K2  = random(6)
  var k  = b (K, K2)
  var _k = _b(K, K2)

  assert( within(b.range(), k) )
  //keys for a different bucket *must* fall outside the range.
  assert( !within(_b.range(),  k) )
  assert(  within(_b.range(), _k) )
})


times(1000, function () {
  var b  = bucket(random(6))
  var big = random(4), little = random(4), _little = random(4)

  assert(within(b.range([big, true]), b([big, little])))
  assert(within(b.range([big, little]), b([big, little])))
  assert(within(b.range([true, true]), b([big, little])))

  assert(!within(b.range([big, little]), b([big, _little])))
  assert(within(b.range([big, true]), b([big, _little])))
  assert(within(b.range([true, true]), b([big, _little])))
})

times(10, function () {
  var b  = bucket(random(6), 'sub')
  var big = random(4), little = random(4), _little = random(4)

  console.log(b.range([big, true]) )
  console.log(b([big, little]))

  assert(b.range([big, true]).within(b([big, little])))
  assert(b.range([big, little]).within(b([big, little])))
  assert(b.range([true, true]).within(b([big, little])))

  assert(!b.range([big, little]).within(b([big, _little])))
  assert(b.range([big, true])   .within( b([big, _little])))
  assert(b.range([true, true])  .within(b([big, _little])))
})
<commit_msg>less looping<commit_after>
var bucket = require('..')
var assert = require('assert')

var alphabet = 'AOEUIDHTNSQJKXBMWVZPYFGCRLpyfgcrlaoeuidhtnszvwmbxkjq7531902468_-'

function random(n) {
  var a = alphabet[~~(Math.random()*alphabet.length)]
  return ( n ? a + random(n - 1) : a )
}

var b = bucket('BUCKET')

assert.equal(typeof b, 'function')
assert.equal(typeof b.range, 'function')

function within(range, key) {
  return range.start <= key && key < range.end
}

function times (n, iter) {
  while(n-- > 0) iter(n)
}

times(100, function () {
  var b  = bucket(random(6))
  var _b = bucket(random(6))
  var K  = random(6)
  var k  = b (K)
  var _k = _b(K)

  console.log(b.parse(k))

  assert( b.range().within(k))
  //keys for a different bucket *must* fall outside the range.
  assert( !_b.range().within(k) )
  assert( _b.range().within(_k) )
})

times(100, function () {
  var b  = bucket(random(6))
  var _b = bucket(random(6))
  var K  = random(6)
  var K2  = random(6)
  var k  = b (K, K2)
  var _k = _b(K, K2)

  assert( within(b.range(), k) )
  //keys for a different bucket *must* fall outside the range.
  assert( !within(_b.range(),  k) )
  assert(  within(_b.range(), _k) )
})


times(100, function () {
  var b  = bucket(random(6))
  var big = random(4), little = random(4), _little = random(4)

  assert(within(b.range([big, true]), b([big, little])))
  assert(within(b.range([big, little]), b([big, little])))
  assert(within(b.range([true, true]), b([big, little])))

  console.log(b.parse(b([big, little])))


  assert(!within(b.range([big, little]), b([big, _little])))
  assert(within(b.range([big, true]), b([big, _little])))
  assert(within(b.range([true, true]), b([big, _little])))
})

times(10, function () {
  var b  = bucket(random(6), 'sub')
  var big = random(4), little = random(4), _little = random(4)

  //console.log(b.range([big, true]) )
//  console.log(b([big, little]))

  console.log(b.parse(b([big, little])))

  assert(b.range([big, true]).within(b([big, little])))
  assert(b.range([big, little]).within(b([big, little])))
  assert(b.range([true, true]).within(b([big, little])))

  assert(!b.range([big, little]).within(b([big, _little])))
  assert(b.range([big, true])   .within( b([big, _little])))
  assert(b.range([true, true])  .within(b([big, _little])))
})

{'fraction_non_alphanumeric': 0.21508756174225416, 'fraction_numerical': 0.016838796587337224, 'mean_word_length': 4.186263096623981, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, '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': '861284', 'n_tokens_mistral': 1814, 'n_tokens_neox': 1711, 'n_words': 396}