
var pull = require('../')
var test = require('tape')

test('find 7', function (t) {
  pull.values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
  .pipe(pull.find(function (d) {
    return d == 7
  }, function (err, seven) {
    t.equal(seven, 7)
    t.notOk(err)
    t.end()
  }))
})

var target = Math.random()
test('find ' + target, function (t) {
  var f = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(Math.random)

  f.push(target)

  pull.values(f.sort())
  .pipe(pull.find(function (d) {
    return d == target
  }, function (err, found) {
    t.equal(found, target)
    t.notOk(err)
    t.end()
  }))
})

test('find missing', function (t) {
  var f = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

  pull.values(f.sort())
  .pipe(pull.find(function (d) {
    return d == target
  }, function (err, found) {
    t.equal(found, null)
    t.notOk(err)
    t.end()
  }))
})




@@ -837,9 +837,274 @@
 ))%0A%7D)%0A%0A%0A
+test('there can only be one', function (t) %7B%0Atest('find 7', function (t) %7B%0A  pull.values(%5B1, 2, 3, 4, 5, 6, 7, 8, 9, 10%5D)%0A  .pipe(pull.find(function (d) %7B%0A    return d %3E= 7%0A  %7D, function (err, seven) %7B%0A    t.equal(seven, 7)%0A    t.notOk(err)%0A    t.end()%0A  %7D))%0A%7D)%0A%0A%7D)
 %0A

test find only returns one