From 345b07af1434abefbb1c037c6d407a6671f8ae75 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Tue, 17 Dec 2019 21:47:05 -0500 Subject: minor parse errors --- README.md | 7 +++++++ socket.js | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e69de29..34d58c3 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,7 @@ +# ywot-clean + +A reconstructed version of `ywot-bot` built off of clean programming principles and a minimal, but fast API. + +# Features + +Currently, `socket.js` provides `Socket` which has a few signals and functions (documented in the code, of course) which allow abstracted interfacing with YWOT. However, certain facilities available in the old version like queuing or fetch division were scrapped in favor of more direct limits due to the unmaintainability of the old style. diff --git a/socket.js b/socket.js index 4a030f5..f5817d4 100644 --- a/socket.js +++ b/socket.js @@ -1,4 +1,6 @@ /* socket.js, a simple wrapper for a YWOT websocket connection */ +const ws = require('ws') +const EventEmitter = require('events'); class retryws extends EventEmitter{ // a wrapper on ws that retries on failure constructor(addr) { @@ -38,7 +40,7 @@ class Socket extends retryws { case 'fetch': this.emit('fetch', message.tiles); break; // The response to a fetch request } - } + }); this.fetch = function(coords){ //coords is a list of quadruplets, each a min/max pair of y/x coordinate pairs which describes at most 1000 tiles //Unchecked for speed @@ -56,12 +58,14 @@ class Socket extends retryws { chars[i].splice(4,0,0); // chars[i].push(i); } - this.send(`{"edits":${JSON.stringify(chars)},"kind":"write"}`; + this.send(`{"edits":${JSON.stringify(chars)},"kind":"write"}`); } this.cursor = function(coords){ //coords is just one quadruplet analagous to fetch; I think the api could handle more, but it's unnecessary for now. - this.send(`"kind":"cursor","positions":[${JSON.stringify(coords)}]}`; + this.send(`"kind":"cursor","positions":[${JSON.stringify(coords)}]}`); } } } + +exports.Socket = Socket; -- cgit