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

@spider-baby/utils-rxjs

v2.0.0

Published

Utility operators for RxJS Observables, primarily for debugging during development.

Downloads

13

Readme

sb-utils-rxjs

This library was generated with Nx.

This library provides utility operators for RxJS Observables, primarily for debugging purposes during development.

Operators

devLog

A debug operator that logs emitted values from an Observable to the console, but only when the application is running in development mode. This operator behaves like tap() but its logging action is conditional based on isDevMode() from @angular/core.

Parameters:

  • labelOrFormatter (string | (value: T) => string):
    • If a string is provided, it's used as a label prefix for the logged message (e.g., [User Data]).
    • If a function is provided, it receives the emitted value and should return a string to be logged. This allows for custom message formatting.
  • customLogger ((message: string, value: T) => void) (optional):
    • A custom function to handle the logging. Defaults to console.log, which will log the message string and the value itself.

Returns:

  • (source: Observable<T>) => Observable<T>: An RxJS operator function.

Usage Examples:

import { devLog } from '@spider-baby/utils-rxjs'; // Adjust import path as necessary

// Example 1: Using a simple string label
source$.pipe(
  devLog('User Data')
).subscribe();
// In dev mode, might log: "[User Data]" { /* emitted value */ }

// Example 2: Using a formatter function
source$.pipe(
  devLog(data => `Received ${data.items.length} items. First item: ${data.items[0]?.name}`)
).subscribe();
// In dev mode, might log: "Received 5 items. First item: ExampleName" { /* emitted value */ }

// Example 3: Using a custom logger
source$.pipe(
  devLog('API Response', (message, value) => {
    console.group(message);
    console.log('Value:', value);
    console.groupEnd();
  })
).subscribe();

devLogError

A debug operator that logs errors from an Observable to the console, but only when the application is running in development mode. This is useful for tapping into the error channel of an Observable for debugging without adding permanent error handling logic.

Parameters:

  • label (string) (optional):
    • A string label to prefix the error message (e.g., [API Error]). Defaults to [Error] if not provided.

Returns:

  • (source: Observable<T>) => Observable<T>: An RxJS operator function.

Usage Example:

import { devLogError } from '@spider-baby/utils-rxjs'; // Adjust import path as necessary

sourceThatMightError$.pipe(
  devLogError('Data Fetch Operation')
).subscribe({
  next: data => console.log('Data:', data),
  // No error callback needed here for logging in dev mode,
  // but you'd typically have one for production error handling.
});
// In dev mode, if an error occurs, might log: "[Data Fetch Operation]" { /* error object */ }

Running unit tests

Run nx test @spider-baby/utils-rxjs to execute the unit tests via Jest.