3.0.30 • Published 5 years ago
the-stream-base v3.0.30
the-stream-base
Base of the streams
Installation
$ npm install the-stream-base --save
Usage
'use strict'
const { TheStream } = require('the-stream-base')
const fs = require('fs')
const asleep = require('asleep')
async function tryExample () {
class CountupStream extends TheStream {
streamDidOpen () {
this.counts = 0
}
streamWillClose () {
console.log('Counts', this.counts)
}
// Consume values from `stream.push()`
async consume (provided) {
for await (const chunk of provided) {
console.log('pushed', chunk)
this.counts++
}
}
// Provide values for `stream.pull()`
async * provide () {
do {
yield await this.counts--
console.log('pulled', this.counts)
} while (this.counts > 0)
}
}
const stream = new CountupStream({})
await stream.open()
for (let i = 0; i < 100; i++) {
await stream.push(i * Math.random())
}
console.log(
await stream.pull()
)
await stream.close()
}
tryExample().catch((err) => console.error(err))
API Guide
License
This software is released under the MIT License.
Links
3.0.30
5 years ago
3.0.29
5 years ago
3.0.28
5 years ago
3.0.27
5 years ago
3.0.26
5 years ago
3.0.25
6 years ago
3.0.24
6 years ago
3.0.23
6 years ago
3.0.22
6 years ago
3.0.21
6 years ago
3.0.20
6 years ago
3.0.19
6 years ago
3.0.18
6 years ago
3.0.17
6 years ago
3.0.16
6 years ago
3.0.15
6 years ago
3.0.14
6 years ago
3.0.13
6 years ago
3.0.12
6 years ago
3.0.11
6 years ago
3.0.10
6 years ago
3.0.9
6 years ago
3.0.8
6 years ago
3.0.7
6 years ago
3.0.6
6 years ago
3.0.5
6 years ago
3.0.4
6 years ago
3.0.3
6 years ago
3.0.2
6 years ago
3.0.1
6 years ago
3.0.0
6 years ago
2.1.4
6 years ago
2.1.3
6 years ago
2.1.2
6 years ago
2.1.1
6 years ago
2.1.0
6 years ago
2.0.0
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago