comparison xml/en/docs/njs/reference.xml @ 2951:c231cd046ac5

Documented the zlib module in njs reference.
author Yaroslav Zhuravlev <yar@nginx.com>
date Mon, 10 Apr 2023 18:25:45 +0100
parents a412c1fffbf1
children 4939c98e2f25
comparison
equal deleted inserted replaced
2950:a412c1fffbf1 2951:c231cd046ac5
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> 7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">
8 8
9 <article name="Reference" 9 <article name="Reference"
10 link="/en/docs/njs/reference.html" 10 link="/en/docs/njs/reference.html"
11 lang="en" 11 lang="en"
12 rev="101"> 12 rev="102">
13 13
14 <section id="summary"> 14 <section id="summary">
15 15
16 <para> 16 <para>
17 <link doc="index.xml">njs</link> provides objects, methods and properties 17 <link doc="index.xml">njs</link> provides objects, methods and properties
5428 </list> 5428 </list>
5429 </para> 5429 </para>
5430 5430
5431 </section> 5431 </section>
5432 5432
5433
5434 <section id="zlib" name="zlib">
5435
5436 <para>
5437 The zlib module provides compression functionality using the
5438 “deflate” and “inflate” algorithms
5439 (since <link doc="changes.xml" id="njs0.7.12">0.7.12</link>).
5440 The zlib module object is returned by
5441 <literal>require('zlib')</literal>.
5442 </para>
5443
5444 <para>
5445 <list type="tag">
5446
5447 <tag-name id="zlib_deflaterawsync"><literal>deflateRawSync(<value>string</value> |
5448 <value>Buffer</value>[,
5449 <value>options</value>])</literal></tag-name>
5450 <tag-desc>
5451 Compresses data using the “deflate” algorithm provided as a string or Buffer
5452 and does not append a zlib header.
5453 The buffer value can be a
5454 <literal>Buffer</literal>,
5455 <literal>TypedArray</literal>, or
5456 <literal>DataView</literal>.
5457 <literal>Options</literal> is an optional object that contains
5458 <link id="zlib_options"/>.
5459 Returns Buffer instance that contains the compressed data.
5460 </tag-desc>
5461
5462 <tag-name id="zlib_deflatesync"><literal>deflateSync(<value>string</value> |
5463 <value>Buffer</value>[,
5464 <value>options</value>])</literal></tag-name>
5465 <tag-desc>
5466 Compresses data using the “deflate” algorithm provided as a string or Buffer.
5467 The Buffer value can be a
5468 <literal>Buffer</literal>,
5469 <literal>TypedArray</literal>, or
5470 <literal>DataView</literal>.
5471 <literal>Options</literal> is an optional object that contains
5472 <link id="zlib_options"/>.
5473 Returns Buffer instance that contains the compressed data.
5474 </tag-desc>
5475
5476 <tag-name id="zlib_inflaterawsync"><literal>inflateRawSync(<value>string</value> |
5477 <value>Buffer</value>)</literal></tag-name>
5478 <tag-desc>
5479 Decompresses a raw stream by using the “deflate” algorithm.
5480 Returns Buffer instance that contains the decompressed data.
5481 </tag-desc>
5482
5483 <tag-name id="zlib_inflatesync"><literal>inflateSync(<value>string</value> |
5484 <value>Buffer</value>)</literal></tag-name>
5485 <tag-desc>
5486 Decompresses a stream by using the “deflate” algorithm.
5487 Returns Buffer instance that contains the decompressed data.
5488 </tag-desc>
5489
5490 </list>
5491 </para>
5492
5493
5494 <section id="zlib_options" name="zlib options">
5495
5496 <para>
5497 <list type= "bullet" compact="no">
5498
5499 <listitem>
5500 <literal>chunkSize</literal>&mdash;is an integer,
5501 by default is <literal>1024</literal>
5502 </listitem>
5503
5504 <listitem>
5505 <literal>dictionary</literal>&mdash;is a
5506 <literal>Buffer</literal>,
5507 <literal>TypedArray</literal>, or
5508 <literal>DataView</literal>.
5509 by default is empty
5510 </listitem>
5511
5512 <listitem>
5513 <literal>level</literal>&mdash;is an integer, compression only,
5514 see <link id="zlib_compression_levels"/>
5515 </listitem>
5516
5517 <listitem>
5518 <literal>memLevel</literal>&mdash;is an integer
5519 from <literal>1</literal> to <literal>9</literal>, compression only
5520 </listitem>
5521
5522 <listitem>
5523 <literal>strategy</literal>&mdash;is an integer, compression only,
5524 see <link id="zlib_compression_strategy"/>
5525 </listitem>
5526
5527 <listitem>
5528 <literal>windowBits</literal>&mdash;is an integer
5529 from <literal>-15</literal> to <literal>-9</literal>
5530 for raw data,
5531 from <literal>9</literal> to <literal>15</literal>
5532 for an ordinary stream
5533 </listitem>
5534
5535 </list>
5536 </para>
5537
5433 </section> 5538 </section>
5434 5539
5540 <section id="zlib_compression_levels" name="zlib compression levels">
5541
5542 <para>
5543 <table>
5544 <tr><td>Name</td><td>Description</td></tr>
5545 <tr><td><literal>zlib.constants.Z_NO_COMPRESSION</literal></td><td>no compression</td></tr>
5546 <tr><td><literal>zlib.constants.Z_BEST_SPEED</literal></td><td>fastest, produces the least compression</td></tr>
5547 <tr><td><literal>zlib.constants.Z_DEFAULT_COMPRESSION</literal></td><td>trade-off between speed and compression</td></tr>
5548 <tr><td><literal>zlib.constants.Z_BEST_COMPRESSION</literal></td><td>slowest, produces the most compression</td></tr>
5549 </table>
5550 </para>
5551
5552 </section>
5553
5554 <section id="zlib_compression_strategy" name="zlib compression strategy">
5555
5556 <para>
5557 <table>
5558 <tr><td>Name</td><td>Description</td></tr>
5559 <tr><td><literal>zlib.constants.Z_FILTERED</literal></td><td>Filtered strategy: for the data produced by a filter or predictor</td></tr>
5560 <tr><td><literal>zlib.constants.Z_HUFFMAN_ONLY</literal></td><td>Huffman-only strategy: only Huffman encoding, no string matching</td></tr>
5561 <tr><td><literal>zlib.constants.Z_RLE</literal></td><td>Run Length Encoding strategy: limit match distances to one, better compression of PNG image data</td></tr>
5562 <tr><td><literal>zlib.constants.Z_FIXED</literal></td><td>Fixed table strategy: prevents the use of dynamic Huffman codes, a simpler decoder for special applications</td></tr>
5563 <tr><td><literal>zlib.constants.Z_DEFAULT_STRATEGY</literal></td><td>Default strategy, suitable for general purpose compression</td></tr>
5564 </table>
5565 </para>
5566
5567 </section>
5568
5569 </section>
5570
5571 </section>
5572
5435 </article> 5573 </article>