-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delay.reject()
#8
Conversation
@@ -18,3 +18,12 @@ module.exports = function (ms) { | |||
|
|||
return thunk; | |||
}; | |||
|
|||
module.exports.reject = function (ms, value) { | |||
if (value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use arguments.length
so they can reject with a falsy value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamestalmage: Fixed. I always do that.
59a1192
to
131f575
Compare
|
||
module.exports.reject = function (ms, value) { | ||
if (arguments.length === 1) { | ||
return new Promise(function (resolve, reject) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arguments.length > 1
t.true(inRange(end(), 30, 70)); | ||
t.is(result, 'foo'); | ||
t.true(inRange(end(), 30, 70), 'should be delayed'); | ||
t.is(result, 'foo', 'should pass through the value'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of using the should
convention. This seems clearer to me:
passes through the value
Same with the others.
Tests are failing. |
Ok @sindresorhus, should be fixed now. |
@ariporad See jamestalmage@d925de7 ;) |
bef2ae5
to
2b10bdb
Compare
Ok @sindresorhus: Integrated @jamestalmage's idea, rebased master. |
Sorry @sindresorhus, but I like to watch the world burn! 😄
Landed. Thank you @ariporad :) |
resolve(result); | ||
}, ms); | ||
module.exports = generate(true); | ||
module.exports.resolve = module.exports; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice try, but we already made a decision about this in #7. We're always open to reconsider if you surface some use-cases we haven't thought of, but should be discussed in the original issue. We don't add stuff just because. There should always be an actual use-case behind something. It might seem simple, but everything adds overhead, either for the system or for the user.
Happy holidays 🎄 |
Fixes #7.
cc @jamestalmage, @sindresorhus.