annotate weather_server/static/amd/mad.js @ 26:7def5611895b

Add support for an index page displaying all locations. This seems as good a time as any to declare 0.1.0.
author Paul Fisher <paul@pfish.zone>
date Sun, 10 Nov 2019 23:46:51 -0500
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