@azrico/webobject 1.5.6 → 1.5.7

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.
@@ -49,7 +49,15 @@ export declare class SimpleObject extends MapableObject {
49
49
  constructor(is_readonly?: boolean);
50
50
  get<MKey extends PropOf<this>>(key: MKey, original?: boolean): PropType<this, MKey>;
51
51
  get<MKey extends PropOnlyPrefixedOf<this>>(key: MKey, original?: boolean): any;
52
- static get<T extends SimpleObject, MKey extends PropOf<T>>(o: T, key: MKey, original?: boolean): PropType<T, MKey> | undefined;
52
+ /**
53
+ * static get method for SimpleObject
54
+ * @param obj
55
+ * @param key
56
+ * @param original
57
+ * @returns
58
+ */
59
+ static get<T extends SimpleObject, MKey extends PropOf<T>>(obj: T, key: MKey, original?: boolean): PropType<T, MKey> | undefined;
60
+ getSubValue: (key: PropOf<this>, subkey: string, original?: boolean) => any;
53
61
  /**
54
62
  * set value and run the event handlers if needed
55
63
  * @param key
@@ -59,6 +67,12 @@ export declare class SimpleObject extends MapableObject {
59
67
  * @returns
60
68
  */
61
69
  set(key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType, autoApply?: boolean): Promise<boolean>;
70
+ /**
71
+ * @deprecated use `set`
72
+ * set value and run the event handlers if needed
73
+ * @return true if changed , false otherwise
74
+ */
75
+ setValue: (key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType, autoApply?: boolean) => Promise<boolean>;
62
76
  /**
63
77
  * set value and run the event handlers if needed
64
78
  *
@@ -67,11 +81,7 @@ export declare class SimpleObject extends MapableObject {
67
81
  * @param value
68
82
  */
69
83
  setPreferApply(key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType): Promise<boolean>;
70
- /**
71
- * set value and run the event handlers if needed
72
- * @return true if changed , false otherwise
73
- */
74
- setValue: (key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType, autoApply?: boolean) => Promise<boolean>;
84
+ setTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
75
85
  /**
76
86
  * load all properties in `initObject` into the current object
77
87
  * @param initObject
@@ -80,7 +90,6 @@ export declare class SimpleObject extends MapableObject {
80
90
  */
81
91
  loadValues(initObject: any, fullUpdate?: boolean): boolean;
82
92
  static loadValues(obj: SimpleObject, initObject: any, fullUpdate?: boolean): boolean;
83
- setTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
84
93
  clearRefreshFunction(): Promise<void>;
85
94
  setRefreshFunction(new_fnc: any): Promise<any>;
86
95
  addRefreshFunction(new_fnc: any): any;
@@ -120,10 +129,10 @@ export declare class SimpleObject extends MapableObject {
120
129
  * @param key
121
130
  * @param value
122
131
  * @param subvalue
132
+ * @param sendChanges
123
133
  * @return true if changed , false otherwise
124
134
  */
125
135
  setSubValue<MKey extends PropOf<this>>(key: MKey, objKey: string, subvalue: any, sendChanges?: sendChangesType): Promise<boolean>;
126
- getSubValue: (key: PropOf<this>, subkey: string, original?: boolean) => any;
127
136
  /**
128
137
  * Push a single value to array property
129
138
  * @param key
@@ -81,7 +81,9 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
81
81
  _defineProperty(_this, "_index_key", "");
82
82
  //sequence value , used to index the object with increasing numbers
83
83
  _defineProperty(_this, "_index_value", -1);
84
+ _defineProperty(_this, "getSubValue", _assertClassBrand(_SimpleObject_brand, _this, _getSubProperty));
84
85
  /**
86
+ * @deprecated use `set`
85
87
  * set value and run the event handlers if needed
86
88
  * @return true if changed , false otherwise
87
89
  */
@@ -100,7 +102,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
100
102
  * @returns
101
103
  */
102
104
  _defineProperty(_this, "setDefault", _this.setDefaultValue);
103
- _defineProperty(_this, "getSubValue", _assertClassBrand(_SimpleObject_brand, _this, _getSubProperty));
104
105
  _defineProperty(_this, "get_managerClass", function () {
105
106
  return undefined;
106
107
  });
@@ -126,8 +127,8 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
126
127
  if (typeof key === "string" && key.includes(".")) {
127
128
  /* ----------------------------- using sub value ---------------------------- */
128
129
  var keysp = key.split(".");
129
- var subkey_part = keysp.pop();
130
- var key_part = keysp.join(".");
130
+ var key_part = keysp.shift();
131
+ var subkey_part = keysp.shift();
131
132
  used_value = _assertClassBrand(_SimpleObject_brand, this, _getSubProperty).call(this, key_part, subkey_part);
132
133
  } else {
133
134
  /* --------------------------- using this or delta -------------------------- */
@@ -137,6 +138,13 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
137
138
  }
138
139
  return is_fnc ? (0, _object.fn_eval_this)(this, used_value) : used_value;
139
140
  }
141
+ /**
142
+ * static get method for SimpleObject
143
+ * @param obj
144
+ * @param key
145
+ * @param original
146
+ * @returns
147
+ */
140
148
  }, {
141
149
  key: "set",
142
150
  value: (
@@ -152,6 +160,9 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
152
160
  var _set = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
153
161
  var shouldNotify,
154
162
  autoApply,
163
+ keysp,
164
+ key_part,
165
+ subkey_part,
155
166
  keyExists,
156
167
  old_value,
157
168
  needsChange,
@@ -174,6 +185,15 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
174
185
  case 7:
175
186
  return _context.abrupt("return", false);
176
187
  case 8:
188
+ if (!(typeof key === "string" && key.includes("."))) {
189
+ _context.next = 13;
190
+ break;
191
+ }
192
+ keysp = key.split(".");
193
+ key_part = keysp.shift();
194
+ subkey_part = keysp.shift();
195
+ return _context.abrupt("return", this.setSubValue(key_part, subkey_part, value));
196
+ case 13:
177
197
  /* --------------------------- set if not changed --------------------------- */
178
198
  keyExists = key in this.__delta;
179
199
  old_value = this.get(key);
@@ -199,14 +219,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
199
219
  }
200
220
  /* --------------------------------- notify --------------------------------- */
201
221
  if (!(shouldNotify === true || shouldNotify === "auto" && needsChange)) {
202
- _context.next = 16;
222
+ _context.next = 21;
203
223
  break;
204
224
  }
205
- _context.next = 16;
225
+ _context.next = 21;
206
226
  return this.notifyChanged("", key, value);
207
- case 16:
227
+ case 21:
208
228
  return _context.abrupt("return", needsChange);
209
- case 17:
229
+ case 22:
210
230
  case "end":
211
231
  return _context.stop();
212
232
  }
@@ -216,7 +236,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
216
236
  return _set.apply(this, arguments);
217
237
  }
218
238
  return set;
219
- }()
239
+ }())
240
+ }, {
241
+ key: "setPreferApply",
242
+ value: (
220
243
  /**
221
244
  * set value and run the event handlers if needed
222
245
  *
@@ -224,10 +247,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
224
247
  * @param key
225
248
  * @param value
226
249
  */
227
- )
228
- }, {
229
- key: "setPreferApply",
230
- value: (function () {
250
+ function () {
231
251
  var _setPreferApply = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
232
252
  var shouldNotify,
233
253
  _args2 = arguments;
@@ -249,25 +269,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
249
269
  return _setPreferApply.apply(this, arguments);
250
270
  }
251
271
  return setPreferApply;
252
- }())
253
- }, {
254
- key: "loadValues",
255
- value: /* -------------------------------------------------------------------------- */
272
+ }()
273
+ /* -------------------------------------------------------------------------- */
256
274
  /* Load */
257
275
  /* -------------------------------------------------------------------------- */
258
- /**
259
- * load all properties in `initObject` into the current object
260
- * @param initObject
261
- * @param fullUpdate
262
- * @returns
263
- */
264
- function loadValues(initObject) {
265
- var fullUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
266
- return SimpleObject.loadValues(this, initObject, fullUpdate);
267
- }
276
+ )
268
277
  }, {
269
278
  key: "setTemp",
270
- value: function () {
279
+ value: (function () {
271
280
  var _setTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
272
281
  var sendChanges,
273
282
  isValueChanged,
@@ -298,10 +307,24 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
298
307
  return _setTemp.apply(this, arguments);
299
308
  }
300
309
  return setTemp;
301
- }() /* ---------------------------- refresh functions --------------------------- */
310
+ }()
311
+ /* -------------------------------------------------------------------------- */
312
+ /**
313
+ * load all properties in `initObject` into the current object
314
+ * @param initObject
315
+ * @param fullUpdate
316
+ * @returns
317
+ */
318
+ )
319
+ }, {
320
+ key: "loadValues",
321
+ value: function loadValues(initObject) {
322
+ var fullUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
323
+ return SimpleObject.loadValues(this, initObject, fullUpdate);
324
+ }
302
325
  }, {
303
326
  key: "clearRefreshFunction",
304
- value: (function () {
327
+ value: ( /* ---------------------------- refresh functions --------------------------- */function () {
305
328
  var _clearRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
306
329
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
307
330
  while (1) switch (_context4.prev = _context4.next) {
@@ -493,6 +516,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
493
516
  * @param key
494
517
  * @param value
495
518
  * @param subvalue
519
+ * @param sendChanges
496
520
  * @return true if changed , false otherwise
497
521
  */
498
522
  function () {
@@ -550,10 +574,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
550
574
  return _setSubValue.apply(this, arguments);
551
575
  }
552
576
  return setSubValue;
553
- }())
554
- }, {
555
- key: "pushValue",
556
- value: (
577
+ }()
557
578
  /**
558
579
  * Push a single value to array property
559
580
  * @param key
@@ -561,7 +582,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
561
582
  * @param sendChanges
562
583
  * @returns
563
584
  */
564
- function () {
585
+ )
586
+ }, {
587
+ key: "pushValue",
588
+ value: (function () {
565
589
  var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, value) {
566
590
  var sendChanges,
567
591
  _args10 = arguments;
@@ -1226,16 +1250,16 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
1226
1250
  /* -------------------------------------------------------------------------- */
1227
1251
  }], [{
1228
1252
  key: "get",
1229
- value: function get(o, key) {
1253
+ value: function get(obj, key) {
1230
1254
  var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1231
- if (o == null) return undefined;
1232
- if (o instanceof SimpleObject && typeof o.get === "function") return o.get(key, original);
1255
+ if (obj == null) return undefined;
1256
+ if (obj instanceof SimpleObject && typeof obj.get === "function") return obj.get(key, original);
1233
1257
  /* ------------------------------- manual get ------------------------------- */
1234
- if (!original && o.__use_delta != false && _typeof(o.__delta) === "object" && key in o.__delta) {
1258
+ if (!original && obj.__use_delta != false && _typeof(obj.__delta) === "object" && key in obj.__delta) {
1235
1259
  //@ts-ignore
1236
- return o.__delta[key];
1260
+ return obj.__delta[key];
1237
1261
  }
1238
- return o[key];
1262
+ return obj[key];
1239
1263
  }
1240
1264
  /* -------------------------------------------------------------------------- */
1241
1265
  /* set */
@@ -1677,24 +1701,6 @@ function _setProperty(key, value) {
1677
1701
  this.__delta[key] = value; //always update delta to keep track of changes
1678
1702
  }
1679
1703
  return true;
1680
- //// if (checkIsChanged || this.__has_delta === false) {
1681
- //// /**
1682
- //// * if any key exists in the `__delta` then the object is changed
1683
- //// */
1684
- //// let next__has_delta = false;
1685
- //// for (const key in this.__delta) {
1686
- //// next__has_delta = true;
1687
- //// break;
1688
- //// }
1689
- //// let previous__has_delta = this.__has_delta;
1690
- //// this.__has_delta = next__has_delta;
1691
- //// /**
1692
- //// * if the state of __has_delta is changed we return true
1693
- //// * so we can run the needed events
1694
- //// */
1695
- //// return previous__has_delta != this.__has_delta;
1696
- //// }
1697
- //// return false;
1698
1704
  }
1699
1705
  function _setSaveResultObject(toObj) {
1700
1706
  if (toObj == null) toObj = null; //null or undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",