# @rxjs-ninja/rxjs-number

> Operators for handling RxJS Observable of numbers

Latest version **5.1.4** (published 2022-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rxjs-ninja/rxjs-number
pnpm add @rxjs-ninja/rxjs-number
yarn add @rxjs-ninja/rxjs-number
bun add @rxjs-ninja/rxjs-number
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.1.4 |
| Published | 2022-11-18 |
| First published | 2020-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 133.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 76 |
| Author | Tane Piper |
| Maintainers | tanepiper |
| Keywords | Rx, RxJS, ReactiveX, ReactiveExtensions, Streams, Observables, Observable, Stream, ES6, ES2015, Typescript, Reactive, Utility, Number, Numbers |

## Links

- npm: https://www.npmjs.com/package/@rxjs-ninja/rxjs-number
- Repository: https://github.com/rxjs-ninja/rxjs-ninja
- Homepage: https://rxjs-ninja.tane.dev
- Issues: https://github.com/rxjs-ninja/rxjs-ninja/issues
- npm.io page: https://npm.io/package/@rxjs-ninja/rxjs-number

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 5.1.4 (latest) — 2022-11-18
- 5.1.3 — 2021-02-02
- 5.1.2 — 2021-01-25
- 5.1.1 — 2021-01-25
- 5.1.0 — 2021-01-25
- 5.0.1 — 2021-01-21
- 5.0.0 — 2021-01-20
- 4.3.0 — 2021-01-19
- 4.2.0 — 2021-01-17
- 4.1.0 — 2021-01-03
- 4.0.0 — 2020-12-21
- 3.1.2 — 2020-11-22
- 3.1.1 — 2020-11-22

## README

# RxJS Ninja - Numbers

![The RXJS Ninja Logo](https://raw.githubusercontent.com/rxjs-ninja/rxjs-ninja/main/assets/logo.png)

[![rxjs-number](https://img.shields.io/npm/v/@rxjs-ninja/rxjs-number?label=@rxjs-ninja/rxjs-number)](https://www.npmjs.com/package/@rxjs-ninja/rxjs-number)

[Website](http://rxjs.ninja)
|
[API Documentation](https://rxjs-ninja.tane.dev/modules/number.html)
|
[Changelog](https://github.com/rxjs-ninja/rxjs-ninja/blob/main/libs/rxjs/number/CHANGELOG.md)

`@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

```ts
// 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

```ts
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

```ts
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

```ts
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

```ts
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

```ts
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

```ts
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`
```

---
_Source: https://npm.io/package/@rxjs-ninja/rxjs-number · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
