You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
401 B
JavaScript

"use strict";
const Promise = require("bluebird");
const simpleSink = require("@promistream/simple-sink");
module.exports = function find(predicate) {
// FIXME: Validatem
return simpleSink({
onResult: (value, abort) => {
return Promise.try(() => {
return predicate(value);
}).then((result) => {
if (result === true) {
abort(true);
return value;
}
});
}
});
};