wspromisify
Advanced tools
Comparing version 2.4.1 to 2.4.2
@@ -37,57 +37,61 @@ { | ||
"scripts": { | ||
"lint": "tslint 'src/**/*.ts'", | ||
"test": "npm run prod:cjs && ava", | ||
"lint": "tslint src/*.ts", | ||
"test": "npm run gentypes && npm run prod:es && ava", | ||
"test:report": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
"test:lazy": "ava", | ||
"dev": "rollup --watch -c", | ||
"gentypes": "dts-bundle-generator --no-check -o dist/bundle.d.ts src/WS.ts", | ||
"dev": "cross-env NODE_ENV=development BUILD=es rollup -c", | ||
"prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c", | ||
"prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c", | ||
"prod": "npm run prod:es && npm run prod:cjs" | ||
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs", | ||
"all": "npm run dev && npm run prod" | ||
}, | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": "./dist/bundle.mjs", | ||
"require": "./dist/bundle.cjs" | ||
} | ||
}, | ||
"ava": { | ||
"files": [ | ||
"./test/specs/*.ts" | ||
"./test/specs/*.js" | ||
], | ||
"serial": true, | ||
"failFast": true, | ||
"timeout": "2m", | ||
"compileEnhancements": false, | ||
"extensions": [ | ||
"ts" | ||
], | ||
"require": [ | ||
"ts-node/register", | ||
"./test/_register.js" | ||
"nodeArguments": [ | ||
"--experimental-specifier-resolution=node" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.12.10", | ||
"@babel/core": "^7.20.12", | ||
"@babel/polyfill": "^7.12.1", | ||
"@babel/register": "^7.12.10", | ||
"@types/node": "^14.14.13", | ||
"@types/ramda": "^0.27.33", | ||
"@types/ws": "^7.4.0", | ||
"ava": "^3.14.0", | ||
"axios": "^0.21.0", | ||
"codecov": "^3.8.1", | ||
"@babel/register": "^7.18.9", | ||
"@rollup/plugin-commonjs": "^23.0.3", | ||
"@rollup/plugin-node-resolve": "^15.0.1", | ||
"@rollup/plugin-replace": "^5.0.1", | ||
"@rollup/plugin-terser": "^0.1.0", | ||
"@types/node": "^18.11.18", | ||
"@types/ws": "^8.5.4", | ||
"ava": "^5.1.1", | ||
"axios": "^1.2.2", | ||
"codecov": "^3.8.3", | ||
"cross-env": "^7.0.3", | ||
"express": "^4.17.1", | ||
"dts-bundle-generator": "^7.1.0", | ||
"express": "^4.18.2", | ||
"nyc": "^15.1.0", | ||
"ramda": "^0.27.1", | ||
"randomatic": "^3.1.1", | ||
"rollup": "^2.35.1", | ||
"rollup-plugin-alias": "^1.5.2", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-resolve-aliases": "^0.3.0", | ||
"rollup-plugin-terser": "7.0.2", | ||
"rollup-plugin-typescript2": "^0.29.0", | ||
"ts-node": "^9.1.1", | ||
"rollup": "^3.10.0", | ||
"rollup-plugin-typescript2": "^0.34.1", | ||
"ts-node": "^10.9.1", | ||
"tslint": "^6.1.3", | ||
"typescript": "^4.1.3", | ||
"ws": "^7.4.1" | ||
"typescript": "^4.9.4", | ||
"ws": "^8.12.0" | ||
}, | ||
"types": "./dist/src/WS.d.ts" | ||
"types": "./dist/bundle.d.ts", | ||
"dependencies": { | ||
"pepka": "^1.0.0-beta.1", | ||
"zipnum": "^1.0.0" | ||
} | ||
} |
@@ -1,6 +0,7 @@ | ||
import commonjs from 'rollup-plugin-commonjs' | ||
import resolve from 'rollup-plugin-node-resolve' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import resolve from '@rollup/plugin-node-resolve' | ||
import typescript from 'rollup-plugin-typescript2' | ||
import { terser } from 'rollup-plugin-terser' | ||
import replace from 'rollup-plugin-replace' | ||
import terser from '@rollup/plugin-terser' | ||
import replace from '@rollup/plugin-replace' | ||
import tsc from 'typescript' | ||
@@ -10,7 +11,9 @@ export default { | ||
output: { | ||
file: process.env.BUILD === 'cjs' ? 'dist/ws.js' : 'dist/ws.esm.js', | ||
format: process.env.BUILD === 'cjs' ? 'cjs' : 'es', | ||
name: 'wspromisify', | ||
file: process.env.NODE_ENV=='development' | ||
? 'dist/bundle.dev.js' | ||
: process.env.BUILD == 'cjs' ? 'dist/bundle.cjs' : 'dist/bundle.mjs', | ||
format: process.env.BUILD == 'cjs' ? 'cjs' : 'es', | ||
name: 'wspromisify' | ||
}, | ||
sourcemap: true, | ||
treeshake: { moduleSideEffects: false }, | ||
plugins: [ | ||
@@ -20,3 +23,3 @@ resolve(), | ||
typescript({ | ||
typescript: require("typescript"), | ||
typescript: tsc, | ||
tsconfig: "./tsconfig.json", | ||
@@ -26,11 +29,15 @@ tsconfigOverride: { | ||
sourceMap: false, | ||
inlineSourceMap: process.env.NODE_ENV==='development' | ||
inlineSourceMap: process.env.NODE_ENV=='development', | ||
module: 'esnext' | ||
} | ||
} | ||
}), | ||
terser(), | ||
process.env.NODE_ENV!='development' && terser(), | ||
replace({ | ||
'process.env.NODE_ENV': JSON.stringify(process.env.BUILD) | ||
preventAssignment: true, | ||
values: { | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) | ||
} | ||
}) | ||
] | ||
} |
import './types' | ||
import { | ||
once, | ||
add_event | ||
} from './utils' | ||
import { once, add_event } from './utils' | ||
@@ -7,0 +4,0 @@ |
@@ -27,3 +27,3 @@ declare namespace wsc { | ||
data_type: DataType | ||
log (event: string, time?: number, message?: any): void | ||
log (event: string, time?: number|null, message?: any): void | ||
log (event: string, message?: any): void | ||
@@ -35,3 +35,3 @@ timer: boolean | ||
lazy: boolean | ||
socket: Socket | ||
socket: Socket | null | ||
adapter: (host: string, protocols?: string[]) => Socket | ||
@@ -38,0 +38,0 @@ encode: (key: string, message: any, config: Config) => any |
@@ -1,3 +0,2 @@ | ||
import packNumber from './packNumber' | ||
import { zipnum } from 'zipnum' | ||
import connectLib from './connectLib' | ||
@@ -7,3 +6,3 @@ import { add_event, sett } from './utils' | ||
import './types' | ||
import { T } from 'ramda' | ||
import { AnyFunc, T } from 'pepka' | ||
@@ -18,11 +17,11 @@ const MAX_32 = 2**31 - 1 | ||
private open = null | ||
private ws = null | ||
private open = false | ||
private ws: wsc.Socket|null = null | ||
// in use by side functions. | ||
private forcibly_closed = false | ||
private reconnect_timeout: NodeJS.Timer = null | ||
private reconnect_timeout: NodeJS.Timer|null = null | ||
private queue = {} | ||
private messages = [] | ||
private onReadyQueue = [] | ||
private onCloseQueue = [] | ||
private messages: any[] = [] | ||
private onReadyQueue: AnyFunc[] = [] | ||
private onCloseQueue: AnyFunc[] = [] | ||
private handlers = <{[event: string]: ((e: any) => void)[]}>{ | ||
@@ -38,3 +37,3 @@ open: [], message: [], close: [], error: [] | ||
private log(event: string, message: any = null, time: number = null): void { | ||
private log(event: string, message: any = null, time: number|null = null): void { | ||
const config = this.config | ||
@@ -81,3 +80,3 @@ if(time !== null) { | ||
return raw | ||
? add_event(this.ws, event_name, _handler) | ||
? add_event(this.ws as wsc.Socket, event_name, _handler) | ||
: this.handlers[event_name].push(_handler) | ||
@@ -91,3 +90,3 @@ } | ||
} else { | ||
this.open = null | ||
this.open = false | ||
this.onCloseQueue.push(() => { | ||
@@ -114,3 +113,3 @@ this.init_flush() | ||
const message_id = packNumber((Math.random()*(MAX_32-10))|0) | ||
const message_id = zipnum((Math.random()*(MAX_32-10))|0) | ||
if(typeof opts.top === 'object') { | ||
@@ -128,6 +127,6 @@ if(opts.top[data_key]) { | ||
if(this.open === true) { | ||
this.ws.send(config.encode(message_id, message_data, config)) | ||
(this.ws as wsc.Socket).send(config.encode(message_id, message_data, config)) | ||
} else if(this.open === false || first_time_lazy) { | ||
this.messages.push({ | ||
send: () => this.ws.send(config.encode(message_id, message_data, config)) | ||
send: () => (this.ws as wsc.Socket).send(config.encode(message_id, message_data, config)) | ||
}) | ||
@@ -150,3 +149,3 @@ if(first_time_lazy) { | ||
'Websocket timeout expired: ': config.timeout, | ||
'for the message': message | ||
'for the message ': message_data | ||
}) | ||
@@ -175,2 +174,2 @@ delete this.queue[message_id] | ||
export default WebSocketClient | ||
export default WebSocketClient |
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"dom", | ||
"esnext" | ||
], | ||
"target":"es2015", | ||
"moduleResolution": "Node", | ||
"lib": [ "esnext", "DOM" ], | ||
"strictNullChecks": true, | ||
"target": "esnext", | ||
"module": "esnext", | ||
"allowJs": false, | ||
"sourceMap": true, | ||
"sourceMap": false, | ||
"emitDecoratorMetadata": true, | ||
@@ -14,10 +14,7 @@ "experimentalDecorators": true, | ||
"noUnusedLocals": false, | ||
"outDir": "./dist/", | ||
"declaration": true, | ||
"rootDir": ".", | ||
"baseUrl": "." | ||
"rootDir": "src", | ||
"baseUrl": ".", | ||
"outDir": "dist/ts" | ||
}, | ||
"include": [ | ||
"./src/WS.ts" | ||
] | ||
"include": [ "src/**/*" ] | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
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
23
Yes
56580
2
33
921
6
2
+ Addedpepka@^1.0.0-beta.1
+ Addedzipnum@^1.0.0
+ Addedpepka@1.6.2(transitive)
+ Addedzipnum@1.0.0(transitive)