js: Extract FoldDict class.

We have ~5 years of proof that we'll probably never
extend Dict with more options.

Breaking the classes into makes both a little faster
(no options to check), and we remove some options
in FoldDict that are never used (from/from_array).

A possible next step is to fine-tune the Dict to use
Map internally.

Note that the TypeScript types for FoldDict are now
more specific (requiring string keys).  Of course,
this isn't really enforced until we convert other
modules to TS.
This commit is contained in:
Steve Howell
2019-12-26 14:34:17 +00:00
committed by Tim Abbott
parent 9cd075ffb1
commit ee3e488e02
17 changed files with 223 additions and 76 deletions

View File

@@ -1,4 +1,5 @@
const Dict = require('./dict').Dict;
const FoldDict = require('./fold_dict').FoldDict;
let user_group_name_dict;
let user_group_by_id_dict;
@@ -6,7 +7,7 @@ let user_group_by_id_dict;
// We have an init() function so that our automated tests
// can easily clear data.
exports.init = function () {
user_group_name_dict = new Dict({fold_case: true});
user_group_name_dict = new FoldDict();
user_group_by_id_dict = new Dict();
};