summaryrefslogtreecommitdiff
path: root/lib/_stream_transform.js
Commit message (Collapse)AuthorAgeFilesLines
* stream: do not use _stream_* anymoreMatteo Collina2021-01-051-3/+2
| | | | | | | | | | | Remove all leftover usage of _stream_* and keep all of them as legacy. We do not deprecate the old modules to avoid disrupition and ease maintainance. PR-URL: https://github.com/nodejs/node/pull/36684 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
* stream: move to internal/streamsMatteo Collina2020-09-211-242/+2
| | | | | | | | | | | | Move all the streams constructors to internal/streams and avoid a circular dependencies between the modules. See: https://github.com/nodejs/readable-stream/issues/348 PR-URL: https://github.com/nodejs/node/pull/35239 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
* stream: support async for stream impl functionsJames M Snell2020-08-031-2/+65
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/34416 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
* stream: try to wait for flush to complete before 'finish'Robert Nagy2020-07-151-2/+20
| | | | | | | | | | | | | | | | Due to compat reasons Transform streams don't always wait for flush to complete before finishing the stream. Try to wait when possible, i.e. when the user does not override _final. Fixes: https://github.com/nodejs/node/issues/34274 PR-URL: https://github.com/nodejs/node/pull/34314 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Zeyu Yang <himself65@outlook.com>
* stream: fix _final and 'prefinish' timingRobert Nagy2020-04-221-4/+4
| | | | | | | | | | | | | | | | | | | | This PR fixes a few different things: The timing of 'prefinish' depends on whether or not _final is defined. In on case the event is emitted synchronously with end() and otherwise asynchronously. _final is currently unecessarily called asynchronously which forces implementors to use 'prefinish' as a hack to emulate synchronous behaviour. Furthermore, this hack is subtly broken due to the above issue. Refs: https://github.com/nodejs/node/issues/31401 Refs: https://github.com/nodejs/node/pull/32763#discussion_r407041983 PR-URL: https://github.com/nodejs/node/pull/32780 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* stream: simplify Transform stream implementationRobert Nagy2020-04-151-108/+52
| | | | | | | | | Significantly simplified Transform stream implementation by using mostly standard stream code. PR-URL: https://github.com/nodejs/node/pull/32763 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* stream: change var to let/const in stream filesSaajan2020-03-301-1/+1
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/32214 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* http,stream: make virtual methods throw an errorLuigi Pinca2020-03-071-1/+1
| | | | | | | | | | | | | | | | | Make virtual methods throw an ERR_METHOD_NOT_IMPLEMENTED error instead of emitting it. The error is not recoverable and the only way to handle it is to override the method. PR-URL: https://github.com/nodejs/node/pull/31912 Refs: https://github.com/nodejs/node/pull/31818#pullrequestreview-359403469 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* lib: flatten access to primordialsMichaël Zasso2019-11-251-3/+5
| | | | | | | | | | | | | | Store all primordials as properties of the primordials object. Static functions are prefixed by the constructor's name and prototype methods are prefixed by the constructor's name followed by "Prototype". For example: primordials.Object.keys becomes primordials.ObjectKeys. PR-URL: https://github.com/nodejs/node/pull/30610 Refs: https://github.com/nodejs/node/issues/29766 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* stream: remove TODO and add a description insteadRuben Bridgewater2019-05-021-3/+1
| | | | | | | | | | | | | After looking into this it turned out that these two errors are sanity checks that should not be reached. It is unfortunate that we assigned error codes for these but changing it into an assertion seems to be a hassle for `readable-streams`. PR-URL: https://github.com/nodejs/node/pull/27086 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
* lib: enforce the use of Object from primordialsMichaël Zasso2019-04-121-0/+2
| | | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/27146 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
* benchmark,lib: change var to constRuben Bridgewater2019-03-301-5/+5
| | | | | | | | | Refs: https://github.com/nodejs/node/pull/26679 PR-URL: https://github.com/nodejs/node/pull/26915 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Refael Ackermann <refack@gmail.com>
* stream: make sure 'readable' is emitted before ending the streamMatteo Collina2019-03-061-3/+0
| | | | | | | | Fixes: https://github.com/nodejs/node/issues/25810 PR-URL: https://github.com/nodejs/node/pull/26059 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
* doc,lib,test: capitalize comment sentencesRuben Bridgewater2018-12-171-3/+3
| | | | | | | | | | | This activates the eslint capitalize comment rule for comments above 50 characters. PR-URL: https://github.com/nodejs/node/pull/24996 Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* tools: capitalize sentencesRuben Bridgewater2018-12-101-2/+2
| | | | | | | | | | | | This adds the `capitalized-comments` eslint rule to verify that actual sentences use capital letters as starting letters. It ignores special words and all lines below 62 characters. PR-URL: https://github.com/nodejs/node/pull/24808 Reviewed-By: Sam Ruby <rubys@intertwingly.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
* lib: use ES6 class inheritance styleRuben Bridgewater2018-12-051-0/+1
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/24755 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* lib: remove `inherits()` usageRuben Bridgewater2018-12-051-2/+1
| | | | | | | | | | | | | | | This switches all `util.inherits()` calls to use `Object.setPrototypeOf()` instead. In fact, `util.inherits()` is mainly a small wrapper around exactly this function while adding the `_super` property on the object as well. Refs: #24395 PR-URL: https://github.com/nodejs/node/pull/24755 Refs: https://github.com/nodejs/node/issues/24395 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* stream: make virtual methods errors consistentLuigi Pinca2018-03-121-1/+1
| | | | | | | | | | | Use the same error code and always emit the error instead of throwing it. PR-URL: https://github.com/nodejs/node/pull/18813 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaë Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* lib: port remaining errors to new systemMichaël Zasso2018-03-071-5/+10
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/19137 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
* stream: updated streams error handlingMathias Buus2018-03-061-2/+1
| | | | | | | | | | | | | | | | | | | | This improves error handling for streams in a few ways. 1. It ensures that no user defined methods (_read, _write, ...) are run after .destroy has been called. 2. It introduces an explicit error to tell the user if they are write to write, etc to the stream after it has been destroyed. 3. It makes streams always emit close as the last thing after they have been destroyed 4. Changes the default _destroy to not gracefully end streams. It also updates net, http2, zlib and fs to the new error handling. PR-URL: https://github.com/nodejs/node/pull/18438 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* stream: delete unused code陈刚2018-02-021-1/+1
| | | | | | | | | | | | | In implementation of `stream.Writable`, `writable._write()` is always called with a callback that is `_writableState.onwrite()`. And In `afterTransform()`, `ts.writechunk` and `ts.writecb` are assigned to null. So, `ts.writecb` is a true value if `ts.writechunk` isn't null. PR-URL: https://github.com/nodejs/node/pull/18278 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
* stream: migrate to internal/errorsRuben Bridgewater2017-10-011-1/+1
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/15665 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* stream: use more explicit statementsRuben Bridgewater2017-06-291-1/+1
| | | | | | | | | | | | | Using objectMode with stream_wrap has not worked properly before and would end in an error. Therefore prohibit the usage of objectMode alltogether. This also improves the handling performance due to the cheaper chunk check and by using explicit statements as they produce better code from the compiler. PR-URL: https://github.com/nodejs/node/pull/13863 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* errors: fix and improve error typesRuben Bridgewater2017-06-281-2/+2
| | | | | | | | | | | | | | | | 1) Add missing lazy assert call 2) Remove obsolete error type 3) Name undocumented error type more appropriate 4) Consolidate error type style (rely on util.format instead of using a function) 5) Uppercase the first letter from error messages 6) Improve some internal error parameters PR-URL: https://github.com/nodejs/node/pull/13857 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* errors,stream-transform: migrate to use internal/errors.jssreepurnajasti2017-06-151-5/+4
| | | | | | PR-URL: https://github.com/nodejs/node/pull/13310 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* stream: improve Transform performanceBrian White2017-06-131-37/+30
| | | | | | PR-URL: https://github.com/nodejs/node/pull/13322 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* stream: improve multiple callback error messagecjihrig2017-05-221-2/+4
| | | | | | | | | | | When a transform stream's callback is called more than once, an error is emitted with a somewhat confusing message. This commit hopes to improve the quality of the error message. Fixes: https://github.com/nodejs/node/issues/12513 PR-URL: https://github.com/nodejs/node/pull/12520 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* stream: add destroy and _destroy methods.Matteo Collina2017-05-221-0/+8
| | | | | | | | | | | | | Adds destroy() and _destroy() methods to Readable, Writable, Duplex and Transform. It also standardizes the behavior and the implementation of destroy(), which has been inconsistent in userland and core. This PR also updates all the subsystems of core to use the new destroy(). PR-URL: https://github.com/nodejs/node/pull/12925 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* meta: restore original copyright headerJames M Snell2017-03-101-0/+21
| | | | | | | | | | | | | | | A prior io.js era commit inappropriately removed the original copyright statements from the source. This restores those in any files still remaining from that edit. Ref: https://github.com/nodejs/TSC/issues/174 Ref: https://github.com/nodejs/node/pull/10599 PR-URL: https://github.com/nodejs/node/pull/10155 Note: This PR was required, reviewed-by and approved by the Node.js Foundation Legal Committee and the TSC. There is no `Approved-By:` meta data.
* src: fixes misplaced commentMadhav Gharmalkar2016-09-301-1/+1
| | | | | | | | | | | In e26622b, a comment was incorrectly moved from the code it was describing. Fixes: https://github.com/nodejs/node/issues/8856 PR-URL: https://github.com/nodejs/node/pull/8860 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* stream: improve stream error messagesItalo A. Casas2016-09-291-1/+1
| | | | | | | | | | | | | | Improve message when tranform._transform() method is not implemented Improve error message when Readable._read() is not implemented Remove extra word in err msg when Writable._write() when not implemented Remove extra word in err msg when Transform._transform() when not implemented PR-URL: https://github.com/nodejs/node/pull/8801 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
* stream: 'data' argument on callback of Transform._flush()Jesús Leganés Combarro "piranna2016-06-091-3/+6
| | | | | | | | | Add a `data` argument on Transform._flush() callback to be API consistent with Transform._transform(). Fixes: https://github.com/nodejs/node/issues/3707 PR-URL: https://github.com/nodejs/node/pull/3708 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* stream: prevent object map change in TransformStateEvan Lucas2016-02-021-0/+1
| | | | | | | | | | | TransformState has the writeencoding property that gets set on the first _write. It is not declared when the transform state is initially constructed and can cause a deopt. PR-URL: https://github.com/nodejs/node/pull/5032 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* stream: remove useless if test in transformzoubin2016-01-111-2/+1
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/4617 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
* lib: Consistent error messages in all modulesmicnic2015-11-091-3/+3
| | | | | | | | This commit fixes some error messages that are not consistent with some general rules which most of the error messages follow. PR-URL: https://github.com/nodejs/node/pull/3374 Reviewed-By: Roman Reiss <me@silverwind.io>
* stream: simpler stream constructonSam Newman2015-02-041-0/+8
| | | | | | | | | | | Adds simplified constructor pattern, allowing users to provide "read", "write", "transform", "flush", and "writev" functions as stream options in lieu of subclassing. Semver: minor PR-URL: https://github.com/iojs/io.js/pull/697 Fixes: https://github.com/iojs/readable-stream/issues/102 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
* lib: reduce util.is*() usagecjihrig2015-01-311-3/+3
| | | | | | | | | | | | Many of the util.is*() methods used to check data types simply compare against a single value or the result of typeof. This commit replaces calls to these methods with equivalent checks. This commit does not touch calls to the more complex methods (isRegExp(), isDate(), etc.). Fixes: https://github.com/iojs/io.js/issues/607 PR-URL: https://github.com/iojs/io.js/pull/647 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* lib: use const to define constantscjihrig2015-01-211-2/+2
| | | | | | | | This commit replaces a number of var statements throughout the lib code with const statements. PR-URL: https://github.com/iojs/io.js/pull/541 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* Remove excessive copyright/license boilerplateisaacs2015-01-121-22/+0
| | | | | | | The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
* lib: turn on strict modeBen Noordhuis2014-11-221-0/+2
| | | | | | | | | Turn on strict mode for the files in the lib/ directory. It helps catch bugs and can have a positive effect on performance. PR-URL: https://github.com/node-forward/node/pull/64 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>
* lib: remove unused variablesBrian White2014-06-111-2/+2
| | | | Signed-off-by: Fedor Indutny <fedor@indutny.com>
* lib: remove unused variables and functionsBrian White2013-08-151-2/+1
|
* src: Replace macros with util functionsisaacs2013-08-011-3/+3
|
* lib: macro-ify type checksBen Noordhuis2013-07-241-3/+3
| | | | | Increases the grep factor. Makes it easier to harmonize type checks across the code base.
* stream: objectMode transform should allow falsey valuesJeff Barczewski2013-07-031-1/+1
| | | | | | | | If a transform stream has objectMode = true, it should allow falsey values other than (null) like 0, false, ''. null is reserved to indicate stream eof but other falsey values should flow through properly.
* Merge remote-tracking branch 'ry/v0.10' into masterisaacs2013-05-171-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: AUTHORS ChangeLog deps/uv/ChangeLog deps/uv/config-unix.mk deps/uv/src/unix/stream.c deps/uv/src/version.c deps/uv/uv.gyp src/node.cc src/node_buffer.cc src/node_crypto.cc src/node_version.h src/stream_wrap.cc src/stream_wrap.h
| * stream: don't create unnecessary buffers in Readableisaacs2013-05-141-2/+2
| | | | | | | | | | | | | | | | If there is an encoding, and we do 'stream.push(chunk, enc)', and the encoding argument matches the stated encoding, then we're converting from a string, to a buffer, and then back to a string. Of course, this is a completely pointless bit of work, so it's best to avoid it when we know that we can do so safely.
* | stream: Guarantee ordering of 'finish' eventisaacs2013-05-091-1/+1
|/ | | | | | | | | | | | In synchronous Writable streams (where the _write cb is called on the current tick), the 'finish' event (and thus the end() callback) can in some cases be called before all the write() callbacks are called. Use a counter, and have stream.Transform rely on the 'prefinish' event instead of the 'finish' event. This has zero effect on most streams, but it corrects an edge case and makes it perform more deterministically, which is a Good Thing.
* stream: unused variableRafael Garcia2013-04-051-2/+0
|
* stream: remove vestiges of previous _transform APIRafael Garcia2013-04-051-2/+2
|