Skip to content

Commit

Permalink
Did a bit of tidyup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbjensen committed Jan 26, 2020
1 parent e139a85 commit fa21571
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 49 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
- [x] Work out what to do when the message storage limit is reached (technically the browser will throw a QUOTA_EXCEEDED_ERR)
- [ ] Work out how to support sending binary data instead of string data
- [ ] Think about how to support higher-level use cases of WebSockets (rpc, pubsub) via a plugin architecture.
- [ ] TypeScript definitions
- [x] TypeScript definitions
6 changes: 1 addition & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// File Dependencies
import { WS_EVENT_NAMES, DATA_STORAGE_TYPES } from "./lib/constants";
import { serialize, deserialize } from "./lib/dataTransformer";
import {
// validateEvents,
// prefillMissingEvents,
EventListenersInterface
} from "./lib/validators";
import { EventListenersInterface } from "./lib/validators";

interface StorageParams {
storageType: string;
Expand Down
43 changes: 0 additions & 43 deletions src/lib/validators.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,7 @@
// File Dependencies
// import { WS_EVENT_NAMES } from "./constants";

// Interfaces
// Question - can interfaces be embedded as types within other interfaces?
export interface EventListenersInterface {
open: Array<Function>;
message: Array<Function>;
error: Array<Function>;
close: Array<Function>;
[key: string]: Array<Function>;
}

// /**
// * Validates that the event passed in is a valid eventListener event
// * @param {string} event - the event name
// */
// export const validateEvent = (event: string) => {
// if (WS_EVENT_NAMES.indexOf(event) === -1) {
// throw new Error(`${event} is not a valid eventListener event`);
// }
// };

// /**
// * Loops through a list of events in the eventListeners object to validate them
// * @param {object} eventListeners
// */
// export const validateEvents = (eventListeners: object) => {
// const eventList = Object.keys(eventListeners);
// eventList.forEach(validateEvent);
// };

// /**
// * Makes sure that any eventListeners object which might miss an event will have them prefilled in
// * @param {object} eventListeners - The eventListeners object parameter
// * @returns {object} The eventListeners object parameter, with any missing events prefilled in
// */
// export const prefillMissingEvents = (
// eventListeners: EventListenersInterface = {
// open: [],
// close: [],
// error: [],
// message: []
// }
// ) => {
// WS_EVENT_NAMES.forEach((eventName: string) => {
// if (!eventListeners[eventName]) eventListeners[eventName] = [];
// });
// return eventListeners;
// };

0 comments on commit fa21571

Please sign in to comment.