stream-async
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

stream async

Build Status Downloads
Version License

do async method by stream code style.

how to use

install in nodejs

npm install stream-async
# or
yarn add stream-async

use

  • simple by class
import { streamAsync } from 'stream-async'
class A {
  foo = 1
  async asyncFun() {
    this.foo += 1
    return this
  }
}
const a = streamAsync(new A())
a.asyncFun().asyncFun()
console.log(a.foo)
// there will output `3`
  • flexible by class
import { streamAsync } from 'stream-async'
class A {
  stream = streamAsync(this)
  foo = 1
  fun () {
    this.foo += 1
    return this
  }
  async asyncFun() {
    this.foo += 1
    return this
  }
  async asyncFun0(x) {
    this.foo += x
    return this
  }
}
const a = new A()
a.stream
  .asyncFun()
  .fun()
  .asyncFun()
  .asyncFun0(10)

console.log(a.foo)
// there will output `14`

/stream-async/

    Package Sidebar

    Install

    npm i stream-async

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    8.05 kB

    Total Files

    7

    Last publish

    Collaborators

    • yijie4188