-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackages.js
More file actions
31 lines (28 loc) · 941 Bytes
/
Copy pathpackages.js
File metadata and controls
31 lines (28 loc) · 941 Bytes
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
const Capsulable = require('./capsulable')
/**
* @returns {Packages} instance
*/
module.exports = (Field)=>{
class Packages {
/**
* @param {function} Origin
* @returns {Capsulable} instance
*/
_load(Origin){
if(typeof this[Origin.prototype.constructor.name] != 'undefined')
throw new Error('Class with the same name cannot exist within the same package.')
let capsulated = Capsulable(Origin, Field)
this[Origin.prototype.constructor.name] = capsulated
return capsulated
}
/**
* @param {function} Origin
*/
_unload(Origin){
if(typeof this[Origin.prototype.constructor.name] == 'undefined')
throw new Error('Package does not have a matching class.')
delete(this[Origin.prototype.constructor.name])
}
}
return new Packages()
}