执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
const REGISTRATION_KEY = Symbol('@@any-observable/REGISTRATION');
let registered = null;
 
module.exports = (global, loadImplementation) => {
    return (implementation, opts) => {
        opts = opts || {};
 
        // global registration unless explicitly  {global: false} in options (default true)
        const registerGlobal = opts.global !== false;
 
        // Load any previous global registration
        if (registerGlobal && !registered) {
            registered = global[REGISTRATION_KEY];
        }
 
        if (registered && implementation && registered.implementation !== implementation) {
            throw new Error(`any-observable already defined as "${registered.implementation}". You can only register an implementation before the first call to require('any-observable') and an implementation cannot be changed`);
        }
 
        if (!registered) {
            // Use provided implementation
            if (implementation && opts.Observable) {
                registered = {
                    Observable: opts.Observable,
                    implementation
                };
            } else {
                // Require implementation if implementation is specified but not provided
                registered = loadImplementation(implementation || null);
            }
 
            if (registerGlobal) {
                // Register preference globally in case multiple installations
                global[REGISTRATION_KEY] = registered;
            }
        }
 
        return registered;
    };
};