summaryrefslogtreecommitdiff
path: root/src/content/dynamicNS.js
blob: f865e8b88239d31085347ebe6a52fcdc9e6fdf8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';

// ensure the order which manifest scripts and dynamically registered scripts
// are executed in doesn't matter for initialization, by using a stub.

if (!this.ns) {
  let deferredSetup = null;
  let nsStub = this.ns = {
    config: {},
    setup(CURRENT, MARKER) {
      deferredSetup = [CURRENT, MARKER];
    },
    merge: ns => {
      ns.config = Object.assign(ns.config, nsStub.config);
      this.ns = ns;
      if (deferredSetup) {
        ns.setup(...deferredSetup);
      }
    }
  }
}