3.5.87 • Published 10 months ago

@taktikorg/natus-enim-non v3.5.87

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@taktikorg/natus-enim-non

Turn a writeable and readable stream into a single streams2 duplex stream.

Similar to duplexer2 except it supports both streams2 and streams1 as input and it allows you to set the readable and writable part asynchronously using setReadable(stream) and setWritable(stream)

npm install @taktikorg/natus-enim-non

build status

Usage

Use @taktikorg/natus-enim-non(writable, readable, streamOptions) (or @taktikorg/natus-enim-non.obj(writable, readable) to create an object stream)

var @taktikorg/natus-enim-non = require('@taktikorg/natus-enim-non')

// turn writableStream and readableStream into a single duplex stream
var dup = @taktikorg/natus-enim-non(writableStream, readableStream)

dup.write('hello world') // will write to writableStream
dup.on('data', function(data) {
  // will read from readableStream
})

You can also set the readable and writable parts asynchronously

var dup = @taktikorg/natus-enim-non()

dup.write('hello world') // write will buffer until the writable
                         // part has been set

// wait a bit ...
dup.setReadable(readableStream)

// maybe wait some more?
dup.setWritable(writableStream)

If you call setReadable or setWritable multiple times it will unregister the previous readable/writable stream. To disable the readable or writable part call setReadable or setWritable with null.

If the readable or writable streams emits an error or close it will destroy both streams and bubble up the event. You can also explicitly destroy the streams by calling dup.destroy(). The destroy method optionally takes an error object as argument, in which case the error is emitted as part of the error event.

dup.on('error', function(err) {
  console.log('readable or writable emitted an error - close will follow')
})

dup.on('close', function() {
  console.log('the duplex stream is destroyed')
})

dup.destroy() // calls destroy on the readable and writable part (if present)

HTTP request example

Turn a node core http request into a duplex stream is as easy as

var @taktikorg/natus-enim-non = require('@taktikorg/natus-enim-non')
var http = require('http')

var request = function(opts) {
  var req = http.request(opts)
  var dup = @taktikorg/natus-enim-non(req)
  req.on('response', function(res) {
    dup.setReadable(res)
  })
  return dup
}

var req = request({
  method: 'GET',
  host: 'www.google.com',
  port: 80
})

req.end()
req.pipe(process.stdout)

License

MIT

Related

@taktikorg/natus-enim-non is part of the mississippi stream utility collection which includes more useful stream modules similar to this one.

removelivelistenersnumberdeepcopydom-testing-libraryshrinkwrapgetOwnPropertyDescriptorspinnersfile systemagentObject.valuesStreamefficientsideproxyaccessibilityutilitiesObject.assignomitcss-in-jsglobalfast-deep-cloneES2021maps3awesomesaucecompareairbnbarrayReflect.getPrototypeOfprototypereverseworkspace:*escorecloudformationtakesyntaxeslintconfigec2bannerviewwritebyteLengthRFC-6455clonephonerfc9562pyyaml3dfullwidthcolumnkeysebstc39childes2017deep-copyopenssldescriptionindicatortermcss lessfullreal-timeprotovalidationmkdirsserializerpropertiesserializeendpointless cssiterateprivate datacreatemrueventsreact poseTypedArraycomputed-typessimpledbbinaries6to5bundlerperformanceintrinsicflattenreact-hook-formgesturesvisualcirculares6-0protocol-buffersrobustfixed-widthFloat64ArraycallbackurlquerystringfilterargsminimalworkerHyBitrimRightenvironmentharmonycompile lesssubprocessglobalThisObservableecmascripttypeofstoragegatewaytimeCSSStyleDeclarationmatchAllarraybuffernested cssforkchaitacitiemake dirsetPrototypeOffigletbyteOffsetschemaiteratorpredictablefindLasttrimStartkeysuperstructtddbytestatelessStyleSheetECMAScript 6colorutilfunctionaldiroptimistlocaltransportartcss variabledeletesignalsstatusinterruptsshebangJSONarktypelessexecsettereffect-tshelpertrimEndwalkobjectconcatsignedtsvpcfull-widthstringchineseformnodejsstylesheetcolorsmomentutil.inspectprotobufeslintpackage managerargumentBigUint64ArraythreeECMAScript 2021offsetconsttoStringTagreduxcopyfastcopycurriedcolourpopmotioncollection.es6touchdescriptoreventEmittermonorepoECMAScript 7Int32Arrayprefixmanagerspeedirqclientloadbalancingfast-cloneUint8ArrayECMAScript 2017springES8consumebusystreamsregular expressionbundlingcloudwatchzodgenericsfastclonelesscssdirectoryserializationclassnamesttyvarTypeBoxglobal this valuereplaybufferreact-componentimportescapepositiveES2016hardlinksconcatMapES3regularstructuredClonefunction.lengthinstalltelephonebootstrap cssbinaryESmodulesmacossafeECMAScript 2016eventDispatcherisConcatSpreadablewait_.extendfunctionRxJSUint32ArraygetintrinsicECMAScript 5picomatchtslibstableinstallergraphqlwindowhttpsfunctionszerolasttoReversedtraverseunicodebindArray.prototype.containscsses5east-asian-widthbrowserslistauthqueueMicrotaskInt8ArraypropPushrangeerrorprocessgradients css3redactdataviewdataViewsettingspuresharedarraybuffereslintpluginless mixinsES2020URLSearchParamselasticachecall-bindYAMLgetelectronjavascriptiamshamECMAScript 2023ignoreestreeimmerfilepatchString.prototype.matchAllroute53AsyncIteratorasciistringifierweakmaperror-handlingjson-schema-validationutilitycore-jskinesisvarsform-validationchanneltypedarraysbuffersArrayBuffer#slicecss nestingnopeextendArray.prototype.flattencommand-lineterminalcryptotostringtagperformantownArray.prototype.flatfantasy-landsharedMapsesreact-testing-libraryyuphasflagyamlwhatwgpipeutils256progressstylingmatchFunction.prototype.nametoArrayString.prototype.trimhttpbcryptnegative zeroassignpackagesruntimerandomclass-validatordescriptorspreprocessorajaxsnsxhrnegativepromisewarningcall-boundhelpersreversedpnpm9ES7importexporti18ncjkassertoptimizerES2019scheme-validationreadablereact-hookssigtermelmpostcss-plugines8fpsdomObject.definePropertynamesargvObject.keysgetterstreamzxes2018transpilemkdirfast-copyequalcharacterequalityvalidatestateslothotdropjsxSymbol.toStringTagrequireArrayreadablestreamtoobjectArrayBufferdeepclonebrowserECMAScript 2015ES2017hashcloudsearchexecfileformscallbindposecryptObject.getPrototypeOflogtestingstyleguidesuperagentspinnerjsdiffmkdirpsequencefetchjapanesejshintsymbolenvironmentsenvpathfastifyStreamsECMAScript 2018containswidthvalidatorflagsSystem.globales-abstractentriesexpresstoSortedanimationslicewhichroutingReactiveExtensionsWebSocketarraysdragdefinePropertyidletoolkittypesafeenderjson-schema-validatorECMAScript 3reuseWebSocketsjestgetoptbininternalprettywaapihookformcompilerfluxstylejwtworkflowguidisdependenciesinvariantmakeencryptiontypescriptRegExp#flagsjsonschemanativeasyncreducerulesauthenticationES2015fast-deep-copymoduleBigInt64Array.gitignore[[Prototype]]inputtypeerroransieveryobjqueueletwgetchromiumlruroutepolyfillschemepinotypesl10ncolumnshandlersgroupless.jstypedarrayeslint-plugindefinebrowserlistcloudtrailmetadatafpdependency managersigintrapidUint16ArrayUnderscorelibphonenumbersetcommandFloat32ArrayECMAScript 2020shimnpm.envbabel-coredatahasOwnquotenamemovedatejQueryio-tsUint8ClampedArrayreactoperating-systemrecursiveArray.prototype.findLastIndexenumerablextermECMAScript 2022shellvaluepreserve-symlinksspecparseemitapiawscoercibleprunechromeMicrosoftdiffuser-streamssameValueZeroSymbolpushexecutemapreducestylesglobalsboundweaksetRegExp.prototype.flagssymlinksstringifyObservableserrorramdareact animationhas-ownes2016gdprsignalObject.fromEntriespersistentframerrdsregexfastaccessorvalid__proto__ponyfillES6immutablecertificatessortquery0readpasswordclilazyjoigradients csselbReactiveXclassnamespawnuploadconfigflatSetes-shim APIbabelgitignorewindowsflatMapPromisepoint-freetextIterator
3.5.87

10 months ago

3.5.86

10 months ago

3.5.85

10 months ago

3.4.85

10 months ago

3.4.84

10 months ago

3.4.83

10 months ago

3.4.82

10 months ago

3.4.81

11 months ago

3.4.80

11 months ago

3.4.79

11 months ago

3.4.78

11 months ago

3.4.77

11 months ago

3.4.76

11 months ago

2.4.76

11 months ago

2.4.75

11 months ago

2.4.74

11 months ago

1.4.74

11 months ago

1.4.73

11 months ago

1.4.72

11 months ago

1.4.71

11 months ago

1.4.70

11 months ago

1.4.69

11 months ago

1.4.68

11 months ago

1.4.67

11 months ago

1.4.66

11 months ago

1.4.65

11 months ago

1.4.64

11 months ago

1.4.63

11 months ago

1.4.62

11 months ago

1.4.61

11 months ago

1.4.60

11 months ago

1.4.59

11 months ago

1.4.58

11 months ago

1.4.57

11 months ago

1.4.56

11 months ago

1.4.55

11 months ago

1.4.54

11 months ago

1.4.53

12 months ago

1.4.52

12 months ago

1.4.51

12 months ago

1.4.50

12 months ago

1.4.49

12 months ago

1.4.48

12 months ago

1.4.47

12 months ago

1.4.46

12 months ago

1.4.45

12 months ago

1.4.44

12 months ago

1.4.43

12 months ago

1.4.42

12 months ago

1.4.41

12 months ago

1.3.41

12 months ago

1.3.40

12 months ago

1.3.39

12 months ago

1.3.38

12 months ago

1.3.37

12 months ago

1.3.36

12 months ago

1.3.35

12 months ago

1.3.34

1 year ago

1.3.33

1 year ago

1.3.32

1 year ago

1.3.31

1 year ago

1.3.30

1 year ago

1.3.29

1 year ago

1.3.28

1 year ago

1.3.27

1 year ago

1.3.26

1 year ago

1.3.25

1 year ago

1.3.24

1 year ago

1.3.23

1 year ago

1.3.22

1 year ago

1.3.21

1 year ago

1.3.20

1 year ago

1.2.20

1 year ago

1.2.19

1 year ago

1.2.18

1 year ago

1.2.17

1 year ago

1.2.16

1 year ago

1.2.15

1 year ago

1.2.14

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago