koa-ws-socket
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -215,13 +215,18 @@ import { Server } from 'ws'; | ||
Socket.prototype.invokeHandler = function (handler, ctx, message) { | ||
var _this = this; | ||
if (!this.middleware) { | ||
handler(ctx, message); | ||
return; | ||
} | ||
this.middleware(ctx, function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
handler(ctx, message); | ||
return [2 /*return*/]; | ||
switch (_a.label) { | ||
case 0: | ||
if (!!this.middleware) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, handler(ctx, message)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
case 2: return [4 /*yield*/, this.middleware(ctx, function () { return handler(ctx, message); })]; | ||
case 3: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
}; | ||
@@ -228,0 +233,0 @@ return Socket; |
@@ -220,13 +220,18 @@ (function (global, factory) { | ||
Socket.prototype.invokeHandler = function (handler, ctx, message) { | ||
var _this = this; | ||
if (!this.middleware) { | ||
handler(ctx, message); | ||
return; | ||
} | ||
this.middleware(ctx, function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
handler(ctx, message); | ||
return [2 /*return*/]; | ||
switch (_a.label) { | ||
case 0: | ||
if (!!this.middleware) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, handler(ctx, message)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
case 2: return [4 /*yield*/, this.middleware(ctx, function () { return handler(ctx, message); })]; | ||
case 3: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
}; | ||
@@ -233,0 +238,0 @@ return Socket; |
@@ -18,3 +18,3 @@ /// <reference types="koa-compose" /> | ||
on(event: string, handler: EventHandler): void; | ||
invokeHandler(handler: EventHandler, ctx: SocketContext, message: any): void; | ||
invokeHandler(handler: EventHandler, ctx: SocketContext, message: any): Promise<void>; | ||
} |
@@ -1,1 +0,1 @@ | ||
{"name":"koa-ws-socket","version":"1.0.1","description":"Attaches ws sockets to koa using koa-style middleware","files":["dist"],"main":"dist/koa-ws-socket.umd.js","module":"dist/koa-ws-socket.es5.js","types":"dist/types/index.d.ts","repository":"https://github.com/pbomb/koa-ws-socket.git","author":"Matt Parrish <matt.r.parrish@gmail.com>","engines":{"node":">=6.0.0"},"license":"MIT","private":false,"scripts":{"add-contributor":"kcd-scripts contributors add","prebuild":"rimraf dist && rimraf compiled","build":"rollup --config rollup.config.ts --no-clean","lint":"tslint -p . -c tslint.json -e **/node_modules/**/* -e **/typings/**/* **/*.ts","test":"kcd-scripts test","test:cover":"kcd-scripts test --coverage","test:update":"npm run test:cover -s -- --updateSnapshot","test:build":"kcd-scripts test --no-watch","build-and-test":"npm run build -s && npm run test:build -s","validate":"kcd-scripts validate lint,build-and-test,test:cover","precommit":"kcd-scripts precommit","prettier":"prettier --write \"**/*.ts\" \"**/*.js{,on}\"","tsc":"tsc"},"devDependencies":{"@types/jest":"21.1.5","@types/koa":"2.0.40","@types/koa-compose":"3.2.2","@types/ws":"3.2.0","kcd-scripts":"0.27.2","koa":"2.4.1","prettier":"1.8.2","rimraf":"2.6.2","rollup":"0.51.2","rollup-plugin-commonjs":"8.2.6","rollup-plugin-node-resolve":"3.0.0","rollup-plugin-sourcemaps":"0.4.2","rollup-plugin-typescript2":"0.8.0","ts-jest":"^22.0.0","tslint":"5.8.0","typescript":"2.6.1","ws":"3.3.1"},"peerDependencies":{"koa":">=2","ws":">=3"},"dependencies":{"base64id":"^1.0.0","koa-compose":"^4.0.0"},"release":{"analyzeCommits":{"releaseRules":[{"type":"refactor","release":"patch"}]}}} | ||
{"name":"koa-ws-socket","version":"1.0.2","description":"Attaches ws sockets to koa using koa-style middleware","files":["dist"],"main":"dist/koa-ws-socket.umd.js","module":"dist/koa-ws-socket.es5.js","types":"dist/types/index.d.ts","repository":"https://github.com/pbomb/koa-ws-socket.git","author":"Matt Parrish <matt.r.parrish@gmail.com>","engines":{"node":">=6.0.0"},"license":"MIT","private":false,"scripts":{"add-contributor":"kcd-scripts contributors add","prebuild":"rimraf dist && rimraf compiled","build":"rollup --config rollup.config.ts --no-clean","lint":"tslint -p . -c tslint.json -e **/node_modules/**/* -e **/typings/**/* **/*.ts","test":"kcd-scripts test","test:cover":"kcd-scripts test --coverage","test:update":"npm run test:cover -s -- --updateSnapshot","test:build":"kcd-scripts test --no-watch","build-and-test":"npm run build -s && npm run test:build -s","validate":"kcd-scripts validate lint,build-and-test,test:cover","precommit":"kcd-scripts precommit","prettier":"prettier --write \"**/*.ts\" \"**/*.js{,on}\"","tsc":"tsc"},"devDependencies":{"@types/jest":"21.1.5","@types/koa":"2.0.40","@types/koa-compose":"3.2.2","@types/ws":"3.2.0","kcd-scripts":"0.27.2","koa":"2.4.1","prettier":"1.8.2","rimraf":"2.6.2","rollup":"0.51.2","rollup-plugin-commonjs":"8.2.6","rollup-plugin-node-resolve":"3.0.0","rollup-plugin-sourcemaps":"0.4.2","rollup-plugin-typescript2":"0.8.0","ts-jest":"^22.0.0","tslint":"5.8.0","typescript":"2.6.1","ws":"3.3.1"},"peerDependencies":{"koa":">=2","ws":">=3"},"dependencies":{"base64id":"^1.0.0","koa-compose":"^4.0.0"},"release":{"analyzeCommits":{"releaseRules":[{"type":"refactor","release":"patch"}]}}} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88531
692