sync-rpc 1.3.5 → 1.3.6
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/lib/__tests__/index.test.js +34 -2
- package/lib/index.js +14 -3
- package/lib/test-worker.js +3 -0
- package/package.json +1 -1
|
@@ -7,6 +7,8 @@ test('it should work', () => {
|
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
let nativeNCFails = false;
|
|
11
|
+
|
|
10
12
|
rpc.FUNCTION_PRIORITY.forEach((fn, i) => {
|
|
11
13
|
test('profile ' + fn.name, () => {
|
|
12
14
|
try {
|
|
@@ -18,10 +20,36 @@ rpc.FUNCTION_PRIORITY.forEach((fn, i) => {
|
|
|
18
20
|
const end = Date.now();
|
|
19
21
|
console.log(fn.name + ': ' + (end - start));
|
|
20
22
|
} catch (ex) {
|
|
21
|
-
|
|
23
|
+
if (fn.name === 'nativeNC') {
|
|
24
|
+
console.log(fn.name + ' fails');
|
|
25
|
+
nativeNCFails = true;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
throw ex;
|
|
22
29
|
}
|
|
23
30
|
});
|
|
24
31
|
});
|
|
32
|
+
|
|
33
|
+
rpc.FUNCTION_PRIORITY.forEach((fn, i) => {
|
|
34
|
+
test('test 30MB ' + fn.name, () => {
|
|
35
|
+
let result;
|
|
36
|
+
try {
|
|
37
|
+
rpc.configuration.fastestFunction = fn;
|
|
38
|
+
result = client('big');
|
|
39
|
+
} catch (ex) {
|
|
40
|
+
if (fn.name === 'nativeNC' && nativeNCFails) {
|
|
41
|
+
console.log(fn.name + ' fails');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
throw ex;
|
|
45
|
+
}
|
|
46
|
+
expect(result.length).toBe(30 * 1024 * 1024, 42);
|
|
47
|
+
// for (let i = 0; i < 30 * 1024 * 1024, 42; i++) {
|
|
48
|
+
// expect(result[i]).toBe(42);
|
|
49
|
+
// }
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
25
53
|
rpc.FUNCTION_PRIORITY.forEach((fn, i) => {
|
|
26
54
|
let longMessage = '';
|
|
27
55
|
for (let i = 0; i < 100000; i++) {
|
|
@@ -37,7 +65,11 @@ rpc.FUNCTION_PRIORITY.forEach((fn, i) => {
|
|
|
37
65
|
const end = Date.now();
|
|
38
66
|
console.log('large ' + fn.name + ': ' + (end - start));
|
|
39
67
|
} catch (ex) {
|
|
40
|
-
|
|
68
|
+
if (fn.name === 'nativeNC' && nativeNCFails) {
|
|
69
|
+
console.log('large ' + fn.name + ' fails');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
throw ex;
|
|
41
73
|
}
|
|
42
74
|
});
|
|
43
75
|
});
|
package/lib/index.js
CHANGED
|
@@ -92,15 +92,26 @@ function waitForAlive(port) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
function nativeNC(port, input) {
|
|
95
|
-
return spawnSync('nc', [host, port], {
|
|
95
|
+
return spawnSync('nc', [host, port], {
|
|
96
|
+
input: input,
|
|
97
|
+
windowsHide: true,
|
|
98
|
+
maxBuffer: Infinity,
|
|
99
|
+
});
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
function nodeNC(port, input) {
|
|
99
103
|
const src = nodeNetCatSrc(port, input);
|
|
100
104
|
if (src.length < 1000) {
|
|
101
|
-
return spawnSync(process.execPath, ['-e', src], {
|
|
105
|
+
return spawnSync(process.execPath, ['-e', src], {
|
|
106
|
+
windowsHide: true,
|
|
107
|
+
maxBuffer: Infinity,
|
|
108
|
+
});
|
|
102
109
|
} else {
|
|
103
|
-
return spawnSync(process.execPath, [], {
|
|
110
|
+
return spawnSync(process.execPath, [], {
|
|
111
|
+
input: src,
|
|
112
|
+
windowsHide: true,
|
|
113
|
+
maxBuffer: Infinity,
|
|
114
|
+
});
|
|
104
115
|
}
|
|
105
116
|
}
|
|
106
117
|
|
package/lib/test-worker.js
CHANGED