summaryrefslogtreecommitdiff
path: root/lib/zlib.js
AgeCommit message (Collapse)Author
2017-03-10meta: restore original copyright headerJames M Snell
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.
2017-02-17zlib: use RangeError/TypeError consistentlyJames M Snell
PR-URL: https://github.com/nodejs/node/pull/11391 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2017-02-17zlib: refactor zlib moduleJames M Snell
PR-URL: https://github.com/nodejs/node/pull/11391 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2017-01-25zlib: be strict about what strategies are acceptedRich Trott
Currently, strategy constants are integers but Node.js will accept string versions of those integers. Users should be using the provided zlib constants and not hardcoding numbers, strings, or anything else. As such, Node.js should be strict about accepting only exactly those values that are in the provided zlib constants. PR-URL: https://github.com/nodejs/node/pull/10934 Fixes: https://github.com/nodejs/node/issues/10932 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2016-11-08zlib: fix linting recently-introduced lint errorRich Trott
Remove unnecessary named function. V8 will do a better job inferring the name from the assignment to a property. The current formulation does not pass linting. PR-URL: https://github.com/nodejs/node/pull/9524 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-11-08zlib: name every function Ref: #8913solebox
PR-URL: https://github.com/nodejs/node/pull/9389 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2016-11-02test: increase test coverage for lib/zlib.jsRich Trott
Add tests for constructor behavior and parameter validation. Remove condition check that cannot be triggered (nothing is greater than `Infinity`). PR-URL: https://github.com/nodejs/node/pull/9366 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-06-11zlib: move constants into zlib.constantsJames M Snell
zlib constants were previously being added to binding in node_zlib.cc. This moves the zlib constants to node_constants.cc for consistency with the recent constants refactoring: https://github.com/nodejs/node/pull/6534 Adds require('zlib').constants to expose the constants Docs-only deprecates the constants hung directly off require('zlib') Removes a couple constants from the docs that apparently no longer exist in the code PR-URL: https://github.com/nodejs/node/pull/7203 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-05-28zlib: release callback and buffer after processingMatt Lavin
PR-URL: https://github.com/nodejs/node/pull/6955 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yuval Brik <yuval@brik.org.il>
2016-05-17zlib: remove `_closed` in sourceAnna Henningsen
This is purely cleanup and carries no visible behavioural changes. Up to now, `this._closed` was used in zlib.js as a synonym of `!this._handle`. This change makes this connection explicit and removes the `_closed` property from zlib streams, as the previous duplication has been the cause of subtle errors like https://github.com/nodejs/node/issues/6034. This also makes zlib errors lead to an explicit `_close()` call rather than waiting for garbage collection to clean up the handle, thus returning memory resources earlier in the case of an error. Add a getter for `_closed` so that the property remains accessible by legacy code. PR-URL: https://github.com/nodejs/node/pull/6574 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-04-19zlib: fix use after null when calling .closeJames Lal
An internal zlib error may cause _handle to be set to null. Close now will check if there is a _handle prior to calling .close on it. PR-URL: https://github.com/nodejs/node/pull/5982 Fixes: https://github.com/nodejs/node/issues/6034 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-18lib,test,tools: alignment on variable assignmentsRich Trott
Correct alignment on variable assignments that span multiple lines in preparation for lint rule to enforce such alignment. PR-URL: https://github.com/nodejs/node/pull/6242 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-04-17zlib: Make the finish flush flag configurableAnna Henningsen
Up to now, `Z_FINISH` was always the flushing flag that was used for the last chunk of input data. This patch makes this choice configurable so that advanced users can perform e.g. decompression of partial data using `Z_SYNC_FLUSH`, if that suits their needs. Add tests to make sure that an error is thrown upon encountering invalid `flush` or `finishFlush` flags. Fixes: https://github.com/nodejs/node/issues/5761 PR-URL: https://github.com/nodejs/node/pull/6069 Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-19zlib: do not emit event on *Sync() methodsRich Trott
Asynchronous functions in `zlib` should not emit the close event. This fixes an issue where asynchronous calls in a for loop could exhaust memory because the pending event prevents the objects from being garbage collected. Fixes: https://github.com/nodejs/node/issues/1668 PR-URL: https://github.com/nodejs/node/pull/5707 Reviewed-By: jasnell - James M Snell <jasnell@gmail.com> Reviewed-By: trevnorris - Trevor Norris <trev.norris@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2016-03-16buffer: add .from(), .alloc() and .allocUnsafe()James M Snell
Several changes: * Soft-Deprecate Buffer() constructors * Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()` * Add `--zero-fill-buffers` command line option * Add byteOffset and length to `new Buffer(arrayBuffer)` constructor * buffer.fill('') previously had no effect, now zero-fills * Update the docs PR-URL: https://github.com/nodejs/node/pull/4682 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2015-11-14zlib: only apply drain listener if given callbackCraig Cavalier
When stream.flush() is called without a callback, an empty listener is being added. Since flush may be called multiple times to push SSE's down to the client, multiple noop listeners are being added. This in turn causes the memory leak detected message. PR-URL: https://github.com/nodejs/node/pull/3534 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-14zlib: pass kind to recursive calls to flushMyles Borins
Bug spotted by @bnoordhuis while doing code review on #3534 Refs: https://github.com/nodejs/node/pull/3534#discussion_r43047477 PR-URL: https://github.com/nodejs/node/pull/3534 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-09lib: Consistent error messages in all modulesmicnic
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>
2015-08-04buffer: fix usage of kMaxLengthTrevor Norris
Starting in V8 v4.3 the maximum array index of a typed array is the same as the largest Smi supported on a given architecture. To compensate for these differences export kMaxLength from the buffer module with the correct size for the given architecture. PR-URL: https://github.com/nodejs/io.js/pull/2003 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-06-15zlib: prevent uncaught exception in zlibBufferMichaël Zasso
If the accumulation of data for the final Buffer is greater than kMaxLength it will throw an un-catchable RangeError. Instead now pass the generated error to the callback. PR-URL: https://github.com/nodejs/io.js/pull/1811 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-06-15lib,test: fix whitespace issuesRoman Reiss
PR-URL: https://github.com/nodejs/io.js/pull/1971 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-06-11lib: don't use global BufferRoman Reiss
Port of https://github.com/joyent/node/pull/8603 The race condition present in the original PR didn't occur, so no workaround was needed. PR-URL: https://github.com/nodejs/io.js/pull/1794 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-04-15node: allow multiple arguments passed to nextTickTrevor Norris
PR-URL: https://github.com/iojs/io.js/pull/1077 Reviewed-by: Colin Ihrig <cjihrig@gmail.com>
2015-04-07zlib: make constants keep readonlyJackson Tian
In zlib module, a dozen constants were exported to user land, If user change the constant, maybe lead unexcepted error. Make them readonly and freezon. PR-URL: https://github.com/iojs/io.js/pull/1361 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-01-31lib: reduce util.is*() usagecjihrig
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>
2015-01-21lib: use const to define constantscjihrig
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>
2015-01-12Remove excessive copyright/license boilerplateisaacs
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.
2015-01-09src: zlib: revert concatenated-stream changesChris Dickinson
Revert "src: fix windows build error" and "zlib: support concatenated gzip files". This reverts commits be413ac732f59ffe621f264239e5e22b77d32025 and 1183ba47dfc2bc8b39f0c10d8dc9e9299a4470bf. Treating subsequent bytes as a concatenated zlib stream breaks npm install. Conflicts: test/parallel/test-zlib-from-multiple-gzip-with-garbage.js test/parallel/test-zlib-from-multiple-gzip.js test/parallel/test-zlib-from-multiple-huge-gzip.js Fixes: https://github.com/joyent/node/issues/8962 PR-URL: https://github.com/iojs/io.js/pull/240 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-11-22lib: turn on strict modeBen Noordhuis
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>
2014-11-09zlib: support concatenated gzip filesLuis Reis
Reviewed-By: Fedor Indutny <fedor@indutny.com> PR-URL: https://github.com/joyent/node/pull/6442
2014-09-05lib: improved forEach object performanceMajid Arif Siddiqui
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-07-29Merge remote-tracking branch 'origin/v0.10' into masterFedor Indutny
Conflicts: doc/api/buffer.markdown lib/_stream_readable.js lib/assert.js lib/buffer.js lib/child_process.js lib/http.js lib/string_decoder.js lib/zlib.js node.gyp test/simple/test-buffer.js test/simple/test-https-foafssl.js test/simple/test-stream2-compatibility.js test/simple/test-tls-server-verify.js
2014-06-27zlib: do not crash on write after closeFedor Indutny
fix #7767 Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-06-11lib: remove unused variablesBrian White
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-05-07crypto, zlib: replace _binding with _handleNicholas Vavilov
Also include whitespace fixes to appease jslint. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-02-04zlib: separate sync/async methodsFedor Indutny
2014-02-01zlib: add sync versions for convenience methodsNikolai Vavilov
2013-08-01src: Replace macros with util functionsisaacs
2013-07-24lib: macro-ify type checksBen Noordhuis
Increases the grep factor. Makes it easier to harmonize type checks across the code base.
2013-07-01zlib: allow zero values for level and strategyBrian White
This is a back-port of commit c9644fb from the master branch.
2013-07-01zlib: allow changing of level and strategyBrian White
2013-07-01zlib: allow custom flush type for flush()Brian White
2013-07-01zlib: remove unused parameterBrian White
2013-07-01zlib: allow zero values for level and strategyBrian White
2013-03-29zlib: allow passing options to convenience methodsKyle Robinson Young
2013-03-08zlib: Manage flush flags appropriatelyisaacs
If you call z.flush();z.write('foo'); then it would try to write 'foo' before the flush was done, triggering an assertion in the zlib binding. Closes #4950
2013-03-05stream: _write takes an encoding argumentisaacs
This vastly reduces the overhead of decodeStrings:false streams, such as net and http.
2013-03-05stream: Remove output function from _transformisaacs
Just use stream.push(outputChunk) instead.
2013-02-21stream: remove lowWaterMark featureisaacs
It seems like a good idea on the face of it, but lowWaterMarks are actually not useful, and in practice should always be set to zero. It would be worthwhile for writers if we actually did some kind of writev() type of thing, but actually this just delays calling write() and the overhead of doing a bunch of Buffer copies is not worth the slight benefit of calling write() fewer times.
2013-02-06Merge remote-tracking branch 'ry/v0.8' into masterisaacs
Conflicts: AUTHORS ChangeLog deps/npm/html/api/bin.html deps/npm/html/api/bugs.html deps/npm/html/api/commands.html deps/npm/html/api/config.html deps/npm/html/api/deprecate.html deps/npm/html/api/docs.html deps/npm/html/api/edit.html deps/npm/html/api/explore.html deps/npm/html/api/help-search.html deps/npm/html/api/init.html deps/npm/html/api/install.html deps/npm/html/api/link.html deps/npm/html/api/load.html deps/npm/html/api/ls.html deps/npm/html/api/npm.html deps/npm/html/api/outdated.html deps/npm/html/api/owner.html deps/npm/html/api/pack.html deps/npm/html/api/prefix.html deps/npm/html/api/prune.html deps/npm/html/api/publish.html deps/npm/html/api/rebuild.html deps/npm/html/api/restart.html deps/npm/html/api/root.html deps/npm/html/api/run-script.html deps/npm/html/api/search.html deps/npm/html/api/shrinkwrap.html deps/npm/html/api/start.html deps/npm/html/api/stop.html deps/npm/html/api/submodule.html deps/npm/html/api/tag.html deps/npm/html/api/test.html deps/npm/html/api/uninstall.html deps/npm/html/api/unpublish.html deps/npm/html/api/update.html deps/npm/html/api/version.html deps/npm/html/api/view.html deps/npm/html/api/whoami.html deps/npm/html/doc/README.html deps/npm/html/doc/adduser.html deps/npm/html/doc/bin.html deps/npm/html/doc/bugs.html deps/npm/html/doc/build.html deps/npm/html/doc/bundle.html deps/npm/html/doc/cache.html deps/npm/html/doc/changelog.html deps/npm/html/doc/coding-style.html deps/npm/html/doc/completion.html deps/npm/html/doc/config.html deps/npm/html/doc/dedupe.html deps/npm/html/doc/deprecate.html deps/npm/html/doc/developers.html deps/npm/html/doc/disputes.html deps/npm/html/doc/docs.html deps/npm/html/doc/edit.html deps/npm/html/doc/explore.html deps/npm/html/doc/faq.html deps/npm/html/doc/folders.html deps/npm/html/doc/global.html deps/npm/html/doc/help-search.html deps/npm/html/doc/help.html deps/npm/html/doc/index.html deps/npm/html/doc/init.html deps/npm/html/doc/install.html deps/npm/html/doc/json.html deps/npm/html/doc/link.html deps/npm/html/doc/ls.html deps/npm/html/doc/npm.html deps/npm/html/doc/outdated.html deps/npm/html/doc/owner.html deps/npm/html/doc/pack.html deps/npm/html/doc/prefix.html deps/npm/html/doc/prune.html deps/npm/html/doc/publish.html deps/npm/html/doc/rebuild.html deps/npm/html/doc/registry.html deps/npm/html/doc/removing-npm.html deps/npm/html/doc/restart.html deps/npm/html/doc/rm.html deps/npm/html/doc/root.html deps/npm/html/doc/run-script.html deps/npm/html/doc/scripts.html deps/npm/html/doc/search.html deps/npm/html/doc/semver.html deps/npm/html/doc/shrinkwrap.html deps/npm/html/doc/star.html deps/npm/html/doc/start.html deps/npm/html/doc/stop.html deps/npm/html/doc/submodule.html deps/npm/html/doc/tag.html deps/npm/html/doc/test.html deps/npm/html/doc/uninstall.html deps/npm/html/doc/unpublish.html deps/npm/html/doc/update.html deps/npm/html/doc/version.html deps/npm/html/doc/view.html deps/npm/html/doc/whoami.html deps/npm/man/man1/global.1 deps/npm/man/man1/ls.1 deps/npm/man/man1/npm.1 deps/npm/man/man1/rm.1 deps/npm/man/man3/npm.3 deps/npm/node_modules/glob/glob.js deps/npm/node_modules/glob/package.json deps/npm/node_modules/node-gyp/package.json deps/npm/node_modules/npm-registry-client/package.json deps/npm/node_modules/npmconf/package.json deps/npm/node_modules/read-installed/package.json deps/npm/node_modules/rimraf/package.json deps/npm/node_modules/rimraf/rimraf.js deps/npm/package.json deps/uv/src/win/error.c doc/api/crypto.markdown lib/zlib.js src/node_version.h src/node_zlib.cc test/simple/test-buffer.js