3.0.30 • Published 6 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
6 years ago
3.0.29
6 years ago
3.0.28
6 years ago
3.0.27
7 years ago
3.0.26
7 years ago
3.0.25
7 years ago
3.0.24
7 years ago
3.0.23
7 years ago
3.0.22
7 years ago
3.0.21
7 years ago
3.0.20
7 years ago
3.0.19
7 years ago
3.0.18
7 years ago
3.0.17
7 years ago
3.0.16
7 years ago
3.0.15
7 years ago
3.0.14
7 years ago
3.0.13
7 years ago
3.0.12
7 years ago
3.0.11
7 years ago
3.0.10
7 years ago
3.0.9
7 years ago
3.0.8
7 years ago
3.0.7
7 years ago
3.0.6
7 years ago
3.0.5
7 years ago
3.0.4
7 years ago
3.0.3
7 years ago
3.0.2
7 years ago
3.0.1
7 years ago
3.0.0
7 years ago
2.1.4
7 years ago
2.1.3
7 years ago
2.1.2
7 years ago
2.1.1
7 years ago
2.1.0
7 years ago
2.0.0
7 years ago
1.1.1
7 years ago
1.1.0
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago