godprotocol 1.0.841 → 1.0.842

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.
@@ -1,57 +1,54 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
9
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
10
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
11
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
12
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
- var Explorer = /*#__PURE__*/_createClass(function Explorer() {
15
- var _this = this;
16
- _classCallCheck(this, Explorer);
17
- _defineProperty(this, "chain_props", ["blocks"]);
18
- _defineProperty(this, "explore", function (query) {
1
+ class Explorer {
2
+ constructor() {}
3
+
4
+ chain_props = ["blocks"];
5
+
6
+ explore = (query) => {
19
7
  if (!query) return;
8
+
20
9
  if (query.startsWith("{")) query = query.slice(1, -1);
21
10
  query = query.split(":");
11
+
22
12
  query[0] = query[0].split(".");
23
- var q2 = Number(query[1]),
13
+
14
+ let q2 = Number(query[1]),
24
15
  prop;
25
- if (_this.chain_props.includes(query[0][0])) prop = query[0][0];
26
- var obj;
16
+
17
+ if (this.chain_props.includes(query[0][0])) prop = query[0][0];
18
+
19
+ let obj;
27
20
  if (isNaN(q2)) {
28
- var arr = _this[prop || "connections"];
29
- for (var b = 0; b < arr.length; b++) {
30
- var blk = _this.build_block(arr[b]);
21
+ let arr = this[prop || "connections"];
22
+ for (let b = 0; b < arr.length; b++) {
23
+ let blk = this.build_block(arr[b]);
31
24
  if (blk.hash === query[1]) {
32
25
  obj = blk;
33
26
  break;
34
27
  }
35
28
  }
36
29
  } else if (q2 >= 0) {
37
- var _arr = _this[prop || "connections"];
38
- for (var _b = 0; _b < _arr.length; _b++) {
39
- var _blk = _this.build_block(_arr[_b]);
40
- if (_blk.index === q2) {
41
- obj = _blk;
30
+ let arr = this[prop || "connections"];
31
+ for (let b = 0; b < arr.length; b++) {
32
+ let blk = this.build_block(arr[b]);
33
+ if (blk.index === q2) {
34
+ obj = blk;
42
35
  break;
43
36
  }
44
37
  }
45
38
  } else {
46
- obj = _this.build_block(_this[prop || "connections"].slice(q2)[0]);
47
- }
48
- if (!prop) for (var q = 0; q < query[0].length; q++) {
49
- var que = query[0][q];
50
- if (!obj) break;
51
- obj = obj[que];
39
+ obj = this.build_block(this[prop || "connections"].slice(q2)[0]);
52
40
  }
41
+
42
+ if (!prop)
43
+ for (let q = 0; q < query[0].length; q++) {
44
+ let que = query[0][q];
45
+
46
+ if (!obj) break;
47
+ obj = obj[que];
48
+ }
49
+
53
50
  return obj;
54
- });
55
- });
56
- var _default = Explorer;
57
- exports["default"] = _default;
51
+ };
52
+ }
53
+
54
+ export default Explorer;
@@ -1,54 +1,58 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _hash = require("../utils/hash");
8
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
- var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
16
- var _this = this;
17
- _classCallCheck(this, Filesystem);
18
- _defineProperty(this, "parse_path", function (path) {
19
- if (!path || path && !path.includes("/")) return path;
20
- return _this.read(path);
21
- });
22
- _defineProperty(this, "read", function (datapath) {
1
+ import { hash } from "../utils/hash";
2
+
3
+ class Filesystem {
4
+ constructor() {
5
+ this.root = process.env.ROOT || __dirname;
6
+ this.base_address = process.env.BASE_ADDRESS || "Accounts";
7
+ }
8
+
9
+ parse_path = (path) => {
10
+ if (!path || (path && !path.includes("/"))) return path;
11
+
12
+ return this.read(path);
13
+ };
14
+
15
+ read = (datapath) => {
23
16
  if (!datapath) return null;
24
- var type_folder = _this.account.manager.oracle.get(datapath);
17
+
18
+ let type_folder = this.account.manager.oracle.get(datapath);
19
+
25
20
  if (!type_folder) return datapath;
26
- var content;
21
+
22
+ let content;
27
23
  if (type_folder.type === "twain") {
28
24
  content = {};
29
- for (var prop in type_folder.obj) {
30
- var val = type_folder.obj[prop];
31
- content[_this.parse_path(prop)] = _this.parse_path(val);
25
+ for (let prop in type_folder.obj) {
26
+ let val = type_folder.obj[prop];
27
+
28
+ content[this.parse_path(prop)] = this.parse_path(val);
32
29
  }
33
30
  } else if (type_folder.type === "array") {
34
31
  content = [];
35
- type_folder.obj.map(function (t) {
36
- content.push(_this.parse_path(t));
32
+ type_folder.obj.map((t) => {
33
+ content.push(this.parse_path(t));
37
34
  });
38
35
  } else content = type_folder.obj;
36
+
39
37
  return content;
40
- });
41
- _defineProperty(this, "save", function (content, chain, just_obj) {
42
- var addr, obj;
43
- var type = typeof chain === "string" ? chain : _this.get_type(chain);
38
+ };
39
+
40
+ save = (content, chain, just_obj) => {
41
+ let addr, obj;
42
+
43
+ let type = typeof chain === "string" ? chain : this.get_type(chain);
44
+
44
45
  if (type === "array" || type === "string") {
45
46
  obj = [];
46
- for (var curs in content) obj.splice(Number(curs) || -1, 0, content[curs]);
47
+
48
+ for (let curs in content)
49
+ obj.splice(Number(curs) || -1, 0, content[curs]);
50
+
47
51
  if (type === "string") obj = obj.join(" ");
48
52
  } else if (type === "twain") {
49
53
  obj = {};
50
- for (var _curs in content) {
51
- obj[_curs] = content[_curs];
54
+ for (let curs in content) {
55
+ obj[curs] = content[curs];
52
56
  }
53
57
  } else if (type === "number") {
54
58
  obj = Number(content["-1"]);
@@ -56,71 +60,84 @@ var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
56
60
  } else {
57
61
  obj = null;
58
62
  }
63
+
59
64
  if (just_obj) return obj;
60
- addr = "".concat(chain.path, "/").concat((0, _hash.hash)(JSON.stringify(obj)));
61
- _this;
62
- if (obj != null) _this.manager.oracle.write(addr, obj);
63
- _this.manager.oracle.set(addr, {
64
- obj: obj,
65
- type: type
66
- });
65
+
66
+ addr = `${chain.path}/${hash(JSON.stringify(obj))}`;
67
+ this;
68
+ if (obj != null) this.manager.oracle.write(addr, obj);
69
+
70
+ this.manager.oracle.set(addr, { obj, type });
71
+
67
72
  return addr;
68
- });
69
- _defineProperty(this, "data_addr", function (type) {
70
- return "".concat(_this.physical_address, "/Datatypes/").concat(type);
71
- });
72
- _defineProperty(this, "get_type", function (chain) {
73
+ };
74
+
75
+ data_addr = (type) => {
76
+ return `${this.physical_address}/Datatypes/${type}`;
77
+ };
78
+
79
+ get_type = (chain) => {
73
80
  switch (chain.physical_address) {
74
- case _this.data_addr("Number"):
81
+ case this.data_addr(`Number`):
75
82
  return "number";
76
- case _this.data_addr("String"):
83
+ case this.data_addr(`String`):
77
84
  return "string";
78
- case _this.data_addr("Twain"):
85
+ case this.data_addr(`Twain`):
79
86
  return "twain";
80
- case _this.data_addr("Array"):
87
+ case this.data_addr(`Array`):
81
88
  return "array";
82
- case _this.data_addr("Boolean"):
89
+ case this.data_addr(`Boolean`):
83
90
  return "boolean";
84
- case _this.data_addr("Void"):
91
+ case this.data_addr(`Void`):
85
92
  return "void";
86
93
  }
87
- });
88
- _defineProperty(this, "write", function (arg, context) {
89
- var content = context.get_buffer();
94
+ };
95
+
96
+ write = (arg, context) => {
97
+ let content = context.get_buffer();
98
+
90
99
  if (!content || !arg) return;
100
+
91
101
  content[context.cursor] = arg;
92
102
  // console.log(`Writing: ${arg}`);
93
- });
94
- _defineProperty(this, "name_hash", function () {
95
- _this.hash = (0, _hash.hash)(_this.name);
96
- });
97
- _defineProperty(this, "set_paths", function (chain) {
103
+ };
104
+
105
+ name_hash = () => {
106
+ this.hash = hash(this.name);
107
+ };
108
+
109
+ set_paths = (chain) => {
98
110
  if (chain.parent && chain.parent.manager) {
99
111
  chain.path = chain.parent.path;
100
112
  return;
101
113
  }
102
- chain.path = "".concat(chain.parent ? chain.parent.path : _this.base_address, "/").concat(chain.hash);
103
- var fs = _this.manager.oracle.fs;
104
- if (!fs.existsSync("".concat(_this.root, "/").concat(chain.path))) {
105
- fs.mkdirSync("".concat(_this.root, "/").concat(chain.path), {
106
- recursive: true
107
- });
114
+ chain.path = `${chain.parent ? chain.parent.path : this.base_address}/${
115
+ chain.hash
116
+ }`;
117
+
118
+ let fs = this.manager.oracle.fs;
119
+
120
+ if (!fs.existsSync(`${this.root}/${chain.path}`)) {
121
+ fs.mkdirSync(`${this.root}/${chain.path}`, { recursive: true });
108
122
  }
109
- });
110
- _defineProperty(this, "add_chain", function (name, parent) {
111
- var chain = _this.manager.web.get("".concat(parent.physical_address, "/").concat(name));
112
- if (!chain) chain = _this.manager.web.set(parent, name);
123
+ };
124
+
125
+ add_chain = (name, parent) => {
126
+ let chain = this.manager.web.get(`${parent.physical_address}/${name}`);
127
+ if (!chain) chain = this.manager.web.set(parent, name);
128
+
113
129
  return chain;
114
- });
115
- _defineProperty(this, "account_chain", function (account) {
116
- var chain = _this.manager.web.get(account.physical_address);
130
+ };
131
+
132
+ account_chain = (account) => {
133
+ let chain = this.manager.web.get(account.physical_address);
134
+
117
135
  if (!chain) {
118
- chain = _this.manager.web.set(account);
136
+ chain = this.manager.web.set(account);
119
137
  }
138
+
120
139
  return chain;
121
- });
122
- this.root = process.env.ROOT || __dirname;
123
- this.base_address = process.env.BASE_ADDRESS || "Accounts";
124
- });
125
- var _default = Filesystem;
126
- exports["default"] = _default;
140
+ };
141
+ }
142
+
143
+ export default Filesystem;
package/Objects/Frame.js CHANGED
@@ -1,52 +1,47 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _functions = require("../utils/functions");
8
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
10
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
13
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
14
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
16
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
17
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
18
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
19
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
20
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
- var Frame = /*#__PURE__*/_createClass(function Frame(_object, parent) {
22
- var _this = this;
23
- _classCallCheck(this, Frame);
24
- _defineProperty(this, "frame", function (object) {
25
- var frame = new Frame(object, _this);
26
- _this.instructions.push(frame);
27
- _this.children.push(frame);
1
+ import { array_to_nested_objects } from "../utils/functions";
2
+
3
+ class Frame {
4
+ constructor(object, parent) {
5
+ this.parent = parent;
6
+
7
+ this.object = Array.isArray(object)
8
+ ? array_to_nested_objects(object)
9
+ : object;
10
+
11
+ this.children = new Array();
12
+ this.instructions = new Array();
13
+ }
14
+
15
+ frame = (object) => {
16
+ let frame = new Frame(object, this);
17
+
18
+ this.instructions.push(frame);
19
+ this.children.push(frame);
20
+
28
21
  return frame;
29
- });
30
- _defineProperty(this, "to_instruction", function () {
31
- for (var prop in _this.object) {
32
- var val = _this.object[prop];
33
- _this.instructions.push("chain ".concat(prop));
34
- val && _this.frame(val).to_instruction();
35
- _this.instructions.push("pop ".concat(prop));
22
+ };
23
+
24
+ to_instruction = () => {
25
+ for (let prop in this.object) {
26
+ let val = this.object[prop];
27
+ this.instructions.push(`chain ${prop}`);
28
+
29
+ val && this.frame(val).to_instruction();
30
+
31
+ this.instructions.push(`pop ${prop}`);
36
32
  }
37
- });
38
- _defineProperty(this, "flatten_instructions", function () {
39
- var inss = new Array();
40
- for (var i = 0; i < _this.instructions.length; i++) {
41
- var ins = _this.instructions[i];
42
- if (ins instanceof Frame) inss.push.apply(inss, _toConsumableArray(ins.flatten_instructions()));else inss.push(ins);
33
+ };
34
+
35
+ flatten_instructions = () => {
36
+ let inss = new Array();
37
+
38
+ for (let i = 0; i < this.instructions.length; i++) {
39
+ let ins = this.instructions[i];
40
+ if (ins instanceof Frame) inss.push(...ins.flatten_instructions());
41
+ else inss.push(ins);
43
42
  }
44
43
  return inss;
45
- });
46
- this.parent = parent;
47
- this.object = Array.isArray(_object) ? (0, _functions.array_to_nested_objects)(_object) : _object;
48
- this.children = new Array();
49
- this.instructions = new Array();
50
- });
51
- var _default = Frame;
52
- exports["default"] = _default;
44
+ };
45
+ }
46
+
47
+ export default Frame;