Skip to content

Commit 3515e81

Browse files
committed
chore: Add missings docs and fix lint
1 parent ace0e1c commit 3515e81

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Here are listed all methods implemented in `react-native-tcp-socket` that imitat
316316

317317
* **[`net.connect(options[, callback])`](#netcreateconnection----omit-in-toc)**
318318
* **[`net.createConnection(options[, callback])`](#netcreateconnection----omit-in-toc)**
319-
* [`net.createServer(connectionListener)`](https://nodejs.org/api/net.html#net_net_createserver_options_connectionlistener)
319+
* [`net.createServer([options][, connectionListener])`](https://nodejs.org/api/net.html#net_net_createserver_options_connectionlistener)
320320
* [`net.isIP(input)`](https://nodejs.org/api/net.html#netisipinput)
321321
* [`net.isIPv4(input)`](https://nodejs.org/api/net.html#netisipv4input)
322322
* [`net.isIPv6(input)`](https://nodejs.org/api/net.html#netisipv6input)
@@ -409,8 +409,8 @@ Here are listed all methods implemented in `react-native-tcp-socket` that imitat
409409
#### TLSSocket
410410
* **Methods:**
411411
* All methods from [`Socket`](#socket)
412-
* [`getCertificate()`](https://nodejs.org/api/tls.html#tlssocketgetcertificate) _Android only_
413-
* **[`getPeerCertificate()`](https://nodejs.org/api/tls.html#tlssocketgetpeercertificatedetailed)** _Android only_
412+
* [`getCertificate()`](https://nodejs.org/api/tls.html#tlssocketgetcertificate)
413+
* **[`getPeerCertificate()`](https://nodejs.org/api/tls.html#tlssocketgetpeercertificatedetailed)**
414414
* **Properties:**
415415
* All properties from [`Socket`](#socket)
416416
* **Events:**
@@ -420,15 +420,15 @@ Here are listed all methods implemented in `react-native-tcp-socket` that imitat
420420
##### `tls.connectTLS()` <!-- omit in toc -->
421421
`tls.connectTLS(options[, callback])` creates a TLS socket connection using the given `options`. The `options` parameter must be an `object` with the following properties:
422422

423-
| Property | Type | iOS/macOS | Android | Description |
424-
| ----------------- | ---------- | :-------: | :-----: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
425-
| `ca` | `<import>` ||| CA file (.pem format) to trust. If `null`, it will use the device's default SSL trusted list. Useful for self-signed certificates. _Check the [documentation](#self-signed-ssl-only-available-for-react-native--060) for generating such file_. **Default**: `null`. |
426-
| `key` | `<import>` | || Private key file (.pem format). _Check the [documentation](#self-signed-ssl-only-available-for-react-native--060) for generating such file_. |
427-
| `cert` | `<import>` | || Public certificate file (.pem format). _Check the [documentation](#self-signed-ssl-only-available-for-react-native--060) for generating such file_. |
428-
| `androidKeyStore` | `<string>` ||| Android KeyStore alias. |
429-
| `certAlias` | `<string>` | || Android KeyStore certificate alias. |
430-
| `keyAlias` | `<string>` | || Android KeyStore private key alias. |
431-
| `...` | `<any>` ||| Any other [`socket.connect()`](#netcreateconnection----omit-in-toc) options not already listed. |
423+
| Property | Type | iOS/macOS | Android | Description |
424+
| ----------------- | ---------------------- | :-------: | :-----: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
425+
| `ca` | `<import>` ||| CA file (.pem format) to trust. If `null`, it will use the device's default SSL trusted list. Useful for self-signed certificates. _Check the [documentation](#self-signed-ssl-only-available-for-react-native--060) for generating such file_. **Default**: `null`. |
426+
| `key` | `<import> \| <string>` | || Private key file (.pem format). _Check the [documentation](#self-signed-ssl-only-available-for-react-native--060) for generating such file_. |
427+
| `cert` | `<import> \| <string>` | || Public certificate file (.pem format). _Check the [documentation](#self-signed-ssl-only-available-for-react-native--060) for generating such file_. |
428+
| `androidKeyStore` | `<string>` ||| Android KeyStore alias. |
429+
| `certAlias` | `<string>` | || Android KeyStore certificate alias. |
430+
| `keyAlias` | `<string>` | || Android KeyStore private key alias. |
431+
| `...` | `<any>` ||| Any other [`socket.connect()`](#netcreateconnection----omit-in-toc) options not already listed. |
432432

433433
#### TLSServer
434434
__Note__: The TLS server is named `Server` in Node's tls, but it is named `TLSServer` in `react-native-tcp-socket` in order to avoid confusion with the [`Server`](#server) class.

__tests__/index.test.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,39 @@ test('create-client', () => {
1212
// interface: "wifi"
1313
};
1414

15-
const socket = net.createConnection(options, () => { });
15+
const socket = net.createConnection(options, () => {});
1616
expect(socket).toBeInstanceOf(net.Socket);
1717
});
1818

1919
test('create-server', () => {
20-
const server = net.createServer(() => { });
20+
const server = net.createServer(() => {});
2121
expect(server).toBeInstanceOf(net.Server);
2222
});
2323

2424
test('create-server-with-options', () => {
25-
const server = net.createServer({
26-
noDelay: true,
27-
keepAlive: true
28-
}, () => {
29-
console.info('server started')
30-
});
25+
const server = net.createServer(
26+
{
27+
noDelay: true,
28+
keepAlive: true,
29+
},
30+
() => {
31+
console.info('server started');
32+
}
33+
);
3134
expect(server).toBeInstanceOf(net.Server);
3235
});
3336

3437
test('create-server-options-no-calback', () => {
3538
const server = net.createServer({
3639
noDelay: true,
37-
keepAlive: true
40+
keepAlive: true,
3841
});
3942
server.on('connection', () => {
4043
console.info('connection received');
4144
});
45+
expect(server).toBeInstanceOf(net.Server);
4246
});
4347

44-
4548
test('isIP', () => {
4649
expect(net.isIP('127.9.8.9')).toBe(4);
4750
expect(net.isIP('127.9.8..')).toBe(0);

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import TLSSocket from './TLSSocket';
1616

1717
/**
1818
* Creates a new TCP server.
19-
*
19+
*
2020
* @param {ServerOptions | ((socket: Socket) => void)} [options] An options object or a connection listener
2121
* @param {(socket: Socket) => void} [connectionListener] A listener for the 'connection' event
2222
* @returns {Server}

0 commit comments

Comments
 (0)