Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

newsware

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

newsware - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

3

lib/api.d.ts
import { Filter, News } from "./types";
import { CloseEvent, ErrorEvent } from "isomorphic-ws";
export declare class Api {

@@ -6,3 +7,3 @@ private apiKey;

constructor(apiKey: string, host?: string);
subscribe: (filter: Filter, callback: (news: News) => void, errorCallback?: ((event: Event) => void) | undefined, closeCallback?: ((event: Event) => void) | undefined) => void;
subscribe: (filter: Filter, callback: (news: News) => void, errorCallback?: ((errorEvent: ErrorEvent) => void) | undefined, closeCallback?: ((closeEvent: CloseEvent) => void) | undefined) => void;
}

@@ -5,2 +5,3 @@ "use strict";

const types_1 = require("./types");
const isomorphic_ws_1 = require("isomorphic-ws");
class Api {

@@ -15,6 +16,6 @@ constructor(apiKey, host = types_1.ApiHost.Production) {

});
const socket = new WebSocket(`ws://${this.host}/v1/ws/news&${urlParams.toString()}`);
const socket = new isomorphic_ws_1.default(`ws://${this.host}/v1/ws/news&${urlParams.toString()}`);
socket.onmessage = (event) => {
console.log("Message received: ", event);
callback(JSON.parse(event.data));
console.log("Message received: ", event.data);
callback(JSON.parse(event.data.toString()));
};

@@ -21,0 +22,0 @@ socket.onerror = (event) => {

{
"name": "newsware",
"version": "0.1.5",
"version": "0.1.6",
"description": "Typescript client for interacting with the Newsware API",

@@ -36,4 +36,9 @@ "main": "lib/index.js",

"devDependencies": {
"@types/ws": "^8.5.5",
"typescript": "^5.1.3"
},
"dependencies": {
"isomorphic-ws": "^5.0.0",
"ws": "^8.13.0"
}
}
import {ApiHost, Filter, News} from "./types";
import Websocket, {CloseEvent, ErrorEvent, MessageEvent} from "isomorphic-ws"

@@ -13,4 +14,4 @@ export class Api {

callback: (news: News) => void,
errorCallback?: (event: Event) => void,
closeCallback?: (event: Event) => void
errorCallback?: (errorEvent: ErrorEvent) => void,
closeCallback?: (closeEvent: CloseEvent) => void
) => {

@@ -21,10 +22,10 @@ const urlParams = new URLSearchParams({

})
const socket = new WebSocket(`ws://${this.host}/v1/ws/news&${urlParams.toString()}`)
const socket = new Websocket(`ws://${this.host}/v1/ws/news&${urlParams.toString()}`)
socket.onmessage = (event) => {
console.log("Message received: ", event)
callback(JSON.parse(event.data) as News)
socket.onmessage = (event: MessageEvent) => {
console.log("Message received: ", event.data)
callback(JSON.parse(event.data.toString()) as News)
}
socket.onerror = (event) => {
socket.onerror = (event: ErrorEvent) => {
console.log("Websocket error: ", event)

@@ -35,3 +36,3 @@ if (!errorCallback) this.subscribe(filter, callback, errorCallback)

socket.onclose = (event) => {
socket.onclose = (event: CloseEvent) => {
console.log("Connection closed")

@@ -38,0 +39,0 @@ if (closeCallback) closeCallback(event)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc