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AEL,KAAK,OAAQ,EAGR,I,EAGT,EAAkB,UAAU,KAAO,WAKjC,OAJA,KAAK,OAAO,MAAK,SAAU,EAAG,GAC5B,OAAQ,EAAE,OAAS,EAAE,K,IACpB,UACH,KAAK,OAAQ,EACN,I","file":"/npm/tiny-binary-search@1.0.3/dist/binary-search-index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/tiny-binary-search@1.0.3/dist/binary-search-index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","function BinarySearchIndex (values) {\n  this.values = [].concat(values || []);\n}\n\nBinarySearchIndex.prototype.query = function (value) {\n  var index = this.getIndex(value);\n  return this.values[index];\n};\n\nBinarySearchIndex.prototype.getIndex = function getIndex (value) {\n  if (this.dirty) {\n    this.sort();\n  }\n\n  var minIndex = 0;\n  var maxIndex = this.values.length - 1;\n  var currentIndex;\n  var currentElement;\n\n  while (minIndex <= maxIndex) {\n    currentIndex = (minIndex + maxIndex) / 2 | 0;\n    currentElement = this.values[Math.round(currentIndex)];\n    if (+currentElement.value < +value) {\n      minIndex = currentIndex + 1;\n    } else if (+currentElement.value > +value) {\n      maxIndex = currentIndex - 1;\n    } else {\n      return currentIndex;\n    }\n  }\n\n  return Math.abs(~maxIndex);\n};\n\nBinarySearchIndex.prototype.between = function between (start, end) {\n  var startIndex = this.getIndex(start);\n  var endIndex = this.getIndex(end);\n\n  if (startIndex === 0 && endIndex === 0) {\n    return [];\n  }\n\n  while (this.values[startIndex - 1] && this.values[startIndex - 1].value === start) {\n    startIndex--;\n  }\n\n  while (this.values[endIndex + 1] && this.values[endIndex + 1].value === end) {\n    endIndex++;\n  }\n\n  if (this.values[endIndex] && this.values[endIndex].value === end && this.values[endIndex + 1]) {\n    endIndex++;\n  }\n\n  return this.values.slice(startIndex, endIndex);\n};\n\nBinarySearchIndex.prototype.insert = function insert (item) {\n  this.values.splice(this.getIndex(item.value), 0, item);\n  return this;\n};\n\nBinarySearchIndex.prototype.bulkAdd = function bulkAdd (items, sort) {\n  this.values = this.values.concat([].concat(items || []));\n\n  if (sort) {\n    this.sort();\n  } else {\n    this.dirty = true;\n  }\n\n  return this;\n};\n\nBinarySearchIndex.prototype.sort = function sort () {\n  this.values.sort(function (a, b) {\n    return +b.value - +a.value;\n  }).reverse();\n  this.dirty = false;\n  return this;\n};\n\nexport default BinarySearchIndex;\n"]}