# timestream-filters

> Filters for sequential objectMode streams (e.g. timeseries data)

Latest version **0.2.4** (published 2015-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install timestream-filters
pnpm add timestream-filters
yarn add timestream-filters
bun add timestream-filters
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2015-08-19 |
| First published | 2013-09-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Bryce B. Baril |
| Maintainers | bryce |
| Keywords | stream, timestream, timeseries, filter, range, limit |

## Links

- npm: https://www.npmjs.com/package/timestream-filters
- Repository: git@github.com:brycebaril/timestream-filters
- Homepage: https://github.com/brycebaril/timestream-filters
- Issues: https://github.com/brycebaril/timestream-filters/issues
- npm.io page: https://npm.io/package/timestream-filters

## Dependencies (2)

- [through2](https://npm.io/package/through2.md) ~2.0.0
- [through2-filter](https://npm.io/package/through2-filter.md) ~2.0.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.2.4 (latest) — 2015-08-19
- 0.2.3 — 2014-01-31
- 0.2.2 — 2013-09-26
- 0.2.1 — 2013-09-20
- 0.2.0 — 2013-09-11
- 0.1.1 — 2013-09-08
- 0.1.0 — 2013-09-08

## README

timestream-filters
=====

[![NPM](https://nodei.co/npm/timestream-filters.png)](https://nodei.co/npm/timestream-filters/)


Filter functions for sequential objectMode data, e.g. timeseries data.

```javascript
var spigot = require("stream-spigot")
var concat = require("concat-stream")

var filters = require("timestream-filters")

function stream() {
  return spigot({objectMode: true}, [
    {v: 50, foo: 150},
    {v: 100, foo: 1100},
    {v: 150, foo: 1150},
    {v: 250, foo: 1250},
    {v: 500, foo: 1500},
    {v: 550, foo: 1550},
  ])
}

stream().pipe(filters.range("v", 120, 500)).pipe(concat(console.log))

/*
[ { v: 150, foo: 1150 },
  { v: 250, foo: 1250 },
  { v: 500, foo: 1500 } ]
 */

stream().pipe(filters.rtrim(3)).pipe(concat(console.log))

/*
[ { v: 250, foo: 1250 },
  { v: 500, foo: 1500 },
  { v: 550, foo: 1550 } ]
 */

stream().pipe(filters.ltrim(3)).pipe(concat(console.log))

/*
[ { v: 50, foo: 150 },
  { v: 100, foo: 1100 },
  { v: 150, foo: 1150 } ]
 */

function fifties(record) {
  return ((record.foo / 50) % 2) == 0
}

stream().pipe(filters.filter(fifties)).pipe(concat(console.log))

/*
[ { v: 100, foo: 1100 },
  { v: 500, foo: 1500 } ]
 */


```

API
===

`timestream-filters` provides four filtering transforms for ordered objectMode streams.

  * range
  * rtrim
  * ltrim
  * scrub
  * filter

`range(seqKey, start, end)`
---

Only forward records where the sequence key `seqKey` is between `start` and `end` *inclusively* to downstream.

`rtrim(n)`
---

Trim the stream to `n` records from the right, e.g. the latest `n` records.

`ltrim(n)`
---

Trim the stream to `n` records from the left, e.g. the first `n` records.

`scrub()`
---

Remove any records that are "empty", that is they have no data beyond the timestamp.

`filter(fn)`
---

Generically filter the stream. Provide a function `fn(record)` that returns true to keep the record for false to discard it.

LICENSE
=======

MIT

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