mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
[socketio-wildcard] introduce typings
This commit is contained in:
15
types/socketio-wildcard/index.d.ts
vendored
Normal file
15
types/socketio-wildcard/index.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// Type definitions for socketio-wildcard 2.0
|
||||
// Project: https://github.com/hden/socketio-wildcard
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="socket.io" />
|
||||
/// <reference types="socket.io-client" />
|
||||
|
||||
import EventEmitter = NodeJS.EventEmitter;
|
||||
import Socket = SocketIO.Socket;
|
||||
import ClientSocket = SocketIOClient.Socket;
|
||||
|
||||
export = sioWildcard;
|
||||
|
||||
declare function sioWildcard(emitterCtor?: { prototype: typeof EventEmitter.prototype }): (socket: Socket | ClientSocket, next?: (err?: any) => void) => void;
|
||||
24
types/socketio-wildcard/socketio-wildcard-tests.ts
Normal file
24
types/socketio-wildcard/socketio-wildcard-tests.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import ioBuilder = require('socket.io');
|
||||
const io = ioBuilder();
|
||||
import middlewareBuilder = require('socketio-wildcard');
|
||||
const middleware = middlewareBuilder();
|
||||
|
||||
io.use(middleware);
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
socket.on('*', (packet) => {
|
||||
// client.emit('foo', 'bar', 'baz')
|
||||
packet.data === ['foo', 'bar', 'baz'];
|
||||
});
|
||||
});
|
||||
|
||||
io.listen(8000);
|
||||
|
||||
import clientIo = require('socket.io-client');
|
||||
const socket = clientIo('http://localhost');
|
||||
import patchBuilder = require('socketio-wildcard');
|
||||
const patch = patchBuilder(clientIo.Manager);
|
||||
patch(socket);
|
||||
|
||||
socket.on('*', () => {
|
||||
});
|
||||
22
types/socketio-wildcard/tsconfig.json
Normal file
22
types/socketio-wildcard/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"socketio-wildcard-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/socketio-wildcard/tslint.json
Normal file
1
types/socketio-wildcard/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user