New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

bs-hyperquest

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bs-hyperquest

BuckleScript bindings for Substack's hyperquest (http-client) library.

0.3.0
Version published
Maintainers
1
Created

bs-hyperquest

BuckleScript bindings for substack's hyperquest library.

Usage

Standard Event Interface

GET
let result =
  Js.Promise.make((~resolve, ~reject) =>
    Hyperquest.get(~uri, ())
    |. Hyperquest.on(
         `response(
           res => {
             let data = ref("");

             res
             |. Hyperquest.IncomingMessage.on(
                  `data(
                    b => data := data^ ++ Hyperquest.Buffer.toString(b),
                  ),
                )
             |. Hyperquest.IncomingMessage.on(
                  `error(exn => reject(. exn)),
                )
             |. Hyperquest.IncomingMessage.on(
                  `end_(_ => resolve(. data^)),
                )
             |. ignore;
           },
         ),
       )
    |. ignore
  );

reason-future Interface

GET
Hyperquest.Future.get(~uri, ())
|. Future.mapOk(((_, data)) => data)
|. Future.mapError(res =>
  switch(res) {
  | (_, `error(exn)) => exn |. Js.String.make |. fail |. finish
  | (_, `response(data)) => data |. fail |. finish
  }
)
|. ignore

FAQs

Package last updated on 25 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts