mind-client-js 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,76 @@
1
+ /*###############################################################
2
+ # #
3
+ # Copyright (c) 2026 DnaSoft BV and/or its subsidiaries. #
4
+ # All rights reserved. #
5
+ # #
6
+ # This source code contains the intellectual property #
7
+ # of its copyright holder(s), and is made available #
8
+ # under a license. If you do not know the terms of #
9
+ # the license, please stop and do not read further. #
10
+ # #
11
+ ###############################################################*/
12
+
13
+ const Glvn = require('./glvn')
14
+ const Global = require('./global')
15
+ const utils = require('../utils')
16
+ const errors = require("../errors");
17
+
18
+ class GlvnManagement {
19
+ addName = function (name) {
20
+ if (this.objRoot.connected === false || this.objRoot.loggedIn === false) throw new Error(errors.NOT_LOGGED_IN + 'Not logged in')
21
+
22
+ // validate name
23
+ utils.validateGlvnName(name)
24
+
25
+ // check existance
26
+ const names = Object.keys(this)
27
+ if (names.find(lName => lName === name)) {
28
+ throw new Error(errors.NAME_ALREADY_REGISTERED + 'Name already registered')
29
+ }
30
+
31
+ // create new entry
32
+ this[name] = this._type === 'vars' ? new Glvn : new Global
33
+
34
+ Object.defineProperties(this[name], {
35
+ _type: {
36
+ value: this._type,
37
+ enumerable: false,
38
+ configurable: false
39
+ },
40
+ objRoot: {
41
+ value: this.objRoot,
42
+ enumerable: false,
43
+ configurable: false
44
+ },
45
+ _glvnName: {
46
+ value: name,
47
+ enumerable: false,
48
+ configurable: false
49
+ },
50
+
51
+ })
52
+
53
+ this[name]._init(this[name])
54
+
55
+ // append reader and writer
56
+ utils.appendToObject(this[name], this)
57
+ }
58
+
59
+ removeName = function (name) {
60
+ if (this.objRoot.connected === false || this.objRoot.loggedIn === false) throw new Error(errors.NOT_LOGGED_IN + 'Not logged in')
61
+
62
+ // validate name
63
+ utils.validateGlvnName(name)
64
+
65
+ // check existance
66
+ const names = Object.keys(this)
67
+ if (names.find(lName => lName === name)) {
68
+ delete this[name]
69
+
70
+ } else {
71
+ throw new Error(errors.NAME_NOT_FOUND + 'Name not found')
72
+ }
73
+ }
74
+ }
75
+
76
+ module.exports = GlvnManagement