Skip to content

Commit

Permalink
use board arg consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
rooklift committed Dec 15, 2021
1 parent df83ef5 commit a597f80
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/75_looker.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ let looker_props = {
return this.all_dbs[db_name];
},

new_entry: function(db_name, fen) { // Creates a new (empty) entry in the database (to be populated elsewhere) and returns it.
new_entry: function(db_name, board) { // Creates a new (empty) entry in the database (to be populated elsewhere) and returns it.

let db = this.get_db(db_name);
let entry = {
type: db_name,
moves: {},
};
db[fen] = entry;
db[board.fen()] = entry;
return entry;
},

Expand All @@ -104,20 +104,20 @@ let looker_props = {
// return the same object (unless it changes of course).

let db = this.get_db(db_name);
if (db) { // Remember get_db() can return null.
if (db) { // Remember get_db() can return null.
let ret = db[board.fen()];
if (ret) {
return ret;
}
}
return null; // I guess we tend to like null over undefined. (Bad habit?)
return null; // I guess we tend to like null over undefined. (Bad habit?)
},

set_ban: function(db_name) {
this.bans[db_name] = performance.now();
},

query_api(query) { // Returns a promise, which is solely used by the caller to attach some cleanup catch/finally()
query_api(query) { // Returns a promise, which is solely used by the caller to attach some cleanup catch/finally()

if (this.lookup(query.db_name, query.board)) { // We already have a result for this board.
return Promise.resolve(); // Consider this case a satisfactory result.
Expand Down Expand Up @@ -163,9 +163,7 @@ let looker_props = {
handle_response_object: function(query, raw_object) {

let board = query.board;
let fen = board.fen();

let o = this.new_entry(query.db_name, fen);
let o = this.new_entry(query.db_name, board);

// If the raw_object is invalid, now's the time to return - after the empty object
// has been stored in the database, so we don't do this lookup again.
Expand Down

0 comments on commit a597f80

Please sign in to comment.