simple-polling
Advanced tools
+1
-2
@@ -7,3 +7,2 @@ var poll = require('./poll') | ||
| .timeout(15000) | ||
| .then(function (num) { console.log('Finished with: ' + num) }) | ||
| .run() | ||
| .run(function (num) { console.log('Finished with: ' + num) }) |
+1
-1
@@ -7,3 +7,3 @@ { | ||
| }, | ||
| "version": "0.1.0", | ||
| "version": "0.2.0", | ||
| "description": "A simple polling abstraction for repeating an asynchronous action until a desired outcome is achieved.", | ||
@@ -10,0 +10,0 @@ "main": "poll.js", |
+2
-8
@@ -6,3 +6,2 @@ module.exports = function (op) { | ||
| , interval_ms = 5000 | ||
| , finish = function () {} | ||
@@ -24,8 +23,3 @@ face.until = function (predicate) { | ||
| face.then = function (done) { | ||
| finish = done | ||
| return this | ||
| } | ||
| face.run = function run() { | ||
| face.run = function run(cb) { | ||
| var started = Date.now() | ||
@@ -37,3 +31,3 @@ | ||
| pred.apply(null, arguments) || (timeout_ms && elapsed >= timeout_ms) | ||
| ? finish.apply(null, arguments) | ||
| ? cb.apply(null, arguments) | ||
| : setTimeout(function () { op(decision) }, interval_ms) | ||
@@ -40,0 +34,0 @@ }) |
1436
-7.35%34
-15%