0.7.5 • Published 7 years ago
@fayti1703/async-utils v0.7.5
@fayti1703/async-utils
Various async utility functions
slurp(stream, encoding)
stream<stream.Readable> The stream to slurpencoding<string> The character encoding to use. All encodings supported by the node Buffer API are accepted. Use 'raw' to return the buffer itself. Default:'utf-8'- Returns: <Promise<string>|<Buffer>>
"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)
options<Object> | <string> | <URL> Seehttps.requestbody<string> | <Buffer> The body of the request. Useundefinedfor no body.encoding<string> The character encoding to use. Uses the same format asslurp- Returns: <Promise<Object>> (See
msgToObj)
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)
options<Object> | <string> | <URL> Seehttp.requestbody<string> | <Buffer> The body of the request. Useundefinedfor no body.encoding<string> The character encoding to use. Uses the same format asslurp- Returns: <Promise<Object>> (See
msgToObj)
Sends a HTTP request to the specified server. This function acts just as request does otherwise.
msgToObj(message)
message<http.IncomingMessage> | <http.ServerResponse> The message to convert
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> How long to sleep for
An alias for setTimeout[util.promisify.custom].