Mercurial > personal > weather-server
annotate weather_server/static/amd/mad.js @ 21:beb42c835c52
Make weather server handle arbitrary data:
- Make logfile record arbitrary BSONs
- Make server handlers OK with same
- Make location type a normal class rather than attrs;
have it handle its own logger.
- Bump version number.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sat, 19 Oct 2019 18:40:48 -0400 |
parents | 47987502bf4c |
children |
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 |