|
1 | | -"use strict"; |
| 1 | +import net from "net"; |
2 | 2 |
|
3 | | -var net = require("net"); |
4 | | - |
5 | | -exports.bufferSizeImpl = function (socket) { |
| 3 | +export function bufferSizeImpl(socket) { |
6 | 4 | return socket.bufferSize; |
7 | | -}; |
| 5 | +} |
8 | 6 |
|
9 | | -exports.bytesReadImpl = function (socket) { |
| 7 | +export function bytesReadImpl(socket) { |
10 | 8 | return socket.bytesRead; |
11 | | -}; |
| 9 | +} |
12 | 10 |
|
13 | | -exports.bytesWrittenImpl = function (socket) { |
| 11 | +export function bytesWrittenImpl(socket) { |
14 | 12 | return socket.bytesWritten; |
15 | | -}; |
| 13 | +} |
16 | 14 |
|
17 | | -exports.connectImpl = function (socket, options, callback) { |
| 15 | +export function connectImpl(socket, options, callback) { |
18 | 16 | socket.connect(options, callback); |
19 | | -}; |
| 17 | +} |
20 | 18 |
|
21 | | -exports.connectingImpl = function (socket) { |
| 19 | +export function connectingImpl(socket) { |
22 | 20 | return socket.connecting; |
23 | | -}; |
| 21 | +} |
24 | 22 |
|
25 | | -exports.createConnectionImpl = net.createConnection; |
| 23 | +export const createConnectionImpl = net.createConnection; |
26 | 24 |
|
27 | | -exports.destroyImpl = function (socket, err) { |
| 25 | +export function destroyImpl(socket, err) { |
28 | 26 | socket.destroy(err); |
29 | | -}; |
| 27 | +} |
30 | 28 |
|
31 | | -exports.destroyedImpl = function (socket) { |
| 29 | +export function destroyedImpl(socket) { |
32 | 30 | return socket.destroyed; |
33 | | -}; |
| 31 | +} |
34 | 32 |
|
35 | | -exports.endImpl = function (socket, buffer, callback) { |
| 33 | +export function endImpl(socket, buffer, callback) { |
36 | 34 | socket.end(buffer, null, callback); |
37 | | -}; |
| 35 | +} |
38 | 36 |
|
39 | | -exports.endStringImpl = function (socket, str, encoding, callback) { |
| 37 | +export function endStringImpl(socket, str, encoding, callback) { |
40 | 38 | socket.end(str, encoding, callback); |
41 | | -}; |
| 39 | +} |
42 | 40 |
|
43 | | -exports.localAddressImpl = function (socket) { |
| 41 | +export function localAddressImpl(socket) { |
44 | 42 | return socket.localAddress; |
45 | | -}; |
| 43 | +} |
46 | 44 |
|
47 | | -exports.localPortImpl = function (socket) { |
| 45 | +export function localPortImpl(socket) { |
48 | 46 | return socket.localPort; |
49 | | -}; |
| 47 | +} |
50 | 48 |
|
51 | | -exports.onDataImpl = function (socket, callbackBuffer, callbackString) { |
| 49 | +export function onDataImpl(socket, callbackBuffer, callbackString) { |
52 | 50 | socket.on("data", function (data) { |
53 | 51 | if (typeof data === "string") { |
54 | 52 | callbackString(data); |
55 | 53 | } else { |
56 | 54 | callbackBuffer(data); |
57 | 55 | } |
58 | 56 | }); |
59 | | -}; |
| 57 | +} |
60 | 58 |
|
61 | | -exports.onImpl = function (event, socket, callback) { |
| 59 | +export function onImpl(event, socket, callback) { |
62 | 60 | socket.on(event, callback); |
63 | | -}; |
| 61 | +} |
64 | 62 |
|
65 | | -exports.pauseImpl = function (socket) { |
| 63 | +export function pauseImpl(socket) { |
66 | 64 | socket.pause(); |
67 | | -}; |
| 65 | +} |
68 | 66 |
|
69 | | -exports.pendingImpl = function (socket) { |
| 67 | +export function pendingImpl(socket) { |
70 | 68 | return socket.pending; |
71 | | -}; |
| 69 | +} |
72 | 70 |
|
73 | | -exports.remoteAddressImpl = function (socket) { |
| 71 | +export function remoteAddressImpl(socket) { |
74 | 72 | return socket.remoteAddress; |
75 | | -}; |
| 73 | +} |
76 | 74 |
|
77 | | -exports.remoteFamilyImpl = function (socket) { |
| 75 | +export function remoteFamilyImpl(socket) { |
78 | 76 | return socket.remoteFamily; |
79 | | -}; |
| 77 | +} |
80 | 78 |
|
81 | | -exports.remotePortImpl = function (socket) { |
| 79 | +export function remotePortImpl(socket) { |
82 | 80 | return socket.remotePort; |
83 | | -}; |
| 81 | +} |
84 | 82 |
|
85 | | -exports.resumeImpl = function (socket) { |
| 83 | +export function resumeImpl(socket) { |
86 | 84 | socket.resume(); |
87 | | -}; |
| 85 | +} |
88 | 86 |
|
89 | | -exports.setEncodingImpl = function (socket, encoding) { |
| 87 | +export function setEncodingImpl(socket, encoding) { |
90 | 88 | socket.setEncoding(encoding); |
91 | | -}; |
| 89 | +} |
92 | 90 |
|
93 | | -exports.setKeepAliveImpl = function (socket, enable, initialDelay) { |
| 91 | +export function setKeepAliveImpl(socket, enable, initialDelay) { |
94 | 92 | socket.setKeepAlive(enable, initialDelay); |
95 | | -}; |
| 93 | +} |
96 | 94 |
|
97 | | -exports.setNoDelayImpl = function (socket, noDelay) { |
| 95 | +export function setNoDelayImpl(socket, noDelay) { |
98 | 96 | socket.setNoDelay(noDelay); |
99 | | -}; |
| 97 | +} |
100 | 98 |
|
101 | | -exports.setTimeoutImpl = function (socket, timeout, callback) { |
| 99 | +export function setTimeoutImpl(socket, timeout, callback) { |
102 | 100 | socket.setTimeout(timeout, callback); |
103 | | -}; |
| 101 | +} |
104 | 102 |
|
105 | | -exports.writeImpl = function (socket, buffer, callback) { |
| 103 | +export function writeImpl(socket, buffer, callback) { |
106 | 104 | return socket.write(buffer, null, callback); |
107 | | -}; |
| 105 | +} |
108 | 106 |
|
109 | | -exports.writeStringImpl = function (socket, str, encoding, callback) { |
| 107 | +export function writeStringImpl(socket, str, encoding, callback) { |
110 | 108 | return socket.write(str, encoding, callback); |
111 | | -}; |
| 109 | +} |
0 commit comments