Files: e16ebf5c918d09fae0df186c4804a1521397dfb9 / capsStore.js
679 bytesRaw
1 | module.exports = class CapsStore { |
2 | /** |
3 | * The caps store, persistantly stores an actors capabilites. |
4 | * @param {Object} storedCaps |
5 | */ |
6 | constructor (storedCaps) { |
7 | this._storedCaps = storedCaps |
8 | } |
9 | |
10 | /** |
11 | * Stores a cap at a given key |
12 | * @param {String} key |
13 | * @param {Object} cap |
14 | */ |
15 | store (key, cap) { |
16 | // save the port instance |
17 | this._storedCaps[key] = cap |
18 | } |
19 | |
20 | /** |
21 | * gets a cap given its key |
22 | * @param {String} key |
23 | * @return {Object} |
24 | */ |
25 | load (key) { |
26 | const cap = this._storedCaps[key] |
27 | return cap |
28 | } |
29 | |
30 | /** |
31 | * delete cap given its key |
32 | * @param {string} key |
33 | */ |
34 | delete (key) { |
35 | delete this._storedCaps[key] |
36 | } |
37 | } |
38 |
Built with git-ssb-web