Mercurial > personal > weather-server
annotate weather_server/static/amd/mad.js @ 24:20c8ec56e447
logfile: Pull logfile thread out of Logger.
This enables automatic garbage collection of Logger instances,
since a running thread no longer has a reference to a Logger's self.
It separates exclusive management of logfile state into the
_writer_thread function, which now opens the file and writes it until
it is told to stop by receiving the poison pill.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 10 Nov 2019 23:07:11 -0500 |
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 |