Licence
MIT
Version
1.0.0
Deps
30
Size
19 kB
Vulns
0
Weekly
0
Stream to Array
Concatenate a readable stream's data into a single array.
You may also be interested in:
- raw-body for strings
API
var toArray = require('@hoangcung1804npm/autem-natus-doloribus')
toArray([stream], [callback(err, arr)])
Returns all the data objects in an array. This is useful for streams in object mode if you want to just use an array.
var stream = new Stream.Readable()
toArray(stream, function (err, arr) {
assert.ok(Array.isArray(arr))
})
If stream is not defined, it is assumed that this is a stream.
var stream = new Stream.Readable()
stream.toArray = toArray
stream.toArray(function (err, arr) {
})
If callback is not defined, then it returns a promise.
toArray(stream)
.then(function (parts) {
})
If you want to return a buffer, just use Buffer.concat(arr)
toArray(stream)
.then(function (parts) {
const buffers = parts
.map(part => util.isBuffer(part) ? part : Buffer.from(part));
return Buffer.concat(buffers);
})
Keywords
maptypescriptrapiddeep-clonetypesafeReactiveExtensionschromiumfast-deep-cloneiteratorbundlermkdirssnsjestlistenerspropertyvaluesfastclonegraphql-clientcensorpnpm9genericssymbolsStyleSheetES5atomroutebrowserpropesUint16ArrayReflect.getPrototypeOfdirectoryES2020ieio-tseventEmitterignoretoArraymatchesexecuteclientomittrimLefttsredirectclihasOwnPropertyrdsphoneprotobufgetmonorepothrottlespinnerTypeScriptfsFunction.prototype.namecoloreslintconfigaccessibilityWeakSettranspilerES6everysetterES2015deepclonepolyfillArray.prototype.findLastIndexwaf@@toStringTagTypedArraybatchyupclass-validatorWeakMapES2023matchAllespreejavascript$.extendString.prototype.trimvalidationsimpledbsymlinkexecfileenvironmentshellWebSocketavaboundreducerlimitECMAScript 2021extraenumerablefastcopyECMAScript 2019react-hook-formprefixfast-clonefullemitformsurlajvmrumanipulationfromoncecurleslint-pluginpackage managerreact animationaccessorAsyncIterator.envrmdircloudtrailargvequalitydescriptionkinesisECMAScript 2020mochachildexecautoprefixerfunction.length__proto__mimeschemereal-time3dequalnativeextensionbinarycall-bindfindupECMAScript 2015graphqlawesomesaucemanagerconcatstyled-componentsinferenceECMAScript 7testes-shimsmimetypestypeofsidesyntaxagenthtmlsuperstructfindLastprivatequoteweakmapcjkrfc4122s3typanionFloat32ArrayObject.entriescssfilterasciiwaitfastifymulti-packageconcurrencydynamodbes2016chromeECMAScript 2018Int16ArrayECMAScript 5tapURLES2018globalsdom-testing-librarytakejsonformbannermodulesWebSocketstslibgroupBystringifyincludespromisesprototypeemojithroatObservablewarningstylesstreamsflattenasteriskscomparelogprocesshttpselasticachecode pointsbundlingvpcquerystringdebugtouchflatMapHyBiBigInt64ArraytoSortednumberflagslazyglacierbrowserslistdominvariantrobustwordbreakstringifierES3isansiargumentsestermtrimdefinePropertyUint8ArrayexpressionpromisesyntaxerrorfigletdeleteRxargsinstallercryptocoreeast-asian-widtheventDispatchersetImmediatesuperagentratelimitcharacteroptionArrayBuffer.prototype.sliceregular expressionSymbolmakeURLSearchParamsisConcatSpreadablenodejscore-jsjsrandomES2021typedsequencesymbolinstallsaferuntimeimportspeedstdlibreduceconfigbuffersObservablesprivate dataes5ECMAScript 2017dayjswgetjsdomstyleguidejapaneseArrayBuffer#slicemake dirutilitiesbinglobalsqscall-boundinternalutilityi18nECMAScript 3taskESnextcollection.es6terminaltapecloudfrontwrapcreatejsxnegative zerogdprownes2018loadbalancingbrowserlistyamlformatArray.prototype.filterdragduplexsubprocessECMAScript 6sorttostringtagwritecircularlinewrapjsdiffpathgroupcollectiongetoptspeccallbounditerationrangeerroridcharactersimmerthreeobjutil.inspectentriesObject.assignstreamgesturesArray.prototype.flattenxhrcloudsearchzeroCSSnpmcolourprettyserializees-shim APIoptimizertypeerrorparserhas-ownconcatMapvarsArray.prototype.containsenvironmentserrorresolveInt8ArraykoreanwhatwgdropSymbol.toStringTagidleArray.prototype.flatMapflatbufferObject.isbreakfull-widthreact posepreserve-symlinks[[Prototype]]IteratorworkerdotenvUnderscoreapisettingsroutingserializerRFC-6455ReactiveXstableRegExp.prototype.flagslinkdeepcopyfast-deep-copytextcallreaddescriptorexpressfolderemrreadablestreamiteratestringloadingsetPrototypeOfpropertiesobjecthooksrmpreprocessorcodesvaluetoStringTagtoolkitfind-upweaksettddstreams2getintrinsiceventsarraysshamreadablequeryreworkescapechaitelephonemobileairbnbworkflowkeysomemkdircommand-lineplugindataViewsharedarraybufferuninstallcloneestreecss-in-jshashttytrimEndregexarraybuffersameValueZeroMicrosofttyped arrayUint32ArraylruconsumeECMAScript 2022JSONparentslotremoveidentifiersreduxcolumnefficientbyteLengthwordwrap_.extendebsnamefunctionsswf0BigUint64Arraybyteloggerhelpergitignoremime-dbObject.getPrototypeOfassertpackage.jsonES2019mergesymlinkshasOwncloudwatchStreambindstoragegatewayspringqsreactbddscheme-validationStreamsdeterministictoolscopysortedcheckhookformoptimistlastl10nstylequeueMicrotasknamesparentsecmascriptcontainsregulartypedarrayssharedmkdirpcolorschinesees-abstractintrinsicmoverm -frstatelessrequestpostcsslanguagejasminelimitedregexpfast-copyviewlibphonenumberruleslocalanimationhttpes7elbbusyUint8ClampedArraybeanstalkqueuegetPrototypeOfString.prototype.matchAllES2016Object.valuesjQueryarrayfile system-0apollooffsetvestRxJStrimStarthigher-orderregular expressionsESgloboutputES7flagendpointforEachformattingmetadataprogresstypedarraypackagespruneframerloggingcommandtransformjshintcacheJSON-SchemalocationArray.prototype.includesbluebirdCSSStyleDeclarationtypeunicodeFloat64ArraymoduleintrimRightsetguidassigneslintpluginzxfetchmapreduceObject.fromEntrieszodArray.prototype.flatTypeBoxnopeinspectPromiseECMAScript 2023postcss-pluginsource maphelpersECMAScript 2016redactstructuredClonehases2015shebangfunctionalpipeawaitinpututilcallbinddebuggerkarmaredux-toolkitwaapicloudformationdefinedataviewtesterimmutablestylingelectronnodeObject.keyspicomatchArrayBufferfeedinternal slotrequireObjectdependenciesnpmignoretraverseposeindicatorArray.prototype.findLastnegativeInt32Arrayminimal.gitignorefullwidthvisualconfigurablevalidateObject.definePropertymatcha11yjoiperformancewidthfastfindserializationxtermrgbfpslength