1 var test = require("tap").test
3 var some = require("../some.js")
5 test("some() doesn't find anything asynchronously", function (t) {
6 some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
7 t.ifError(error, "ran successfully")
9 t.notOk(match, "nothing to find, so nothing found")
14 function predicate(value, cb) {
15 // dezalgo ensures it's safe to not do this, but just in case
16 setTimeout(function () { cb(null, value > "j" && value) })
20 test("some() doesn't find anything synchronously", function (t) {
21 some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
22 t.ifError(error, "ran successfully")
24 t.notOk(match, "nothing to find, so nothing found")
29 function predicate(value, cb) {
30 cb(null, value > "j" && value)
34 test("some() doesn't find anything asynchronously", function (t) {
35 some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
36 t.ifError(error, "ran successfully")
38 t.equals(match, "d", "found expected element")
43 function predicate(value, cb) {
44 setTimeout(function () { cb(null, value > "c" && value) })
48 test("some() doesn't find anything synchronously", function (t) {
49 some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
50 t.ifError(error, "ran successfully")
52 t.equals(match, "d", "found expected")
57 function predicate(value, cb) {
58 cb(null, value > "c" && value)