-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconverter.js
71 lines (71 loc) · 1.47 KB
/
converter.js
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
module.exports = {
name: "converter",
ns: "utils",
description: "Convert ascii, utf8, ucs2, base64, binary or hex",
async: true,
phrases: {
active: "Converting from {{input.from}} to {{input.to}}"
},
ports: {
input: {
"in": {
type: "any",
title: "Input",
async: true,
fn: function __IN__(data, source, state, input, $, output, buffer) {
var r = function() {
// \n replace shouldn't be necessary.
if (typeof $.in === 'string' && $.from === 'base64') {
$.in = $.in.replace('\n', '');
}
var d = new buffer.Buffer($.in, $.from);
output({
out: $.write('in', d.toString($.to))
});
}.call(this);
return {
state: state,
return: r
};
}
},
from: {
"enum": ["ascii",
"utf8",
"ucs2",
"base64",
"binary",
"hex"
],
type: "string",
title: "From",
"default": "utf8"
},
to: {
"enum": ["ascii",
"utf8",
"ucs2",
"base64",
"binary",
"hex"
],
type: "string",
title: "To",
"default": "utf8"
}
},
output: {
out: {
type: "any",
title: "Output"
}
}
},
dependencies: {
npm: {
buffer: require('buffer')
}
},
state: {},
on: {}
}