Skip to content

Commit f058c34

Browse files
pimterrysandersn
andauthored
Add types for native-duplexpair (DefinitelyTyped#57482)
* Add types for native-duplexpair * Update tslint.json Co-authored-by: Nathan Shively-Sanders <[email protected]>
1 parent 14f7018 commit f058c34

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

types/native-duplexpair/index.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Type definitions for native-duplexpair 1.0
2+
// Project: https://github.com/tediousjs/native-duplexpair#readme
3+
// Definitions by: Tim Perry <https://github.com/pimterry>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
/// <reference types="node" />
6+
7+
import { Duplex, DuplexOptions } from 'stream';
8+
9+
declare class DuplexPair {
10+
readonly socket1: Duplex;
11+
readonly socket2: Duplex;
12+
13+
constructor(options?: DuplexOptions);
14+
}
15+
16+
export = DuplexPair;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Taken straight from the package README:
2+
import DuplexPair = require('native-duplexpair');
3+
4+
const { socket1, socket2 } = new DuplexPair();
5+
6+
socket1.write('Hi');
7+
console.log(socket2.read()); // => <Buffer 48 69>
8+
9+
const { socket1: encodedSocket1, socket2: encodedSocket2 } = new DuplexPair({ encoding: 'utf8' });
10+
11+
socket1.write('Hi');
12+
console.log(socket2.read()); // => 'Hi'

types/native-duplexpair/tsconfig.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictFunctionTypes": true,
10+
"strictNullChecks": true,
11+
"baseUrl": "../",
12+
"typeRoots": [
13+
"../"
14+
],
15+
"types": [],
16+
"noEmit": true,
17+
"forceConsistentCasingInFileNames": true
18+
},
19+
"files": [
20+
"index.d.ts",
21+
"native-duplexpair-tests.ts"
22+
]
23+
}

types/native-duplexpair/tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "extends": "@definitelytyped/dtslint/dt.json" }

0 commit comments

Comments
 (0)