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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rxjs-ninja/rxjs-number

v5.1.4

Published

Operators for handling RxJS Observable of numbers

Downloads

11

Readme

RxJS Ninja - Numbers

The RXJS Ninja Logo

rxjs-number

Website | API Documentation | Changelog

@rxjs-ninja/rxjs-number provides operators for querying, filtering and modifying number values, and Observable for generating number emitters.

Function and Operator categories

Create

Functions and Operators for creating Observable number values

// Generate a number stream, take `6`, add `1` return the modulus `3` value
fromNumber().pipe(take(6), add(1), mod(3)).subscribe();
// Output: `1, 2, 0, 1, 2, 0`

Distribution

Operators for handling the distribution of numbers, these will return a single value from an Iterable of numbers

const source$ = from([
  [1, 2, 3],
  [10, 15, 8],
  [5, 10, 100],
]);

// Get the Mean
source$.pipe(mean()).subscribe();
// Output: `2, 11, 38.333`

// Get the Median
source$.pipe(median()).subscribe();
// Output: `2, 15, 100`

// Get the Minimum Number
source$.pipe(min()).subscribe();
// Output: `1, 8, 5`

// Get the Minimum Number
source$.pipe(max()).subscribe();
// Output: `3, 15, 100`

Filter

Operators for filtering Observable number sources for truthy queries

const source$ = from([1.4, 5, 8.2, 10, 12, 19, 11, 7.6, 14]);

// Gets numbers only in the range of `2` to `11`
source$.pipe(filterInRange(2, 11)).subscribe();
// Output: `5, 8.2, 10, 12, 11, 7.6`

// Gets numbers only in the range of `2` to `11`
source$.pipe(filterOutOfRange(2, 11)).subscribe();
// Output: `1.4, 19, 14`

// Get only floating numbers
source$.pipe(filterIsFloat()).subscribe();
// Output: `1.4, 8.2, 7.6`

Formatting

Operators for formatting numbers to strings

const floatSource$ = from([1.9875, 5.67, 8.1, 97.344]);

// Get a fixed length string
floatSource$.pipe(toFixed(2)).subscribe();
// Output: `'1.99', '5.67', '8.10', '97.34'`

// Format value to local currency
floatSource$.pipe(toLocaleString('en-GB', { currency: 'EUR', style: 'currency' })).subscribe();
// Output: `'€1.99', '€5.67', '€8.10', '€97.34'`

Math

Operators for some math operations such as add, subtract, multiply and raise by power

const source$ = from([1, 2, 3, 4, 5]);

// Add `5` to the source value
$source.pipe(add(5)).subscribe();
// Output: `6, 7, 8, 9, 10`

// Add `5` to the source value
$source.pipe(mul(2)).subscribe();
// Output: `2, 4, 6, 8, 10`

// Return the remainder for modulus 2
$source.pipe(mod(2)).subscribe();
// Output: `1, 0, 1, 0, 1`

Parsing

Operators for parsing strings to numbers

const floatSource$ = from(['1.9875', '5.67', '8.1', '97.344', 'Ninja']);

// Parse string values as float
floatSource$.pipe(parseFloat()).subscribe();
// Output: `1.9875, 5.67, 8.1, 97.344, NaN`

// Parse string values as integer
floatSource$.pipe(parseInt()).subscribe();
// Output: `1, 5, 8, 97, NaN`

Query

Operators for querying number sources for boolean checks

const source$ = from([1.4, 5, 8.2, NaN, 12, 19, 11, NaN, 14]);

// Check if number is in range of `2` to `11`
source$.pipe(inRange(2, 11)).subscribe();
// Output: `false, true, true, false, false, false, true, false, false`

// Check if values are not NaN values
source.pipe(isNotNaN()).subscribe();
// Output: `true, true, true, false, true, true, true, false, true`