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-sphereuisphereuitest-iki-mini-appwinx-form-winxweb-elements-iconswow.js-juzisupercluster-googlemaps-adapter-clonessequelcomponentsedanbosokselect2-selectalltestujsk_custom_ckeditor5svelte-component-libvantiq-reactsushi-sdk-ftm@castrum-nubis/bulmazzzxxxyyy321123miracle-webpack-tree-shakingjesh-calculationjesusdemojeuxuikrown_login_libraryhot-zone-vuehotkey-mapperiiif-manifest-editorgundam5labtesttwogh-monoproject-cligit-branching-workflowmynancemangudinlagirajinmanan-react-native-expo-authorize-netluojia-cli-devmd-vditorparvan_componentsparvan_reactjs_componentsori-bot-react-nativepileuleuyanteang-search-dropdownpatepangdeuireact-form-component-libraryreact-native-dimensions-layoutreact-native-bottom-tab-designsreact-native-escapereact-native-custome-component-demoreact-native-fedlight-dsmreact-native-custom-poccomponentreact-native-custom-poccomponent-nextreact-picky-with-clearnuxtpaginationsneural_compressor_ext_lab_customizedneural_compressor_ext_lab_customized_2rainbowprokovanmailpyreswap-sdkreact-native-lib-test-rn-1react-native-recent-framework-updatereact-native-s-airlinesreact-native-rn-appreact-native-rn-common-components-examplereact-native-rn-tolkaplayerreact-native-rn-tolkaplayer-dharmeshreact-native-sherpa-onnx-offline-ttsreact-native-rtn-ips-poslin-testreact-native-sandycomponentreact-native-multi-bluetooth-printerreact-native-moosa-lib-for-testreact-native-paynow-generatorreact-native-offline-noticereact-native-test-tooltipreact-native-sunmi-printer-hkreact-native-nativewindreact-native-multiplyreact-native-module-argereact-native-adarsh_react_native_video_playerreact-native-avinash_jha_test_pluginreact-native-awesome-module-dharmeshreact-native-awesome-module-latestquicknexrefinejs-repostyletoolsstock-ticker-react-widgettehmusimhujanud7-act2u-librarytldrawlignin
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