summaryrefslogtreecommitdiff
path: root/src/content/dynamicNS.js
blob: 51a27015269cbf31a9e5e48746997f291f7e7164 (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(permissions, MARKER) {
      deferredSetup = [permissions, MARKER];
    },
    merge: ns => {
      ns.config = Object.assign(ns.config, nsStub.config);
      this.ns = ns;
      if (deferredSetup) {
        ns.setup(...deferredSetup);
      }
    }
  }
}