File: node_stream.md

package info (click to toggle)
node-jszip 3.5.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 25,100 kB
  • sloc: javascript: 5,652; makefile: 2; sh: 2
file content (33 lines) | stat: -rw-r--r-- 1,001 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
title: "nodeStream(type[, onUpdate])"
layout: default
section: api
---

Return a [nodejs Streams3](https://github.com/nodejs/readable-stream)
of the content in the asked type.

__Returns__ : a [nodejs Streams3](https://github.com/nodejs/readable-stream).

## Arguments

name     | type     | default      | description
---------|----------|--------------|------------
type     | String   | `nodebuffer` | only `nodebuffer` is currently supported.
onUpdate | Function |              | an optional function called on each internal update with the metadata.

__Metadata__ : see [the metadata of `async()`]({{site.baseurl}}/documentation/api_zipobject/async.html#onupdate-callback).

## Example

```js
zip
.file("my_text.txt")
.nodeStream()
.pipe(fs.createWriteStream('/tmp/my_text.txt'))
.on('finish', function () {
    // JSZip generates a readable stream with a "end" event,
    // but is piped here in a writable stream which emits a "finish" event.
    console.log("text file written.");
});
```