Skip to content

Commit

Permalink
Abstact key prefix to variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kim committed Jun 9, 2020
1 parent 1bcc5db commit 208d9ba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/wordnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let fsp = require('fs').promises;
module.exports = {};

const SPACE_CHAR = ' ';
const KEY_PREFIX = '@__';
const EXTENSIONS_MAP = {
'adj': 'a',
'adv': 'r',
Expand All @@ -25,7 +26,7 @@ let _data = {};

// Utilities.
function toNumber(str, radix = 10) { return parseInt(str, radix) }
function getKey(word) { return `@__${word}` }
function getKey(word) { return `${KEY_PREFIX}${word}` }


/**
Expand Down Expand Up @@ -54,7 +55,7 @@ module.exports.init = async function() {
*/
module.exports.list = function() {
return Object.keys(_index).map(function(key) {
return key.substring(3).replace(/_/g, SPACE_CHAR);
return key.substring(KEY_PREFIX.length).replace(/_/g, SPACE_CHAR);
});
}

Expand Down

0 comments on commit 208d9ba

Please sign in to comment.