# sosj

> Sorted Object Stream Join -- Joins two sorted objectMode streams based on a provided join key.

Latest version **0.3.0** (published 2014-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install sosj
pnpm add sosj
yarn add sosj
bun add sosj
```

## 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.3.0 |
| Published | 2014-05-23 |
| First published | 2013-09-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Bryce B. Baril |
| Maintainers | bryce |
| Keywords | streams, objectMode, sequence, join |

## Links

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

## Dependencies (2)

- [through2-map](https://npm.io/package/through2-map.md) ~1.2.1
- [readable-stream](https://npm.io/package/readable-stream.md) ~1.1.10

## 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.3.0 (latest) — 2014-05-23
- 0.2.2 — 2014-01-31
- 0.2.1 — 2013-12-16
- 0.2.0 — 2013-12-16
- 0.1.2 — 2013-09-20
- 0.1.1 — 2013-09-05
- 0.1.0 — 2013-09-05

## README

sosj
=====

[![NPM](https://nodei.co/npm/sosj.png)](https://nodei.co/npm/sosj/)

Sequential Object Stream Joiner (SOSJ) -- Provides an `align` function that can be used as a precursor to joining two objectMode streams.

Combines two objectMode streams that are each **ALREADY ORDERED** by a sequence key and emits a new stream which is doublets of records for the two joined streams.

If you wish to use floating points keys, then you must use the optional epsilon param, which follows the classical semantics for float-comparison.

You can then use other `Transform` streams to perform typical Set join operations. Or you can use some that have already been created for you that wrap this library: [stream-joins](http://npm.im/stream-joins)

```javascript
var align = require("sosj")
var spy = require("through2-spy")
var spigot = require("stream-spigot")

var left = spigot({objectMode: true}, [
  {v: 0, foo: 100},
  {v: 1, foo: 200},
  {v: 2, foo: 300},
  {v: 3, foo: 400},
  {v: 4, foo: 500},
])

var right = spigot({objectMode: true}, [
  {v: 0, bar: 100},
  {v: 2, bar: 200},
  {v: 4, bar: 300},
  {v: 8, bar: 400},
])

align("v", left, right).pipe(spy({objectMode: true}, console.log))

/*
[ { v: 0, foo: 100 }, { v: 0, bar: 100 } ]
[ { v: 1, foo: 200 }, null ]
[ { v: 2, foo: 300 }, { v: 2, bar: 200 } ]
[ { v: 3, foo: 400 }, null ]
[ { v: 4, foo: 500 }, { v: 4, bar: 300 } ]
[ null, { v: 8, bar: 400 } ]
 */

```

API
===

`require("sosj")(sequenceKey, leftStream, rightStream, epsilon)`
---

Align the two streams by sequenceKey into doublets of `[left, right]`, `[left, null]`, or `[null, right]` depending on if the records have matching sequenceKey values.
If epsilon param is used, floating-number comparison semantics are triggered, i.e., keys will match if `Math.abs(key_left - key_right) <= epsilon`

LICENSE
=======

MIT

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