-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateWriteStream.js
More file actions
78 lines (75 loc) · 1.45 KB
/
createWriteStream.js
File metadata and controls
78 lines (75 loc) · 1.45 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
module.exports = {
name: "createWriteStream",
ns: "fs",
title: "Create Write Stream",
description: "Creates a Writeable Stream Object",
phrases: {
active: "Writing file {{input.file}} ({{input.encoding}})"
},
ports: {
input: {
file: {
title: "Filename",
type: "string",
required: true
},
encoding: {
title: "Encoding",
type: "string",
"default": "utf-8"
},
flag: {
title: "Flag",
type: "string",
"default": "w"
}
},
output: {
error: {
title: "Error",
type: "object"
},
stream: {
title: "Stream",
type: "Stream"
},
fd: {
type: "number",
title: "File descriptor"
}
}
},
dependencies: {
npm: {
fs: require('fs')
}
},
fn: function createWriteStream(input, $, output, state, done, cb, on, fs) {
var r = function() {
var opts = {
flag: $.flag,
encoding: $.encoding
};
var stream = fs.createWriteStream($.file, opts);
output({
stream: $.create(stream)
});
stream.on('error', function(err) {
output({
error: $.create(err)
});
});
stream.on('open', function(fd) {
output({
fd: $.create(fd)
});
});
}.call(this);
return {
output: output,
state: state,
on: on,
return: r
};
}
}