This repository has been archived by the owner on Feb 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
46 lines (43 loc) · 1.58 KB
/
main.js
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
42
43
44
45
46
/**
* @see https://github.com/dmkuznetsov/requirejs-registry
*/
define(function () {
'use strict';
var repository = {};
return {
load: function (name, req, load, config) {
var namespace = name.replace(/\//g, '_');
name = name.replace(/\/+$/, '');
if (repository[namespace] === undefined) {
repository[namespace] = {};
if (config.config !== undefined && config.config[name] !== undefined) {
repository[namespace] = config.config[name];
}
}
var instance = {
'version': '3.0.0',
'namespace': namespace,
'all': function () {
return repository[this.namespace];
},
'get': function (name) {
return repository[this.namespace][name];
},
'set': function (name, value) {
if (name instanceof Object && value === undefined) {
for (var i in name) if (name.hasOwnProperty(i)) {
repository[this.namespace][i] = name[i];
}
return true;
}
repository[this.namespace][name] = value;
return repository[this.namespace][name];
},
'has': function (name) {
return (typeof(repository[this.namespace][name]) != 'undefined');
}
};
load(instance);
}
};
});