-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathstore.js
More file actions
47 lines (36 loc) · 972 Bytes
/
store.js
File metadata and controls
47 lines (36 loc) · 972 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import Core from '../core';
function get_key(key) {
let real_key = key;
if (Core.global.__elixirscript_names__.has(key)) {
real_key = Core.global.__elixirscript_names__.get(key);
}
if (Core.global.__elixirscript_store__.has(real_key)) {
return real_key;
}
throw new Error(`Key ${real_key} not found`);
}
function create(value, name = null) {
const key = new Core.PID();
if (name !== null) {
Core.global.__elixirscript_names__.set(name, key);
}
return Core.global.__elixirscript_store__.set(key, value);
}
function update(key, value) {
const real_key = get_key(key);
return Core.global.__elixirscript_store__.set(real_key, value);
}
function read(key) {
const real_key = get_key(key);
return Core.global.__elixirscript_store__.get(real_key);
}
function remove(key) {
const real_key = get_key(key);
return Core.global.__elixirscript_store__.delete(real_key);
}
export default {
create,
update,
read,
remove,
};