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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@musicq/net

v1.0.0

Published

A HTTP client built on top of RxJS.

Downloads

5

Readme

Net

Net is an HTTP client which is built on top of RxJS.

Installation

Using npm

npm install @musicq/net

or using yarn

yarn add @musciq/net

Usage

Here's a basic example to raise a HTTP request.

import {http} from '@musicq/net'

const request = http.get('/api/todos').pipe(
  map(res => res.body)
)

request.subscribe(res => console.log(res))

net provides some utilities functions to let us handle error easily.

If you want to return a default value when your requests encounter an exception error. You can use defaultValue function.

It will return the default value you provide instead of return an error. This is useful when we need a fallback and don't want to tell if error occurs.

import {catchError} from "rxjs/operators";
import {defaultValue} from '@musicq/net'

const request = http.get('/api/todos').pipe(
  map(res => res.body),
  // provide a default value to return it.
  catchError(defaultValue([]))
)

Sometimes you may need to show an error tip when there is an error.

You can do it using the native ability of RxJS.

import {catchError} from "rxjs/operators";
import {errorWrapper, isError} from '@musicq/net'

const request = http.get('/api/todos').pipe(
  map(res => res.body)
)

request.subscribe(
  res => console.log(res),
  err => console.error(err)
)

Or You can use errorWrapper in cooperation with isError to handle errors.

import {catchError} from "rxjs/operators";
import {errorWrapper, isError} from '@musicq/net'

const request = http.get('/api/todos').pipe(
  map(res => res.body),
  // catch the error and wrap it in a HttpErr instance, then return
  catchError(errorWrapper)
)

request.subscribe(res => {
  if (isError(res)) {
    console.log(res.e)
    return
  }

  console.log(res)
})

This is handy when you want to unify the process of handling both error and normal responses.

net has provided a simple version of errorWrapper, called simpleErrorWrapper to let you can use it in any other scenarios without Observable.

For example, if you want to handle a Promise error in the same way.

import {simpleErrorWrapper, isError} from '@musicq/net';

const request = fetch('/api/todos')
    .then(res => res.json())
    .catch(simpleErrorWrapper)

(async () => {
  const res = await request
  
  if (isError(res)) {
    console.error(res.e)
    return
  }

  console.log(res)
})