node-automator 1.4.18 → 1.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-automator",
3
- "version": "1.4.18",
3
+ "version": "1.4.19",
4
4
  "description": "Execute automation with yaml configuration(compatible with json)",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -1,59 +1,12 @@
1
- function utf8_encode(string) {
2
- string = string.replace(/\r\n/g, "\n");
3
- var utftext = "";
4
- for (var n = 0; n < string.length; n++) {
5
- var c = string.charCodeAt(n);
6
- if (c < 128) {
7
- utftext += String.fromCharCode(c);
8
- } else if ((c > 127) && (c < 2048)) {
9
- utftext += String.fromCharCode((c >> 6) | 192);
10
- utftext += String.fromCharCode((c & 63) | 128);
11
- } else {
12
- utftext += String.fromCharCode((c >> 12) | 224);
13
- utftext += String.fromCharCode(((c >> 6) & 63) | 128);
14
- utftext += String.fromCharCode((c & 63) | 128);
15
- }
16
-
17
- }
18
- return utftext;
19
- }
20
-
21
- function utf8_decode(utftext) {
22
- var string = "";
23
- var i = 0;
24
- var c = 0;
25
- var c2 = 0;
26
- var c3 = 0;
27
- while (i < utftext.length) {
28
- c = utftext.charCodeAt(i);
29
- if (c < 128) {
30
- string += String.fromCharCode(c);
31
- i++;
32
- } else if ((c > 191) && (c < 224)) {
33
- c2 = utftext.charCodeAt(i + 1);
34
- string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
35
- i += 2;
36
- } else {
37
- c2 = utftext.charCodeAt(i + 1);
38
- c3 = utftext.charCodeAt(i + 2);
39
- string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
40
- i += 3;
41
- }
42
- }
43
- return string;
44
- }
45
-
46
1
  function encode(string) {
47
- return btoa(utf8_encode(string));
2
+ return Buffer.from(string).toString("base64");
48
3
  }
49
4
 
50
5
  function decode(string) {
51
- return utf8_decode(atob(string));
6
+ return Buffer.from(string, "base64").toString("utf8");
52
7
  }
53
8
 
54
9
  module.exports = {
55
- utf8_encode,
56
- utf8_decode,
57
10
  encode,
58
11
  decode,
59
12
  };