1 | 'use strict';
|
2 |
|
3 | var Application = require('./core/Application');
|
4 | var package_json = require('./package.json');
|
5 |
|
6 | var _applications_cache = {};
|
7 | var _default_app_key = null;
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | var IFNode = function(options) {
|
16 | if(_default_app_key && !options) {
|
17 | return _applications_cache[_default_app_key];
|
18 | }
|
19 |
|
20 | if(typeof options === 'string') {
|
21 | return _applications_cache[options];
|
22 | }
|
23 |
|
24 | var app = new Application(options);
|
25 | var key = app.alias || app.id;
|
26 |
|
27 | if(!_default_app_key) {
|
28 | _default_app_key = key;
|
29 | }
|
30 |
|
31 | _applications_cache[key] = app;
|
32 |
|
33 | return app;
|
34 | };
|
35 |
|
36 | Object.defineProperty(IFNode, 'VERSION', {
|
37 | value: package_json.version
|
38 | });
|
39 |
|
40 | module.exports = IFNode;
|