annotate weather_server/static/amd/mad.js @ 31:9bc3687e1e5e

logfile: Add an index, and don't keep everything in RAM. - Adds index BSON file, updated upon writing. - Limits amount of data in RAM. - Gracefully handles writes that don't update index.
author Paul Fisher <paul@pfish.zone>
date Tue, 07 Jul 2020 19:51:30 -0400
parents 47987502bf4c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
1 "use strict";
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
2 class MADRegistry {
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
3 constructor() {
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
4 this.mods = new Map();
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
5 }
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
6 define(name, deps, factory) {
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
7 this.mods.set(name, { deps, factory, exports: null });
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
8 }
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
9 require(dep, srcMod) {
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
10 if (dep === 'require') {
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
11 return (child) => this.require(child, srcMod);
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
12 }
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
13 if (dep === 'exports') {
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
14 if (!srcMod)
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
15 throw new Error('Internal consistency error.');
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
16 return srcMod.exports;
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
17 }
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
18 const mod = this.mods.get(dep);
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
19 if (!mod)
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
20 throw new Error('Undefined module.');
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
21 if (mod.exports)
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
22 return mod.exports;
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
23 mod.exports = {};
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
24 const deps = mod.deps.map(child => this.require(child, mod));
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
25 mod.factory(...deps);
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
26 return mod.exports;
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
27 }
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
28 install(to) {
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
29 to['define'] =
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
30 (name, deps, factory) => this.define(name, deps, factory);
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
31 to['require'] = (dep) => this.require(dep);
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
32 }
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
33 }
47987502bf4c Add graph, make it public, and bump the version.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
34 //# sourceMappingURL=mad.js.map