1.0.5 • Published 5 years ago

minipass-flush v1.0.5

Weekly downloads
7,656,413
License
ISC
Repository
github
Last release
5 years ago

minipass-flush

A Minipass stream that calls a flush function before emitting 'end'

USAGE

const Flush = require('minipass-flush')
cons f = new Flush({
  flush (cb) {
    // call the cb when done, or return a promise
    // the 'end' event will wait for it, along with
    // close, finish, and prefinish.
    // call the cb with an error, or return a rejecting
    // promise to emit 'error' instead of doing the 'end'
    return rerouteAllEncryptions().then(() => clearAllChannels())
  },
  // all other minipass options accepted as well
})

someDataSource.pipe(f).on('end', () => {
  // proper flushing has been accomplished
})

// Or as a subclass implementing a 'flush' method:
class MyFlush extends Flush {
  flush (cb) {
    // old fashioned callback style!
    rerouteAllEncryptions(er => {
      if (er)
        return cb(er)
      clearAllChannels(er => {
        if (er)
          cb(er)
        cb()
      })
    })
  }
}

That's about it.

If your flush method doesn't have to do anything asynchronous, then it's better to call the callback right away in this tick, rather than returning Promise.resolve(), so that the end event can happen as soon as possible.

cacachemake-fetch-happenvuedragdropuploadimagesbb-chat@texttree/demo-bsa-reference-rcl@fundefund/funde_ck@saeon/ol-react@saeon/quick-formcogoportutils@mink-opn/build-tokens@infinitebrahmanuniverse/nolb-minip@saaspe/componentsexpand-react-bridgenode-gio@everything-registry/sub-chunk-2175jawwy-sdkreact-native-sphereuisphereuijeuxuijesusdemolabtesttwonuxtpaginationsnpm-all-packagesmynanceparvan_componentsparvan_reactjs_componentspatepangdeuing-search-dropdownpileuleuyantealuojia-cli-devmangudinlagirajinmd-vditormiracle-webpack-tree-shakingneural_compressor_ext_lab_customizedneural_compressor_ext_lab_customized_2quicknexpyreswap-sdktehmusimhujantest-iki-mini-apptldrawligninstyletoolssvelte-component-libsushi-sdk-ftmsupercluster-googlemaps-adapter-clonestestujsk_custom_ckeditor5u-libraryreact-native-fedlight-dsmreact-native-dimensions-layoutreact-picky-with-clearselect2-selectallsequelcomponentsedanbosokstock-ticker-react-widgetreact-form-component-libraryreact-native-rtn-ips-poslin-testreact-native-awesome-module-latestreact-native-nativewindreact-native-lib-test-rn-1react-native-module-argereact-native-rn-appreact-native-sandycomponentreact-native-recent-framework-updatereact-native-multiplyrefinejs-repoud7-act2zzzxxxyyy321123web-elements-iconswow.js-juziwinx-form-winxagent-get-agentained-ckeditor5@sackmanson/quill-image-uploader@samwinslow/edgedb@fabwcie/ckeditor5-preview@saeon/logger@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdown@faizanhaider/iconsax@zebracompany/f_editor@vitali_shcherbina/styled-lib@taymoon/ckeditor5-custom-buildanakketigaanaklanangteaanakwadontea@blkmarketco/components-library@openpolitica/matomo-next@parallelnft/web3modal@shivarajapple/first-library@skeetboothppq/component-library@podlubnaja/ui-kitdesign-system-fitbank-450@positionex/position-sdk@farvater/open-pedigree@saqib1987/quiz_test@tomw2w/my-nuxt-layer@lego-js/tests@marinaga/bananize@plogg/three@opn-ooo/eslint-config-opn@oriduk/ckeditor5-rebuild-musicanote@oriduk/ckeditor5-rebuild-oriduk
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago