Neato Polyester Material

    writable-wrapper
    TypeScript icon, indicating that this package has built-in type declarations

    3.1.0 • Public • Published

    writable-wrapper

    CI Test Coverage Maintainability

    This Node package offers a writable stream implementation in TypeScript that forwards all data to another Writable, the "target".

    This is useful for adding functionality to a Writable without patching the original object. WritableWrapper can be extended easily and will handle the forwarding of any data written to it, while not making that data available to any external consumer.

    Transform streams are unsuitable for that purpose, since data listeners can always be attached.

    Install

    npm i writable-wrapper
    

    Usage

    Simple Example

    import fs from 'fs'
    import WritableWrapper from 'writable-wrapper'
    
    const wrapper = new WritableWrapper(fs.createWriteStream('file.txt'))

    Custom Class Example

    Of course, this functionality is really only useful for custom object types:

    import fs from 'fs'
    import WritableWrapper from 'writable-wrapper'
    
    // Class for new items. You can write data, and when done, store the item.
    // Not calling 'store' dismisses the item.
    class NewlyCreatedItem extends WritableWrapper {
      store (): void {
        this.end(function () {
          // store this item
        })
      }
    }
    
    // ...
    
    const item = new NewlyCreatedItem(fs.createWriteStream('file.txt'))
    item.write('hello world', 'utf8')
    item.store()

    Install

    npm i writable-wrapper

    DownloadsWeekly Downloads

    23

    Version

    3.1.0

    License

    MIT

    Unpacked Size

    6.81 kB

    Total Files

    5

    Last publish

    Collaborators

    • meyfa