# @jameslnewell/observable

> A super simple and light-weight observable implementation.

Latest version **1.5.0** (published 2021-02-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jameslnewell/observable
pnpm add @jameslnewell/observable
yarn add @jameslnewell/observable
bun add @jameslnewell/observable
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2021-02-03 |
| First published | 2019-10-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 36.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | jameslnewell |
| Keywords | observable, observables |

## Links

- npm: https://www.npmjs.com/package/@jameslnewell/observable
- Repository: https://github.com/jameslnewell/observable
- Homepage: https://github.com/jameslnewell/observable#readme
- Issues: https://github.com/jameslnewell/observable/issues
- npm.io page: https://npm.io/package/@jameslnewell/observable

## Recent versions

- 1.5.0 (latest) — 2021-02-03
- 1.4.1 — 2021-02-02
- 1.4.0 — 2021-02-02
- 1.3.0 — 2020-03-26
- 1.2.4 — 2019-10-31
- 1.2.3 — 2019-10-30
- 1.2.2 — 2019-10-30
- 1.2.1 — 2019-10-30
- 1.2.0 — 2019-10-30
- 1.1.0 — 2019-10-23
- 1.0.1 — 2019-10-23
- 1.0.0 — 2019-10-23

## README

# @jameslnewell/observable

![npm (scoped)](https://img.shields.io/npm/v/@jameslnewell/observable.svg)
[![Bundle Size](https://badgen.net/bundlephobia/minzip/@jameslnewell/observable)](https://bundlephobia.com/result?p=@jameslnewell/observable)
[![Actions Status](https://github.com/jameslnewell/observable/workflows/main/badge.svg)](https://github.com/jameslnewell/observable/actions)

A super simple and light-weight observable implementation.

## Installation

```bash
yarn add @jameslnewell/observable
```

## Usage

```js
const {create, map, pipe} from '@jameslnewell/observable';

const numbers = (ms = 1000) => create(subscriber => {
  let count = 0;
  const handle = setInterval(() => subscriber.next(count++), ms);
  return () => clearInterval(handle);
});

const letters = pipe(map(number => String.fromCharCode(65 + number)))(numbers())

const subscription = letters.subscribe({
  next: data => console.log(data),
  error: error => console.error(error),
  completed: () => console.log('completed')
});

subscription.unsubscribe();

```

## API

### fromArray(array)

### fromError(array)

### create(factory): Observable

### map(fn)(observable): Observable

### delay(ms)(observable): Observable

### pipe(fn1, fn2, fn3)(Observable): Observable

### isObservable(value): boolean

### firstValueFrom(observable: Observable<Value>): Promise<Value>

### lastValueFrom(observable: Observable<Value>): Promise<Value>

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