assert.ok(foundValue.value === 6)
})
it('using thread worker, binary search closest by array value, when it is exact match', async() => {
const arr = [6, 9, 8, 4, 1, 7, 3, 10, 5, 2]
arr.sort()
const foundValue = await bsClosest.worker({
type: 'value',
target: 5,
array: arr,
})
assert.ok(foundValue === 5)
})
it('using thread worker, binary search closest by array value, but find the closest value', async() => {
const arr = [9, 8, 4, 1, 7, 3, 10, 5, 2]
arr.sort()
const foundValue = await bsClosest.worker({
type: 'value',
target: -1,
array: arr,
})
assert.ok(foundValue === 1)
})