array-to-btree-object

Takes an array of data and a comparison function, returns an object

Usage no npm install needed!

<script type="module">
  import arrayToBtreeObject from 'https://cdn.skypack.dev/array-to-btree-object';
</script>

README

array-to-btree-object

This module takes a list and a comparison function, and returns an object that looks kinda like this:


{
  data: 'the-item-in-your-list',
  left: {
    data: 'another-item-in-your-list'
  },
  right: {
    data: 'another-item'
  }
}

The comparison function looks kinda like this:


function (item, treeItem) {
   return item > treeItem;
}