# pull-with-latest

> Combine a stream with the latest value from another stream

Latest version **3.0.1** (published 2017-10-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install pull-with-latest
pnpm add pull-with-latest
yarn add pull-with-latest
bun add pull-with-latest
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2017-10-05 |
| First published | 2017-04-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | nichoth |
| Maintainers | nichoth |
| Keywords | pull-stream, pull, stream, combine, latest |

## Links

- npm: https://www.npmjs.com/package/pull-with-latest
- Repository: https://github.com/nichoth/pull-with-latest
- Homepage: https://github.com/nichoth/pull-with-latest#readme
- Issues: https://github.com/nichoth/pull-with-latest/issues
- npm.io page: https://npm.io/package/pull-with-latest

## Dependencies (2)

- [pull-stream](https://npm.io/package/pull-stream.md) ^3.5.0
- [pull-abortable](https://npm.io/package/pull-abortable.md) ^4.1.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

- 3.0.1 (latest) — 2017-10-05
- 3.0.0 — 2017-10-05
- 2.0.4 — 2017-04-11
- 2.0.3 — 2017-04-11
- 2.0.2 — 2017-04-11
- 2.0.1 — 2017-04-11
- 1.0.0 — 2017-04-05

## README

# pull with latest

Take two streams, and return a new stream that emits every value from the first stream with the most recent value from the other stream.

## install 

    npm install pull-with-latest

## example

```js
var test = require('tape')
var withLatest = require('../')
var S = require('pull-stream')

test('pass null for the default predicate', function (t) {
    t.plan(2)
    var predicate = null

    S(
        withLatest.apply(null, [predicate].concat(sources())),
        S.collect(function (err, res) {
            t.error(err)
            t.deepEqual(res, [
                [2, 'a'],
                [4, 'b'],
                [6, 'c']
            ], 'should combine the streams ok')
        })
    )
})

test('use predicate function', function (t) {
    t.plan(2)
    var predicate = function (a, b) {
        return { a: a, b: b }
    }

    S(
        withLatest.apply(null, [predicate].concat(sources())),
        S.collect(function (err, res) {
            t.error(err)
            t.deepEqual(res, [
                { a:2, b:'a' },
                { a:4, b:'b' },
                { a:6, b:'c' }
            ], 'should combine the streams ok')
        })
    )
})


function sources () {
    var sampler = S(
        S.values(['a','b','c']),
        S.asyncMap(function (ev, cb) {
            setTimeout(function () {
                cb(null, ev)
            }, 210)
        })
    )

    var otherStream = S(
        S.values([1,2,3,4,5,6]),
        S.asyncMap(function (ev, cb) {
            setTimeout(function () {
                cb(null, ev)
            }, 100)
        })
    )

    return [otherStream, sampler]
}
```

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