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 [#5366][4].
[0]: https://nodejs.org/api/util.html#util_util_callbackify_original
[1]: 4780493301/lib/util.js (L183-L226)
[2]: 4780493301/test/parallel/test-util-callbackify.js
[3]: 7d24857ddb/types/node/util.d.ts (L61-L84)
[4]: https://github.com/denoland/deno/issues/5366
* Prepend underscores to private modules
* Remove collectUint8Arrays() It would be a misuse of Deno.iter()'s result.
* Move std/_util/async.ts to std/async
* Move std/util/sha*.ts to std/hash
This change is to prevent needed a separate stat syscall for each file
when using readdir.
For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
This PR brings assertOps and assertResources sanitizers to Deno.test() API.
assertOps checks that test doesn't leak async ops, ie. there are no unresolved
promises originating from Deno APIs. Enabled by default, can be disabled using
Deno.TestDefinition.disableOpSanitizer.
assertResources checks that test doesn't leak resources, ie. all resources used
in test are closed. For example; if a file is opened during a test case it must be
explicitly closed before test case finishes. It's most useful for asynchronous
generators. Enabled by default, can be disabled using
Deno.TestDefinition.disableResourceSanitizer.
We've used those sanitizers in internal runtime tests and it proved very useful in
surfacing incorrect tests which resulted in interference between the tests.
All tests have been sanitized.
Closes #4208