godprotocol 1.0.796 → 1.0.798

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.
Files changed (61) hide show
  1. package/.babelrc +3 -0
  2. package/Index.js +8 -21
  3. package/Loader_sequence/main.js +259 -358
  4. package/Objects/Account.js +178 -337
  5. package/Objects/Block.js +53 -58
  6. package/Objects/Blockweb.js +27 -34
  7. package/Objects/Chain.js +115 -118
  8. package/Objects/Explorer.js +30 -37
  9. package/Objects/Filesystem.js +95 -80
  10. package/Objects/Frame.js +43 -48
  11. package/Objects/Manager.js +68 -77
  12. package/Objects/Opcodes.js +32 -97
  13. package/Objects/Oracle.js +23 -39
  14. package/Objects/Virtual_machine.js +125 -261
  15. package/build/Account.js +162 -0
  16. package/build/Block.js +65 -0
  17. package/build/Blockweb.js +36 -0
  18. package/build/Chain.js +119 -0
  19. package/build/Explorer.js +47 -0
  20. package/build/Filesystem.js +127 -0
  21. package/build/Frame.js +52 -0
  22. package/build/Index.js +15 -0
  23. package/build/Manager.js +99 -0
  24. package/build/Opcodes.js +39 -0
  25. package/build/Oracle.js +42 -0
  26. package/build/Virtual_machine.js +128 -0
  27. package/build/add.js +41 -0
  28. package/build/create_server.js +119 -0
  29. package/build/framer.js +57 -0
  30. package/build/functions.js +82 -0
  31. package/build/hash.js +14 -0
  32. package/build/jmp.js +19 -0
  33. package/build/main.js +283 -0
  34. package/build/opcodes.js +42 -0
  35. package/build/privacy.js +27 -0
  36. package/build/services.js +50 -0
  37. package/build/std.js +11 -0
  38. package/framer.js +39 -31
  39. package/opcodes/add.js +14 -40
  40. package/opcodes/jmp.js +10 -14
  41. package/opcodes/std.js +5 -9
  42. package/opcodes.js +25 -29
  43. package/package.json +3 -3
  44. package/readme.md +71 -95
  45. package/types/Account.d.ts +73 -0
  46. package/types/Block.d.ts +22 -0
  47. package/types/Blockweb.d.ts +14 -0
  48. package/types/Chain.d.ts +35 -0
  49. package/types/Explorer.d.ts +9 -0
  50. package/types/Filesystem.d.ts +23 -0
  51. package/types/Frame.d.ts +14 -0
  52. package/types/Manager.d.ts +21 -0
  53. package/types/Opcodes.d.ts +11 -0
  54. package/types/Oracle.d.ts +17 -0
  55. package/types/Virtual_machine.d.ts +20 -0
  56. package/types/index.d.ts +4 -0
  57. package/utils/create_server.js +65 -622
  58. package/utils/functions.js +31 -43
  59. package/utils/hash.js +10 -11
  60. package/utils/privacy.js +10 -15
  61. package/utils/services.js +32 -33
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;
@@ -1,99 +1,90 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _framer = _interopRequireDefault(require("../framer"));
8
- var _opcodes = _interopRequireDefault(require("../opcodes"));
9
- var _Account = _interopRequireDefault(require("./Account"));
10
- var _Blockweb = _interopRequireDefault(require("./Blockweb"));
11
- var _Oracle = _interopRequireDefault(require("./Oracle"));
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
- 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); }
14
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
15
- 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."); }
16
- 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; } }
17
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
18
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
19
- 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; }
20
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
- 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); } }
23
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
24
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
25
- 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; }
26
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
27
- 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); }
28
- var Manager = /*#__PURE__*/_createClass(function Manager() {
29
- var _this = this;
30
- _classCallCheck(this, Manager);
31
- _defineProperty(this, "start_clock", function () {
32
- var frequency = Number(process.env.HERTS) || 10;
33
- _this.clock = setInterval(function () {
34
- for (var account in _this.tracks) {
35
- var track = _this.tracks[account];
36
- var instruction = track.sequence[track.pointer];
1
+ import framer from "../framer";
2
+ import opcodes from "../opcodes";
3
+ import Account from "./Account";
4
+ import Blockweb from "./Blockweb";
5
+ import Oracle from "./Oracle";
6
+
7
+ class Manager {
8
+ constructor() {
9
+ this.accounts = new Object();
10
+ this.running = 0;
11
+ this.tracks = new Object();
12
+ this.web = new Blockweb(this);
13
+ this.oracle = new Oracle(this);
14
+ }
15
+
16
+ start_clock = () => {
17
+ let frequency = Number(process.env.HERTS) || 10;
18
+ this.clock = setInterval(() => {
19
+ for (let account in this.tracks) {
20
+ let track = this.tracks[account];
21
+
22
+ let instruction = track.sequence[track.pointer];
23
+
37
24
  track.account.vm.execute(instruction, track);
38
25
  track.pointer++;
26
+
39
27
  if (track.pointer === track.sequence.length) {
40
- _this.running--;
28
+ this.running--;
41
29
  track.account.chain.mine(track.account.vm);
42
30
  track.account.flush_buffer(track.pids.splice(-1)[0]);
43
- delete _this.tracks[account];
31
+
32
+ delete this.tracks[account];
44
33
  }
34
+
45
35
  if (track.breakpoint.slice(-1)[0] === track.pointer) {
46
36
  track.account.flush_buffer(track.pids.splice(-1)[0]);
47
37
  }
48
38
  }
49
- !_this.running && clearInterval(_this.clock);
39
+
40
+ !this.running && clearInterval(this.clock);
50
41
  }, frequency);
51
- });
52
- _defineProperty(this, "get_account", function (name) {
53
- return _this.accounts[name];
54
- });
55
- _defineProperty(this, "add_account", function (name, meta) {
56
- var account = _this.get_account(name);
42
+ };
43
+
44
+ get_account = (name) => this.accounts[name];
45
+
46
+ add_account = (name, meta) => {
47
+ let account = this.get_account(name);
48
+
57
49
  if (!account) {
58
- account = new _Account["default"](name, _objectSpread(_objectSpread({}, meta), {}, {
59
- manager: _this
60
- }));
61
- (0, _framer["default"])(account);
62
- (0, _opcodes["default"])(account);
63
- _this.accounts[account.name] = account;
64
- } else if (meta && meta["private"] && !account["private"]) {
65
- account["private"] = true;
50
+ account = new Account(name, { ...meta, manager: this });
51
+ framer(account);
52
+ opcodes(account);
53
+
54
+ this.accounts[account.name] = account;
55
+ } else if (meta && meta.private && !account.private) {
56
+ account.private = true;
66
57
  }
58
+
67
59
  return account;
68
- });
69
- _defineProperty(this, "push", function (program) {
70
- var track = _this.tracks[program.account.name];
60
+ };
61
+
62
+ push = (program) => {
63
+ let track = this.tracks[program.account.name];
64
+
71
65
  if (track) {
72
- var _track$sequence;
73
66
  track.breakpoint.push(track.pointer + program.sequence.length + 1);
74
- (_track$sequence = track.sequence).splice.apply(_track$sequence, [track.pointer + 1, 0].concat(_toConsumableArray(program.sequence)));
67
+ track.sequence.splice(track.pointer + 1, 0, ...program.sequence);
75
68
  track.pids.push(program.pid);
76
- if (!_this.running) {
77
- _this.running++;
78
- _this.tracks[program.account.name] = track;
79
- _this.start_clock();
69
+
70
+ if (!this.running) {
71
+ this.running++;
72
+ this.tracks[program.account.name] = track;
73
+ this.start_clock();
80
74
  }
81
75
  } else {
82
- track = _objectSpread(_objectSpread({}, program), {}, {
76
+ track = {
77
+ ...program,
83
78
  pointer: 0,
84
79
  pids: [program.pid],
85
- breakpoint: new Array()
86
- });
87
- _this.tracks[track.account.name] = track;
88
- _this.running++;
89
- _this.running === 1 && _this.start_clock();
80
+ breakpoint: new Array(),
81
+ };
82
+ this.tracks[track.account.name] = track;
83
+
84
+ this.running++;
85
+ this.running === 1 && this.start_clock();
90
86
  }
91
- });
92
- this.accounts = new Object();
93
- this.running = 0;
94
- this.tracks = new Object();
95
- this.web = new _Blockweb["default"](this);
96
- this.oracle = new _Oracle["default"](this);
97
- });
98
- var _default = Manager;
99
- exports["default"] = _default;
87
+ };
88
+ }
89
+
90
+ export default Manager;
@@ -1,102 +1,37 @@
1
- "use strict";
1
+ import { transpile_object } from "../utils/functions";
2
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) {
9
- "@babel/helpers - typeof";
10
- return (
11
- (_typeof =
12
- "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
13
- ? function (o) {
14
- return typeof o;
15
- }
16
- : function (o) {
17
- return o &&
18
- "function" == typeof Symbol &&
19
- o.constructor === Symbol &&
20
- o !== Symbol.prototype
21
- ? "symbol"
22
- : typeof o;
23
- }),
24
- _typeof(o)
25
- );
26
- }
27
- function _defineProperties(e, r) {
28
- for (var t = 0; t < r.length; t++) {
29
- var o = r[t];
30
- (o.enumerable = o.enumerable || !1),
31
- (o.configurable = !0),
32
- "value" in o && (o.writable = !0),
33
- Object.defineProperty(e, _toPropertyKey(o.key), o);
34
- }
35
- }
36
- function _createClass(e, r, t) {
37
- return (
38
- r && _defineProperties(e.prototype, r),
39
- t && _defineProperties(e, t),
40
- Object.defineProperty(e, "prototype", { writable: !1 }),
41
- e
42
- );
43
- }
44
- function _classCallCheck(a, n) {
45
- if (!(a instanceof n))
46
- throw new TypeError("Cannot call a class as a function");
47
- }
48
- function _defineProperty(e, r, t) {
49
- return (
50
- (r = _toPropertyKey(r)) in e
51
- ? Object.defineProperty(e, r, {
52
- value: t,
53
- enumerable: !0,
54
- configurable: !0,
55
- writable: !0,
56
- })
57
- : (e[r] = t),
58
- e
59
- );
60
- }
61
- function _toPropertyKey(t) {
62
- var i = _toPrimitive(t, "string");
63
- return "symbol" == _typeof(i) ? i : i + "";
64
- }
65
- function _toPrimitive(t, r) {
66
- if ("object" != _typeof(t) || !t) return t;
67
- var e = t[Symbol.toPrimitive];
68
- if (void 0 !== e) {
69
- var i = e.call(t, r || "default");
70
- if ("object" != _typeof(i)) return i;
71
- throw new TypeError("@@toPrimitive must return a primitive value.");
3
+ class Opcodes {
4
+ constructor() {
5
+ this.opcodes = new Object();
72
6
  }
73
- return ("string" === r ? String : Number)(t);
74
- }
75
- var Opcodes = /*#__PURE__*/ _createClass(function Opcodes() {
76
- var _this = this;
77
- _classCallCheck(this, Opcodes);
78
- _defineProperty(this, "set", function (opcode, circuit) {
79
- _this.opcodes[opcode] = circuit;
80
- _this.account.assembler.opcodes.push(opcode);
81
- });
82
- _defineProperty(this, "prepare_operation", function (opcode, context) {
83
- var circ = _this.opcodes[opcode];
7
+
8
+ set = (opcode, circuit) => {
9
+ this.opcodes[opcode] = circuit;
10
+ this.account.assembler.opcodes.push(opcode);
11
+ };
12
+
13
+ prepare_operation = (opcode, context) => {
14
+ let circ = this.opcodes[opcode];
15
+
84
16
  if (typeof circ !== "function") return;
85
- var buf = context.get_buffer();
86
- var args = buf && context.account.read(buf.inputs);
87
- var res = circ(args);
88
- _this.stdin(res);
89
- });
90
- _defineProperty(this, "stdin", function (object, cb) {
17
+
18
+ let buf = context.get_buffer();
19
+
20
+ let args = buf && context.account.read(buf.inputs);
21
+
22
+ let res = circ(args);
23
+
24
+ this.stdin(res);
25
+ };
26
+
27
+ stdin = (object, cb) => {
91
28
  if (object == null) return;
92
- var code_string = (0, _functions.transpile_object)(object);
93
- _this.account.assembler.run(code_string, {
94
- cb: cb,
95
- pure: true,
96
- });
29
+
30
+ let code_string = transpile_object(object);
31
+
32
+ this.account.compiler.run(code_string, { cb, pure: true });
97
33
  // console.log(`Writing in: ${code_string}`);
98
- });
99
- this.opcodes = new Object();
100
- });
101
- var _default = Opcodes;
102
- exports["default"] = _default;
34
+ };
35
+ }
36
+
37
+ export default Opcodes;
package/Objects/Oracle.js CHANGED
@@ -1,42 +1,26 @@
1
- "use strict";
1
+ import fs from "fs";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _fs = _interopRequireDefault(require("fs"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
- 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); }
10
- 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); } }
11
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
- 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; }
14
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
- 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); }
16
- var Oracle = /*#__PURE__*/_createClass(function Oracle(mgr) {
17
- var _this = this;
18
- _classCallCheck(this, Oracle);
19
- _defineProperty(this, "set", function (path, _ref) {
20
- var type = _ref.type,
21
- obj = _ref.obj;
22
- _this.datapaths[path] = {
23
- obj: obj,
24
- type: type
25
- };
26
- });
27
- _defineProperty(this, "get", function (path) {
28
- return _this.datapaths[path];
29
- });
30
- _defineProperty(this, "write", function (addr, data) {
31
- var meta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
32
- encoding: "utf-8"
3
+ class Oracle {
4
+ constructor(mgr) {
5
+ this.fs = fs;
6
+ this.mgr = mgr;
7
+ this.datapaths = new Object();
8
+ }
9
+
10
+ set = (path, { type, obj }) => {
11
+ this.datapaths[path] = {
12
+ obj,
13
+ type,
33
14
  };
15
+ };
16
+
17
+ get = (path) => this.datapaths[path];
18
+
19
+ write = (addr, data, meta = { encoding: "utf-8" }) => {
34
20
  if (typeof data !== "string") data = JSON.stringify(data);
35
- _this.fs.writeFileSync(addr, data, meta);
36
- });
37
- this.fs = _fs["default"];
38
- this.mgr = mgr;
39
- this.datapaths = new Object();
40
- });
41
- var _default = Oracle;
42
- exports["default"] = _default;
21
+
22
+ this.fs.writeFileSync(addr, data, meta);
23
+ };
24
+ }
25
+
26
+ export default Oracle;