npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

axiosbridge

v1.1.0

Published

A RESTful specific wrapper for axios.

Readme

axiosbridge

A wrapper for axios that converts Promises from incoming responses into Monads.

Usage:

import axios from "axios";
import axiosbridge from "axiosbridge";

const bridge = new axiosbridge.Bridge({
  baseURL: "https://www.google.com",
}, axios);

(async () => await axiosbridge.execSafeAsync(
  async () => bridge.get("/"),
  {
    onFulfilled: (result) => console.dir(result),
    onError: (error) => console.error(error),
    _finally: () => console.log("I get logged after the handlers are done in both cases."),
  }
))();

API

Table of Contents

Bridge

A wrapper for an axios instance that converts the returned Promises in to Results when a request is made.

Parameters

axios_instance

Main axios instance to be used for all requests

Type: AxiosInstance

connection_timeout

Time before giving up on server discovery.

get

Request fetch

Parameters

Returns Promise<Result<Option<T>, E>>

post

Request create

Parameters

Returns Promise<Result<Option<H>, E>>

patch

Request patch

Parameters

Returns Promise<Result<Option<H>, E>>

put

Request update

Parameters

Returns Promise<Result<Option<H>, E>>

delete

Request delete

Parameters

Returns Promise<Result<Option<T>, E>>

setErrorConstructor

Sets the error constructor.

Parameters

  • errorConstructor function (err: any): E New error constructor

convertPromiseToResult

Runs the provided function and if it throws an error it catches and logs then it converts Promise to a Result before returning it.

Parameters

  • _function function (...args: any): Promise<T> The function to be run
  • onReject function (err: any): E? Runs if the function throws an error
  • onFulfill function (result: T): T Runs if the function completes successfully (optional, default (result:T)=>result)
  • config PromiseToResultConverterConfig Configuration for the convertor (optional, default {logErrors:false})
  • errorConstructor function (err: any): E? Transforms one type of error into another

Returns Promise<Result<T, E>>

execSafeAsync

Runs an async function that will always resolve to a Result and runs the proper handler with the resulting value.

Parameters

Returns Promise<(F | void)>

cleanableExec

Delays the execution of a function by the provided delay and returns a cleanup function to clean the timeout later. The delay is 0 by default.

N.B. This is to be used for calling asynchronous tasks in useEffects that execute on mount.

Parameters

  • _function function (): void The function to be run
  • delay The delay after which the function is to be run (optional, default 0)
  • onClean CleanableExecOnCleanConfig? Handler configuration for cleanup

cleanableSafeAsyncExec

Wraps cleanable [execSafeAsync] in a {cleanableExec}

Parameters

processAbortController

It aborts if an external controller is provided and produces a new controller if not.

Parameters

PromiseToResultConverterConfig

Type: {logErrors: boolean}

Properties

logErrors

Determines whether the converter logs errors when the function being run throws.

Type: boolean

SafeAsyncExecHandlers

Type: {onFulfilled: function (value: T): void, onError: function (error: E): void?, onNone: function (): void?, _finally: function (): (F | void)?}

Properties

  • onFulfilled function (value: T): void
  • onError function (error: E): void?
  • onNone function (): void?
  • _finally function (): (F | void)?

onFulfilled

Runs if the execution resolved without errors, and it yields a non-empty value.

Type: function (value: T): void

onError

Runs if the execution fails.

Type: function (error: E): void

onNone

Runs if the execution is resolved without errors, but it yields an empty value.

Type: function (): void

_finally

Runs after all other handlers without condition if provided.

Type: function (): (F | void)

CleanableExecOnCleanConfig

Type: {handler: function (): void, cleanAfter: boolean?}

Properties

  • handler function (): void
  • cleanAfter boolean?

handler

The function to be appended.

Type: function (): void

cleanAfter

Determines whether to run the function after the timeout clean up. If true it runs the function after.

Type: boolean

CleanableSafeAsyncExecHandlers

Type: {onFulfilled: function (value: T): void, onError: function (error: E): void?, onNone: function (): void?, _finally: function (): (F | void)?, onClean: CleanableExecOnCleanConfig?}

Properties

  • onFulfilled function (value: T): void
  • onError function (error: E): void?
  • onNone function (): void?
  • _finally function (): (F | void)?
  • onClean CleanableExecOnCleanConfig?

onFulfilled

Runs if the execution resolved without errors, and it yields a non-empty value.

Type: function (value: T): void

onError

Runs if the execution fails.

Type: function (error: E): void

onNone

Runs if the execution is resolved without errors, but it yields an empty value.

Type: function (): void

_finally

Runs after all other handlers without condition if provided.

Type: function (): (F | void)

onClean

Appended to the cleaner function that is returned from a cleanable execution.

Type: CleanableExecOnCleanConfig

DEFAULT_CONNECTION_TIME_OUT

Time before giving up on server discovery.

Type: number

DEFAULT_REQUEST_TIME_OUT

Time before giving up on response from a server after a handshake.

Type: number

Option

Result

AbortController

AxiosInstance

CreateAxiosDefaults

AxiosRequestConfig

AxiosResponse

AxiosStatic