Skip to content
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

Closed
wants to merge 5 commits into from
Closed

Conversation

ariporad
Copy link
Contributor

@@ -18,3 +18,12 @@ module.exports = function (ms) {

return thunk;
};

module.exports.reject = function (ms, value) {
if (value) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.


module.exports.reject = function (ms, value) {
if (arguments.length === 1) {
return new Promise(function (resolve, reject) {
Copy link
Contributor

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');
Copy link
Owner

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.

@sindresorhus
Copy link
Owner

Tests are failing.

@ariporad
Copy link
Contributor Author

Ok @sindresorhus, should be fixed now.

@sindresorhus
Copy link
Owner

@ariporad See jamestalmage@d925de7 ;)

@ariporad
Copy link
Contributor Author

Ok @sindresorhus: Integrated @jamestalmage's idea, rebased master.

Sorry @sindresorhus, but I like to watch the world burn! 😄
@sindresorhus sindresorhus changed the title Add Delay.reject() Add delay.reject() Dec 25, 2015
@sindresorhus
Copy link
Owner

Landed. Thank you @ariporad :)

resolve(result);
}, ms);
module.exports = generate(true);
module.exports.resolve = module.exports;
Copy link
Owner

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.

@sindresorhus
Copy link
Owner

Happy holidays 🎄

sindresorhus added a commit that referenced this pull request Dec 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants