diff --git a/LICENSE b/LICENSE index ea42c28..7797f2b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ The MIT License (MIT) -Copyright (c) 2022 Aldwin Vlasblom +Copyright (c) 2024 Aldwin Vlasblom Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 7ad380e..a02f654 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ be used. ### EventEmitter -#### `once :: String -⁠> EventEmitter -⁠> Future Error a` +#### `once :: String -⁠> EventEmitter -⁠> Future Error a` Resolve a Future with the first event emitted over the given event emitter under the given event name. @@ -35,7 +35,7 @@ Future.of (42); ### Buffer -#### `encode :: Charset -⁠> Buffer -⁠> Future Error String` +#### `encode :: Charset -⁠> Buffer -⁠> Future Error String` Given an encoding and a [Buffer][], returns a Future of the result of encoding said buffer using the given encoding. The Future will reject @@ -48,7 +48,7 @@ with an Error if the encoding is unknown. ### Stream -#### `streamOf :: Buffer -⁠> Future a (Readable Buffer)` +#### `streamOf :: Buffer -⁠> Future a (Readable Buffer)` Given a [Buffer][], returns a Future of a [Readable][] stream which will emit the given Buffer before ending. @@ -57,12 +57,12 @@ The stream is wrapped in a Future because creation of a stream causes side-effects if it's not consumed in time, making it safer to pass it around wrapped in a Future. -#### `emptyStream :: Future a (Readable Buffer)` +#### `emptyStream :: Future a (Readable Buffer)` A [Readable][] stream which ends after emiting zero bytes. Can be useful as an empty [`Request`](#Request) body, for example. -#### `buffer :: Readable a -⁠> Future Error (Array a)` +#### `buffer :: Readable a -⁠> Future Error (Array a)` Buffer all data on a [Readable][] stream into a Future of an Array. @@ -80,7 +80,7 @@ itself from the Stream. Future.of ([Buffer.from ('hello'), Buffer.from ('world')]); ``` -#### `bufferString :: Charset -⁠> Readable Buffer -⁠> Future Error String` +#### `bufferString :: Charset -⁠> Readable Buffer -⁠> Future Error String` A version of [`buffer`](#buffer) specialized in Strings. @@ -89,7 +89,7 @@ a Future containing a String with the fully buffered and encoded result. ### Event Loop -#### `instant :: b -⁠> Future a b` +#### `instant :: b -⁠> Future a b` Resolves a Future with the given value in the next tick, using [`process.nextTick`][]. The scheduled job cannot be @@ -101,7 +101,7 @@ blocking the event loop until it's completed. Future.of ('noodles') ``` -#### `immediate :: b -⁠> Future a b` +#### `immediate :: b -⁠> Future a b` Resolves a Future with the given value in the next tick, using [`setImmediate`][]. This job will run as soon as all @@ -188,7 +188,7 @@ which either make decisions for you, taking away control in an attempt to provide a smoother usage experience, or which take complicated structures of interacting options to attempt to cater to as many cases as possible. -#### `Request :: Object -⁠> Url -⁠> Future Error (Readable Buffer) -⁠> Request` +#### `Request :: Object -⁠> Url -⁠> Future Error (Readable Buffer) -⁠> Request` Constructs a value of type Request to be used as an argument for functions such as [`sendRequest`](#sendRequest). @@ -206,19 +206,19 @@ Takes the following arguments: See [`sendRequest`](#sendRequest) for a usage example. -#### `Request.options :: Request -⁠> Object` +#### `Request.options :: Request -⁠> Object` Get the options out of a Request. -#### `Request.url :: Request -⁠> Url` +#### `Request.url :: Request -⁠> Url` Get the url out of a Request. -#### `Request.body :: Request -⁠> Future Error (Readable Buffer)` +#### `Request.body :: Request -⁠> Future Error (Readable Buffer)` Get the body out of a Request. -#### `Response :: Request -⁠> IncomingMessage -⁠> Response` +#### `Response :: Request -⁠> IncomingMessage -⁠> Response` Constructs a value of type Response. These values are typically created for you by functions such as [`sendRequest`](#sendRequest). @@ -227,15 +227,15 @@ Takes the following arguments: 1. A [Request](#Request). 2. An [IncomingMessage][] assumed to belong to the Request. -#### `Response.request :: Response -⁠> Request` +#### `Response.request :: Response -⁠> Request` Get the request out of a Response. -#### `Response.message :: Response -⁠> IncomingMessage` +#### `Response.message :: Response -⁠> IncomingMessage` Get the message out of a Response. -#### `sendRequest :: Request -⁠> Future Error Response` +#### `sendRequest :: Request -⁠> Future Error Response` This is the "lowest level" function for making HTTP requests. It does not handle buffering, encoding, content negotiation, or anything really. @@ -265,7 +265,7 @@ sendRequest (BinaryPostRequest ('https://example.com') (eventualBody)); If you want to use this function to transfer a stream of data, don't forget to set the Transfer-Encoding header to "chunked". -#### `retrieve :: Url -⁠> StrMap String -⁠> Future Error Response` +#### `retrieve :: Url -⁠> StrMap String -⁠> Future Error Response` A version of [`sendRequest`](#sendRequest) specialized in the `GET` method. @@ -276,7 +276,7 @@ makes a GET requests to the given resource. retrieve ('https://api.github.com/users/Avaq') ({'User-Agent': 'Avaq'}) ``` -#### `send :: Mimetype -⁠> Method -⁠> Url -⁠> StrMap String -⁠> Buffer -⁠> Future Error Response` +#### `send :: Mimetype -⁠> Method -⁠> Url -⁠> StrMap String -⁠> Buffer -⁠> Future Error Response` A version of [`sendRequest`](#sendRequest) for sending arbitrary data to a server. There's also more specific versions for sending common types of @@ -294,7 +294,7 @@ This function will always send the Content-Type and Content-Length headers, alongside the provided headers. Manually provoding either of these headers override those generated by this function. -#### `sendJson :: Method -⁠> String -⁠> StrMap String -⁠> JsonValue -⁠> Future Error Response` +#### `sendJson :: Method -⁠> String -⁠> StrMap String -⁠> JsonValue -⁠> Future Error Response` A version of [`send`](#send) specialized in sending JSON. @@ -309,7 +309,7 @@ sendJson ('PUT') ({name: 'Bob', email: 'bob@example.com'}); ``` -#### `sendForm :: Method -⁠> String -⁠> StrMap String -⁠> JsonValue -⁠> Future Error Response` +#### `sendForm :: Method -⁠> String -⁠> StrMap String -⁠> JsonValue -⁠> Future Error Response` A version of [`send`](#send) specialized in sending form data. @@ -324,7 +324,7 @@ sendForm ('POST') ({name: 'Bob', email: 'bob@example.com'}); ``` -#### `matchStatus :: (Response -⁠> a) -⁠> StrMap (Response -⁠> a) -⁠> Response -⁠> a` +#### `matchStatus :: (Response -⁠> a) -⁠> StrMap (Response -⁠> a) -⁠> Response -⁠> a` Transform a [`Response`](#Response) based on its status code. @@ -358,7 +358,7 @@ matchStatus (processResponse) ({ }); ``` -#### `redirectAnyRequest :: Response -⁠> Request` +#### `redirectAnyRequest :: Response -⁠> Request` A redirection strategy that simply reissues the original Request to the Location specified in the given Response. @@ -369,7 +369,7 @@ If the new location is on an external host, then any confidential headers Used in the [`defaultRedirectionPolicy`](#defaultRedirectionPolicy) and the [`aggressiveRedirectionPolicy`](#aggressiveRedirectionPolicy). -#### `redirectIfGetMethod :: Response -⁠> Request` +#### `redirectIfGetMethod :: Response -⁠> Request` A redirection strategy that simply reissues the original Request to the Location specified in the given Response, but only if the original request @@ -380,7 +380,7 @@ If the new location is on an external host, then any confidential headers Used in [`followRedirectsStrict`](#followRedirectsStrict). -#### `redirectUsingGetMethod :: Response -⁠> Request` +#### `redirectUsingGetMethod :: Response -⁠> Request` A redirection strategy that sends a new GET request based on the original request to the Location specified in the given Response. If the response @@ -394,7 +394,7 @@ new request. Used in the [`defaultRedirectionPolicy`](#defaultRedirectionPolicy) and the [`aggressiveRedirectionPolicy`](#aggressiveRedirectionPolicy). -#### `retryWithoutCondition :: Response -⁠> Request` +#### `retryWithoutCondition :: Response -⁠> Request` A redirection strategy that removes any caching headers if present and retries the request, or does nothing if no caching headers were present @@ -402,7 +402,7 @@ on the original request. Used in the [`defaultRedirectionPolicy`](#defaultRedirectionPolicy). -#### `defaultRedirectionPolicy :: Response -⁠> Request` +#### `defaultRedirectionPolicy :: Response -⁠> Request` Carefully follows redirects in strict accordance with [RFC2616 Section 10.3][]. @@ -432,7 +432,7 @@ retrieve ('https://example.com') ({}) .pipe (chain (followRedirectsWith (myRedirectionPolicy) (10))) ``` -#### `aggressiveRedirectionPolicy :: Response -⁠> Request` +#### `aggressiveRedirectionPolicy :: Response -⁠> Request` Aggressively follows redirects in mild violation of [RFC2616 Section 10.3][]. In particular, anywhere that a redirection @@ -451,7 +451,7 @@ retrieve ('https://example.com') ({}) .pipe (chain (followRedirectsWith (aggressiveRedirectionPolicy) (10))) ``` -#### `followRedirectsWith :: (Response -⁠> Request) -⁠> Number -⁠> Response -⁠> Future Error Response` +#### `followRedirectsWith :: (Response -⁠> Request) -⁠> Number -⁠> Response -⁠> Future Error Response` Given a function that take a Response and produces a new Request, and a "maximum" number, recursively keeps resolving new requests until a request @@ -462,14 +462,14 @@ follower. See [`aggressiveRedirectionPolicy`](#aggressiveRedirectionPolicy) and [`defaultRedirectionPolicy`](defaultRedirectionPolicy) for additional usage examples. -#### `followRedirects :: Number -⁠> Response -⁠> Future Error Response` +#### `followRedirects :: Number -⁠> Response -⁠> Future Error Response` Given the maximum numbers of redirections, follows redirects according to the [default redirection policy](#defaultRedirectionPolicy). See the [Http section](#http) for a usage example. -#### `acceptStatus :: Number -⁠> Response -⁠> Future Response Response` +#### `acceptStatus :: Number -⁠> Response -⁠> Future Response Response` This function "tags" a [Response](#Response) based on a given status code. If the response status matches the given status code, the returned Future @@ -486,7 +486,7 @@ In combination with [`responseToError`](#responseToError), you can then flatten it back into the outer Future. The usage example under the [Http](#http) section shows this. -#### `bufferMessage :: Charset -⁠> IncomingMessage -⁠> Future Error String` +#### `bufferMessage :: Charset -⁠> IncomingMessage -⁠> Future Error String` A version of [`buffer`](#buffer) specialized in [IncomingMessage][]s. @@ -496,14 +496,14 @@ See also [`bufferResponse`](#bufferResponse) and Given a charset and an IncomingMessage, returns a Future with the buffered, encoded, message body. -#### `bufferResponse :: Charset -⁠> Response -⁠> Future Error String` +#### `bufferResponse :: Charset -⁠> Response -⁠> Future Error String` A composition of [`Response.message`](#Response.message) and [`bufferMessage`](#bufferMessage) for your convenience. See also [autoBufferResponse](#autoBufferResponse). -#### `autoBufferMessage :: IncomingMessage -⁠> Future Error String` +#### `autoBufferMessage :: IncomingMessage -⁠> Future Error String` Given an IncomingMessage, buffers and decodes the message body using the charset provided in the message headers. Falls back to UTF-8 if the @@ -513,14 +513,14 @@ Returns a Future with the buffered, encoded, message body. See also [bufferMessage](#bufferMessage). -#### `autoBufferResponse :: Response -⁠> Future Error String` +#### `autoBufferResponse :: Response -⁠> Future Error String` A composition of [`Response.message`](#Response.message) and [`autoBufferMessage`](#autoBufferMessage) for your convenience. See also [bufferResponse](#bufferResponse). -#### `responseToError :: Response -⁠> Future Error a` +#### `responseToError :: Response -⁠> Future Error a` Given a [Response](#Response), returns a *rejected* Future of an instance of Error with a message based on the content of the response. diff --git a/package.json b/package.json index e64ffb9..8bb66ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fluture-node", - "version": "4.0.2", + "version": "4.0.3", "description": "FP-style HTTP and streaming utils for Node based on Fluture", "keywords": [ "buffer",