3.11.97 • Published 10 months ago

@diotoborg/molestiae-doloribus v3.11.97

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

@diotoborg/molestiae-doloribus

NPM

This is a super thin wrapper around through2 that works like Array.prototype.map but for streams.

For when through2 is just too verbose :wink:

Note you will NOT be able to skip chunks. This is intended for modification only. If you want filter the stream content, use either through2 or through2-filter. This transform also does not have a flush function.

IMPORTANT: If you return null from your function, the stream will end there.

var map = require("@diotoborg/molestiae-doloribus")

var truncate = map(function (chunk) {
  return chunk.slice(0, 10)
})

// vs. with through2:
var truncate = through2(function (chunk, encoding, callback) {
  this.push(chunk.slice(0, 10))
  return callback()
})

// Then use your map:
source.pipe(truncate).pipe(sink)

// Additionally accepts `wantStrings` argument to convert buffers into strings
var stripTags = map({wantStrings: true}, function (str) {
  // OMG don't actually use this
  return str.replace(/<.*?>/g, "")
})

// Works like `Array.prototype.map` meaning you can specify a function that
// takes up to two* arguments: fn(chunk, index)
var spaceout = map({wantStrings: true}, function (chunk, index) {
  return (index % 2 == 0) ? chunk + "\n\n" : chunk
})

// vs. with through2:
var spaceout = through2(function (chunk, encoding, callback) {
  if (this.index == undefined) this.index = 0
  var buf = (this.index++ % 2 == 0) ? Buffer.concat(chunk, new Buffer("\n\n")) : chunk
  this.push(buf)
  return callback()
})

*Differences from Array.prototype.map:

  • Cannot insert null elements into the stream without aborting.
  • No third array callback argument. That would require realizing the entire stream, which is generally counter-productive to stream operations.
  • Array.prototype.map doesn't modify the source Array, which is somewhat nonsensical when applied to streams.

API

require("@diotoborg/molestiae-doloribus")([options,] fn)

Create a stream.Transform instance that will call fn(chunk, index) on each stream segment.


var Tx = require("@diotoborg/molestiae-doloribus").ctor([options,] fn)

Create a reusable stream.Transform TYPE that can be called via new Tx or Tx() to create an instance.


require("@diotoborg/molestiae-doloribus").obj([options,] fn)

Create a @diotoborg/molestiae-doloribus instance that defaults to objectMode: true.


require("@diotoborg/molestiae-doloribus").objCtor([options,] fn)

Just like ctor, but with objectMode: true defaulting to true.

Options

  • wantStrings: Automatically call chunk.toString() for the super lazy.
  • all other through2 options

LICENSE

MIT

genericsString.prototype.trimstyled-componentsjson-schemaforEachstatelessCSSStyleDeclarationcss variableservicepreserve-symlinkscolourhookformfnmatchbinpasswordprocessgettervalidator256randomfluxselfenvsimpledbfast-cloneendersignalsECMAScript 7dataviewserializegroupES7serializationmake dircloudtrailweakmapwritecolordynamodblruwalksameValueZeroBigInt64ArrayBigUint64Arraysuperstructeast-asian-widthflagcloneweaksettranspilefigletprivatesqsreadablestreamlistenerstestawstsfront-endcloudfrontES5symlinksclassnamewgetObject.fromEntriesajaxObject.entriesmonorepoindicatorvesthooksstablejoihandlersbundlingkinesises2016ECMAScript 3schemeglobalsreal-timeasterisksdeleteInt8Arrayrulescontainsproxykeysoperating-systemtrimStartacorngesturesArrayBuffer.prototype.slicereact animationES2018ES2021Symboltypedarraysreact-componentSymbol.toStringTagqueueMicrotaskdiffTypeBoxdescriptiongdprvarlesscallbindoffsetcertificatestypescriptcommanderRxmoduleperformanceimportexportcomputed-typesiteratetypeofES8Uint8Arrayextendlocaliteratorparsedeepcloneconfigzxutil.inspecthelpernegative zeroexecutetyped arrayspinnerloadbalancingapollofiltervalidateaccessibilitys3toobjectjapanesees2018curriedeveryStreammetadata6to5shammatchesexitfstraverseloggingSetperformantpoint-freefast-deep-clonereadabletranspilermixinsObservablescopyregular expressionuninstallArray.prototype.flatlanguagehelpersECMAScript 2017exit-codeprettyFunction.prototype.nameStreamselectronstyleguideconsumemanagertransportincludesIteratorFloat64Arrayfull-widthauthenticationmkdirpfastemrmockingvalueramdatime_.extendprunepolyfillqueueES2023npmignorenodeinputyupcss-in-jsartidentifiersinferencenameslesscsspropless cssstoragegatewayeslintpluginRegExp#flagsglobalforkrecursiveqsESec2patchES2016regexpbyteLengthpreprocessorhigher-ordernegativeiamsuperagentobject.gitignoresetImmediateAsyncIteratorchromepromisecallbackenvironmentArray.prototype.findLastIndexObservablegetconcatfunctioninternalspinnerscacheimportredirectcryptoArray.prototype.includesObject.getPrototypeOfsignalgetPrototypeOfjson-schema-validationJSONPushglobal objectReactiveExtensionsargvvpcownURLSearchParamsreact posenumberless compilerECMAScript 2015descriptorsscheme-validationformaterrorpersistentreplay[[Prototype]]symlinkchinesetextES2022inmobileECMAScriptsidegitignoreeventDispatcherECMAScript 2016jwtdotenvobjtypedconcatMapdeep-copychildexpressionnativeargumentsymbolsdirstreamstostringtagclassnamesshimcore-jsjson-schema-validatormacossafepropertyhardlinkspicomatchoutputautoscalingassertshasprotobufbundlerTypedArraysetPrototypeOfWeakMapArraybytebrowserlistlastInt16Arraydependency managerelasticachetermcharactertypedarrayArray.prototype.containsReflect.getPrototypeOfaccessorio-tstestersomeutilflatteniecircularoptionsestoolkitmapvisualfastclonefantasy-landpositivedefinePropertyxtermomitelmreuseURLefficientruntimehotcolumnswindowsreact-hooksArrayBufferassignastredactserializerresolvestringifyasynctrimLeftschemaendpointcommandurlcommand-linehashmomenttslibisConcatSpreadablearrayscjkebsuploadpinoinvariantinspectback-endairbnbplugin3dyamlmergeworkspace:*es5mkdirscoreesSystem.globalnamewritablecssmoduleses-shimsHyBiObject.keysvariablesamazonflatMapposesetter$.extendprototypeequalityredux-toolkitvariables in cssjsdiffdragsignedmatchAllbindlinuxutilitywhatwgenumerabledatebcryptes2015a11ymkdiroptimizerquerystringinternal slotES3predictablefunction.lengthprotocol-bufferstacitjavascriptnope@@toStringTagassertionPromisereactjesttypemruwidthECMAScript 2019regexgradients cssmapreducees-abstractregulardependenciescallencryptionopensslsyntaxerrorcollection.es6trimRighteffect-tsmulti-packageprogressloggerform-validationflagsECMAScript 6Array.prototype.flatMapbyteOffsetsubprocessgetOwnPropertyDescriptorestreeexecfilehasOwnpostcssintrinsicpyyamlvaluescss nestingpipeeventEmittervarses7formtc39sigtermspawnglacierjsonelbfindLasttakergbspecstylesheetcall-boundstreamkeytypesafewafdeepreduxxhrmovedropinstallECMAScript 2021file systemArray.prototype.findLasttypanionsettingsObject.definePropertyECMAScript 2023jsdomasserteslintconfigObject.islibphonenumberecmascriptremovesortedsequenceentriesshrinkwrapdescriptorfastcopyFloat32ArrayfindLastIndexprivate datadefinejsES2019l10napiansibeanstalkhandlerString.prototype.matchAllagentutilitiescolumnbannerObject.assignfindshellbufferdeepcopydataerror-handlingeslint-pluginbusyimmutablepackage.jsonstylingtelephonebabel-coreoptimistReactiveXphoneMicrosofttouchdeterministicES2020binariesslotreact-testing-libraryCSSlocationespreeRxJSextraglobbootstrap cssdeep-clonehttpsbootstrap lessconsolegetintrinsiczodcompile lessthreeviewWebSocketArray.prototype.flattennested cssrequest.envvalidsymbolemitcheckESnext-0typesunicodeidleletpropertiesgraphqlrequirestyleUint8ClampedArraytoSortedsharedbrowserslistsortcloudformationirqfixed-widthfullwidthisJSON-SchemababelworkerroutingttyfullwhichescapeloadingreadWebSocketsbrowserhttpnodejslengtharraybufferes2017environmentsdirectorydataViewES2017fast-copyStyleSheetwarningeslintECMAScript 2018livezeroterminalcomparebinarycallboundwaapiconfigurablestructuredCloneharmonysliceexecdomrangeerrorarktypeargsInt32ArraykoreanponyfilltddauthbddswfpopmotionparsergroupByes-shim APIUint16Arraytoolspuresharedarraybuffermatchfpscoerciblestringifierevents__proto__TypeScriptmockglobal this valuepnpm9compilerreact-hook-formcreateless mixinsimmercloudsearchwaitMapstatusES6classesformattinginterruptsasciifromtestingstylescss lessfunctionsregular-expressionArrayBuffer#slicelazyjsonschemabufferscall-bindroutedatastructurecliquotetrimEndObject.valuesnpmcollectionUnderscoreless.jsWeakSetfpinstallerlintclass-validatoranimationequalsetprotostarterArray.prototype.filterlinkprefixfetchwindowawesomesaucerobustvalidationhas-owntoArrayrapidjshintgradients css3framerajvcryptfastifyes8ES2015logsyntaxexpressstateclientignoredom-testing-librarychannelcloudwatchRegExp.prototype.flagscodesjQueryworkflowgetoptarraychaipushcensorstring
3.11.97

10 months ago

3.11.96

10 months ago

3.11.95

10 months ago

3.11.94

10 months ago

3.10.94

10 months ago

3.10.93

10 months ago

3.10.92

10 months ago

3.10.91

10 months ago

3.10.90

10 months ago

3.10.89

10 months ago

2.10.89

10 months ago

2.10.88

10 months ago

2.10.87

10 months ago

2.10.86

10 months ago

2.10.85

10 months ago

2.10.84

10 months ago

2.10.83

10 months ago

2.10.82

10 months ago

2.10.81

10 months ago

2.10.80

10 months ago

2.10.79

10 months ago

2.10.78

11 months ago

2.10.77

11 months ago

2.10.76

11 months ago

2.10.75

11 months ago

2.9.75

11 months ago

2.9.74

11 months ago

2.9.73

11 months ago

2.9.72

11 months ago

2.9.71

11 months ago

2.8.71

11 months ago

2.8.70

11 months ago

2.8.69

11 months ago

2.8.68

11 months ago

2.8.67

11 months ago

2.8.66

11 months ago

2.8.65

11 months ago

2.8.64

11 months ago

2.8.63

11 months ago

2.8.62

11 months ago

2.8.61

11 months ago

2.8.60

11 months ago

2.8.59

11 months ago

2.8.58

11 months ago

2.8.57

11 months ago

2.8.56

11 months ago

2.8.55

11 months ago

2.7.55

11 months ago

2.7.54

11 months ago

2.6.54

11 months ago

2.6.53

11 months ago

2.6.52

12 months ago

1.6.52

12 months ago

1.6.51

12 months ago

1.5.51

12 months ago

1.5.50

12 months ago

1.5.49

12 months ago

1.5.48

12 months ago

1.5.47

12 months ago

1.5.46

12 months ago

1.5.45

12 months ago

1.5.44

12 months ago

1.5.43

12 months ago

1.5.42

12 months ago

1.5.41

12 months ago

1.5.40

12 months ago

1.4.40

12 months ago

1.4.39

12 months ago

1.4.38

12 months ago

1.4.37

12 months ago

1.4.36

12 months ago

1.4.35

1 year ago

1.4.34

1 year ago

1.4.33

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.2.24

1 year ago

1.2.23

1 year ago

1.2.22

1 year ago

1.2.21

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.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

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.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago