@scrabble-solver/dictionaries 2.7.2 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,4 +6,12 @@ const path = require('path');
6
6
  const rootDirectory = path.resolve(__dirname, '..');
7
7
  const { dictionaries } = require(rootDirectory);
8
8
 
9
- dictionaries.update();
9
+ const updateDictionaries = async () => {
10
+ try {
11
+ await dictionaries.update();
12
+ } catch (error) {
13
+ console.error(error);
14
+ }
15
+ };
16
+
17
+ updateDictionaries();
@@ -47,7 +47,7 @@ var lib_1 = require("./lib");
47
47
  var Dictionaries = /** @class */ (function () {
48
48
  function Dictionaries() {
49
49
  this.cache = new lib_1.LayeredCache();
50
- this.downloadDictionaryProxies = Object.fromEntries(Object.values(types_1.Locale).map(function (locale) { return [locale, lib_1.createAsyncProxy(function () { return lib_1.downloadDictionary(locale); })]; }));
50
+ this.downloadDictionaryProxies = Object.fromEntries(Object.values(types_1.Locale).map(function (locale) { return [locale, (0, lib_1.createAsyncProxy)(function () { return (0, lib_1.downloadDictionary)(locale); })]; }));
51
51
  }
52
52
  Dictionaries.prototype.get = function (locale) {
53
53
  return __awaiter(this, void 0, void 0, function () {
package/build/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -57,8 +57,8 @@ var DiskCache = /** @class */ (function () {
57
57
  if (!this.has(locale)) {
58
58
  return [2 /*return*/, undefined];
59
59
  }
60
- filepath = getDictionaryFilepath_1.default(locale);
61
- return [4 /*yield*/, readFile_1.default(filepath)];
60
+ filepath = (0, getDictionaryFilepath_1.default)(locale);
61
+ return [4 /*yield*/, (0, readFile_1.default)(filepath)];
62
62
  case 1:
63
63
  serialized = _a.sent();
64
64
  trie = trie_1.Trie.deserialize(serialized);
@@ -68,7 +68,7 @@ var DiskCache = /** @class */ (function () {
68
68
  });
69
69
  };
70
70
  DiskCache.prototype.getLastModifiedTimestamp = function (locale) {
71
- var filepath = getDictionaryFilepath_1.default(locale);
71
+ var filepath = (0, getDictionaryFilepath_1.default)(locale);
72
72
  if (!fs_1.default.existsSync(filepath)) {
73
73
  return undefined;
74
74
  }
@@ -76,7 +76,7 @@ var DiskCache = /** @class */ (function () {
76
76
  return stats.mtimeMs;
77
77
  };
78
78
  DiskCache.prototype.has = function (locale) {
79
- var filepath = getDictionaryFilepath_1.default(locale);
79
+ var filepath = (0, getDictionaryFilepath_1.default)(locale);
80
80
  return fs_1.default.existsSync(filepath);
81
81
  };
82
82
  DiskCache.prototype.isStale = function (locale) {
@@ -96,8 +96,8 @@ var DiskCache = /** @class */ (function () {
96
96
  return __generator(this, function (_a) {
97
97
  switch (_a.label) {
98
98
  case 0:
99
- filepath = getDictionaryFilepath_1.default(locale);
100
- return [4 /*yield*/, writeFile_1.default(filepath, trie.serialize())];
99
+ filepath = (0, getDictionaryFilepath_1.default)(locale);
100
+ return [4 /*yield*/, (0, writeFile_1.default)(filepath, trie.serialize())];
101
101
  case 1:
102
102
  _a.sent();
103
103
  return [2 /*return*/];
@@ -51,9 +51,14 @@ var __read = (this && this.__read) || function (o, n) {
51
51
  }
52
52
  return ar;
53
53
  };
54
- var __spread = (this && this.__spread) || function () {
55
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
56
- return ar;
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
57
62
  };
58
63
  var __importDefault = (this && this.__importDefault) || function (mod) {
59
64
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -106,7 +111,7 @@ var LayeredCache = /** @class */ (function () {
106
111
  };
107
112
  LayeredCache.prototype.getLastModifiedLayer = function (locale) {
108
113
  var layers = this.layers.filter(function (cache) { return cache.has(locale); });
109
- var _a = __read(__spread(layers).sort(createCacheTimestampComparator_1.default(locale)), 1), cached = _a[0];
114
+ var _a = __read(__spreadArray([], __read(layers), false).sort((0, createCacheTimestampComparator_1.default)(locale)), 1), cached = _a[0];
110
115
  return cached;
111
116
  };
112
117
  return LayeredCache;
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var createCacheTimestampComparator = function (locale) { return function (a, b) {
4
- var aTimestamp = a.getLastModifiedTimestamp(locale);
5
- var bTimestamp = b.getLastModifiedTimestamp(locale);
6
- if (aTimestamp === bTimestamp) {
7
- return 0;
8
- }
9
- if (typeof aTimestamp === 'undefined') {
10
- return 1;
11
- }
12
- if (typeof bTimestamp === 'undefined') {
13
- return -1;
14
- }
15
- return bTimestamp - aTimestamp;
16
- }; };
3
+ var createCacheTimestampComparator = function (locale) {
4
+ return function (a, b) {
5
+ var aTimestamp = a.getLastModifiedTimestamp(locale);
6
+ var bTimestamp = b.getLastModifiedTimestamp(locale);
7
+ if (aTimestamp === bTimestamp) {
8
+ return 0;
9
+ }
10
+ if (typeof aTimestamp === 'undefined') {
11
+ return 1;
12
+ }
13
+ if (typeof bTimestamp === 'undefined') {
14
+ return -1;
15
+ }
16
+ return bTimestamp - aTimestamp;
17
+ };
18
+ };
17
19
  exports.default = createCacheTimestampComparator;
@@ -48,7 +48,7 @@ var downloadDictionary = function (locale) { return __awaiter(void 0, void 0, vo
48
48
  switch (_a.label) {
49
49
  case 0:
50
50
  logger_1.default.info('downloadDictionary', { locale: locale });
51
- return [4 /*yield*/, word_lists_1.getWordList(locale)];
51
+ return [4 /*yield*/, (0, word_lists_1.getWordList)(locale)];
52
52
  case 1:
53
53
  words = _a.sent();
54
54
  logger_1.default.info('downloadDictionary - success', { locale: locale });
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var path_1 = __importDefault(require("path"));
7
7
  var constants_1 = require("../constants");
8
8
  var getDictionaryFilepath = function (locale) {
9
- return path_1.default.resolve(constants_1.OUTPUT_DIRECTORY, locale + ".txt");
9
+ return path_1.default.resolve(constants_1.OUTPUT_DIRECTORY, "".concat(locale, ".txt"));
10
10
  };
11
11
  exports.default = getDictionaryFilepath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/dictionaries",
3
- "version": "2.7.2",
3
+ "version": "2.8.0",
4
4
  "description": "Scrabble Solver 2 - Dictionaries",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -31,9 +31,9 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@kamilmielnik/trie": "^1.0.3",
34
- "@scrabble-solver/logger": "^2.7.2",
35
- "@scrabble-solver/types": "^2.7.2",
36
- "@scrabble-solver/word-lists": "^2.7.2"
34
+ "@scrabble-solver/logger": "^2.8.0",
35
+ "@scrabble-solver/types": "^2.8.0",
36
+ "@scrabble-solver/word-lists": "^2.8.0"
37
37
  },
38
- "gitHead": "f1a2823c32eedaeff30cf8315e20427574fc97b7"
38
+ "gitHead": "be53b4e8c12e092b9fc180775e700fc0c771f298"
39
39
  }
@@ -3,23 +3,25 @@ import { Locale } from '@scrabble-solver/types';
3
3
 
4
4
  import { Cache } from '../types';
5
5
 
6
- const createCacheTimestampComparator = (locale: Locale) => (a: Cache<Locale, Trie>, b: Cache<Locale, Trie>): number => {
7
- const aTimestamp = a.getLastModifiedTimestamp(locale);
8
- const bTimestamp = b.getLastModifiedTimestamp(locale);
6
+ const createCacheTimestampComparator = (locale: Locale) => {
7
+ return (a: Cache<Locale, Trie>, b: Cache<Locale, Trie>): number => {
8
+ const aTimestamp = a.getLastModifiedTimestamp(locale);
9
+ const bTimestamp = b.getLastModifiedTimestamp(locale);
9
10
 
10
- if (aTimestamp === bTimestamp) {
11
- return 0;
12
- }
11
+ if (aTimestamp === bTimestamp) {
12
+ return 0;
13
+ }
13
14
 
14
- if (typeof aTimestamp === 'undefined') {
15
- return 1;
16
- }
15
+ if (typeof aTimestamp === 'undefined') {
16
+ return 1;
17
+ }
17
18
 
18
- if (typeof bTimestamp === 'undefined') {
19
- return -1;
20
- }
19
+ if (typeof bTimestamp === 'undefined') {
20
+ return -1;
21
+ }
21
22
 
22
- return bTimestamp - aTimestamp;
23
+ return bTimestamp - aTimestamp;
24
+ };
23
25
  };
24
26
 
25
27
  export default createCacheTimestampComparator;