1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-15 18:38:53 -05:00
denoland-deno/std
Evan Hahn f5c0188b5e
std/node: add util.callbackify (#5415)
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
2020-05-20 10:29:05 -04:00
..
_util BREAKING(std): reorganization (#5087) 2020-05-09 08:34:47 -04:00
archive BREAKING: Remove Deno.EOF, use null instead (#4953) 2020-04-28 12:40:43 -04:00
async improve deferred test (#5459) 2020-05-15 16:59:44 -04:00
bytes BREAKING: reorder std/io/utils copyBytes arguments (#5022) 2020-04-30 16:39:25 -04:00
datetime BREAKING: remove overload of Deno.test() (#4951) 2020-04-28 12:33:09 +02:00
encoding docs(std): Fix typo (#5582) 2020-05-18 12:10:19 +02:00
examples improve chat example (#5474) 2020-05-15 17:00:31 -04:00
flags BREAKING(std): reorganization (#5087) 2020-05-09 08:34:47 -04:00
fmt docs(std): fixed spelling mistake (#5662) 2020-05-20 13:20:20 +02:00
fs Implement Deno.symlink() for windows (#5533) 2020-05-19 00:46:02 +02:00
hash fix(std/hash): SHA1 hash of Uint8Array (#5086) 2020-05-18 00:04:11 +02:00
http Miscellaneous documentation and spelling improvements (#5527) 2020-05-17 19:24:39 +02:00
io Miscellaneous documentation and spelling improvements (#5527) 2020-05-17 19:24:39 +02:00
log fix(std/log): await default logger setup (#5341) 2020-05-20 16:27:01 +02:00
mime fix(multipart): fix error when parsing file name in utf8 format (#5428) 2020-05-19 14:22:26 -04:00
node std/node: add util.callbackify (#5415) 2020-05-20 10:29:05 -04:00
path Revert "Fix definition of URL constructor (#5521)" (#5564) 2020-05-18 08:46:56 -04:00
permissions Update to Prettier 2 and use ES Private Fields (#4498) 2020-03-28 13:03:49 -04:00
signal BREAKING(std): reorganization (#5087) 2020-05-09 08:34:47 -04:00
testing Provide better ANSI colorized output when inspecting objects (#5404) 2020-05-19 14:19:26 -04:00
textproto fix(multipart): fix error when parsing file name in utf8 format (#5428) 2020-05-19 14:22:26 -04:00
uuid BREAKING(std): reorganization (#5087) 2020-05-09 08:34:47 -04:00
ws shorten example (#5448) 2020-05-15 08:51:15 -04:00
README.md fix(std): fix broken style guide link (#5211) 2020-05-11 20:36:24 -04:00
version.ts std/0.51.0 (#5336) 2020-05-14 13:45:05 +02:00

Deno Standard Modules

These modules do not have external dependencies and they are reviewed by the Deno core team. The intention is to have a standard set of high quality code that all Deno projects can use fearlessly.

Contributions are welcome!

How to use

These modules are tagged in accordance with Deno releases. So, for example, the v0.3.0 tag is guaranteed to work with deno v0.3.0. You can link to v0.3.0 using the URL https://deno.land/std@v0.3.0/. Not specifying a tag will link to the master branch.

It is strongly recommended that you link to tagged releases to avoid unintended updates.

Don't link to / import any module whose path:

  • Has a name or parent with an underscore prefix: _foo.ts, _util/bar.ts.
  • Is that of a test module or test data: test.ts, foo_test.ts, testdata/bar.txt.

No stability is guaranteed for these files.

Documentation

To browse documentation for modules:

Contributing

deno_std is a loose port of Go's standard library. When in doubt, simply port Go's source code, documentation, and tests. There are many times when the nature of JavaScript, TypeScript, or Deno itself justifies diverging from Go, but if possible we want to leverage the energy that went into building Go. We generally welcome direct ports of Go's code.

Please ensure the copyright headers cite the code's origin.

Follow the style guide.