-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
std/node: add util.callbackify #5415
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Looks like I've introduced some linting errors. I'll fix those. |
EvanHahn
force-pushed
the
std-node-util-callbackify
branch
2 times, most recently
from
May 14, 2020 21:42
69ce6bb
to
7223ed5
Compare
ry
reviewed
May 15, 2020
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.
Thanks - looks good!
This adds [Node's `util.callbackify`][0] to `std/node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland#5366
EvanHahn
force-pushed
the
std-node-util-callbackify
branch
from
May 15, 2020 14:49
7223ed5
to
d00e2bc
Compare
ry
approved these changes
May 20, 2020
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.
LGTM - thanks @EvanHahn
EvanHahn
added a commit
to EvanHahn/evanhahn-dot-com
that referenced
this pull request
May 20, 2020
caspervonb
pushed a commit
to caspervonb/deno_std
that referenced
this pull request
Jan 21, 2021
This adds [Node's `util.callbackify`][0] to `std/node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland/deno#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland/deno#5366
caspervonb
pushed a commit
to caspervonb/deno_std
that referenced
this pull request
Jan 24, 2021
This adds [Node's `util.callbackify`][0] to `node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland/deno#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland/deno#5366
caspervonb
pushed a commit
to caspervonb/deno_std
that referenced
this pull request
Jan 24, 2021
This adds [Node's `util.callbackify`][0] to `node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland/deno#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland/deno#5366
caspervonb
pushed a commit
to caspervonb/deno_std
that referenced
this pull request
Jan 24, 2021
This adds [Node's `util.callbackify`][0] to `node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland/deno#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland/deno#5366
caspervonb
pushed a commit
to caspervonb/deno_std
that referenced
this pull request
Jan 31, 2021
This adds [Node's `util.callbackify`][0] to `node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland/deno#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland/deno#5366
caspervonb
pushed a commit
to caspervonb/deno_std
that referenced
this pull request
Jan 31, 2021
This adds [Node's `util.callbackify`][0] to `node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland/deno#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland/deno#5366
caspervonb
pushed a commit
to caspervonb/deno_std
that referenced
this pull request
Jan 31, 2021
This adds [Node's `util.callbackify`][0] to `node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland/deno#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland/deno#5366
caspervonb
pushed a commit
to caspervonb/deno_std
that referenced
this pull request
Jan 31, 2021
This adds [Node's `util.callbackify`][0] to `node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland/deno#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland/deno#5366
caspervonb
pushed a commit
to caspervonb/deno_std
that referenced
this pull request
Feb 1, 2021
This adds [Node's `util.callbackify`][0] to `node/util.ts`. I lifted most of this from the [original Node source code][1] (and [its tests][2]). I tried to make minimal modifications to the source. I made a few arbitrary decisions: - I was unable to do the function's types elegantly. I made overloads for functions that have 0 to 5 (inclusive) arguments, excluding the callback. I would love to know a better way to do this. (It seems that the folks at DefinitelyTyped [were also stumped][3], though maybe their solution is deliberate.) - There are a few edge cases that cause custom Node errors to be produced. Instead of re-implementing those errors completely, I created simplified classes. These are mostly correct but are not identical to the real Node errors. - The tests implement a possibly-arcane `TestQueue` class. I originally used a lot of inline promises but found it too repetitive. Closes [denoland/deno#5366][4]. [0]: https://nodejs.org/api/util.html#util_util_callbackify_original [1]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/lib/util.js#L183-L226 [2]: https://github.com/nodejs/node/blob/47804933012841f2dc90626bdcc161adf34569a5/test/parallel/test-util-callbackify.js [3]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7d24857ddb07ab637dfa8c477d13352f8a8206fc/types/node/util.d.ts#L61-L84 [4]: denoland/deno#5366
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds Node's
util.callbackify
tostd/node/util.ts
.I lifted most of this from the original Node source code (and its tests). I tried to make minimal modifications to the source.
I made a few arbitrary decisions:
TestQueue
class. I originally used a lot of inline promises but found it too repetitive.Closes #5366.