@fayti1703/async-utils

Various (async) Promise utility functions

Usage no npm install needed!

<script type="module">
  import fayti1703AsyncUtils from 'https://cdn.skypack.dev/@fayti1703/async-utils';
</script>

README

@fayti1703/async-utils

Various async utility functions

slurp(stream, encoding)

"Slurps" the given stream; all remaining data will be consumed and returned.

Note: This function rejects if the stream emits an 'error' event.

request(options, body, encoding)

Sends a HTTPS request to the specified server. The resulting response is passed to msgToObj, the result of which is returned.

requestInsecure(options, body, encoding)

Sends a HTTP request to the specified server. This function acts just as request does otherwise.

msgToObj(message)

Converts message into an equivalent object with an added data property and toString function.

Note: Due to the implementation of this function, properties from the message may be dropped. If this includes a property you need, please file a bug report.

sleep(ms)

  • ms [<number>][number] How long to sleep for

An alias for setTimeout[util.promisify.custom].