@azrico/webobject 1.5.8 → 1.5.10

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.
@@ -85,7 +85,7 @@ export declare class WebObject extends SimpleObject {
85
85
  * useful in server applications
86
86
  * @returns
87
87
  */
88
- get_fullDeltaObject(p?: deltaParams): Promise<any>;
88
+ get_fullObject(p?: deltaParams): Promise<any>;
89
89
  /**
90
90
  * You will post this to the server for saving
91
91
  * automatically removes unchangable fields
@@ -480,26 +480,26 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
480
480
  key: "get_basicObject",
481
481
  value: (function () {
482
482
  var _get_basicObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
483
- var fulldelta, key, element;
483
+ var fullobject, key, element;
484
484
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
485
485
  while (1) switch (_context8.prev = _context8.next) {
486
486
  case 0:
487
487
  _context8.next = 2;
488
- return this.get_fullDeltaObject();
488
+ return this.get_fullObject();
489
489
  case 2:
490
- fulldelta = _context8.sent;
491
- for (key in fulldelta) {
492
- element = fulldelta[key];
490
+ fullobject = _context8.sent;
491
+ for (key in fullobject) {
492
+ element = fullobject[key];
493
493
  /* --------------------------- check for id fields -------------------------- */
494
494
  if (element != null && _typeof(element) === "object") {
495
495
  if ((key === "id" || key.endsWith("_id")) && typeof element.toString === "function") {
496
- fulldelta[key] = String(element);
496
+ fullobject[key] = String(element);
497
497
  } else {
498
- fulldelta[key] = JSON.parse(JSON.stringify(element));
498
+ fullobject[key] = JSON.parse(JSON.stringify(element));
499
499
  }
500
500
  }
501
501
  }
502
- return _context8.abrupt("return", fulldelta);
502
+ return _context8.abrupt("return", fullobject);
503
503
  case 5:
504
504
  case "end":
505
505
  return _context8.stop();
@@ -519,9 +519,9 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
519
519
  */
520
520
  )
521
521
  }, {
522
- key: "get_fullDeltaObject",
522
+ key: "get_fullObject",
523
523
  value: (function () {
524
- var _get_fullDeltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(p) {
524
+ var _get_fullObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(p) {
525
525
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
526
526
  while (1) switch (_context9.prev = _context9.next) {
527
527
  case 0:
@@ -538,10 +538,10 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
538
538
  }
539
539
  }, _callee9, this);
540
540
  }));
541
- function get_fullDeltaObject(_x3) {
542
- return _get_fullDeltaObject.apply(this, arguments);
541
+ function get_fullObject(_x3) {
542
+ return _get_fullObject.apply(this, arguments);
543
543
  }
544
- return get_fullDeltaObject;
544
+ return get_fullObject;
545
545
  }()
546
546
  /**
547
547
  * You will post this to the server for saving
@@ -1,4 +1,4 @@
1
- import { PropType, WriteablePropOf, PropOf, Ensure, PropOnlyPrefixedOf } from "@azrico/types";
1
+ import { PropType, WriteablePropOf, PropOf, Ensure, PropPrefixedOf, PropOnlyPrefixedOf } from "@azrico/types";
2
2
  import { formatObject } from "@azrico/convert";
3
3
  import { MapableObject } from "./MapableObject";
4
4
  import ObjectManager from "./ObjectManager";
@@ -66,13 +66,13 @@ export declare class SimpleObject extends MapableObject {
66
66
  * @param autoApply if the field is not in delta, instantly calls the `apply` function to remove from delta
67
67
  * @returns
68
68
  */
69
- set(key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType, autoApply?: boolean): Promise<boolean>;
69
+ set<MKey extends PropPrefixedOf<this>>(key: MKey, value: any, shouldNotify?: sendChangesType, autoApply?: boolean): Promise<boolean>;
70
70
  /**
71
71
  * @deprecated use `set`
72
72
  * set value and run the event handlers if needed
73
73
  * @return true if changed , false otherwise
74
74
  */
75
- setValue: (key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType, autoApply?: boolean) => Promise<boolean>;
75
+ setValue: <MKey extends PropPrefixedOf<this>>(key: MKey, value: any, shouldNotify?: sendChangesType, autoApply?: boolean) => Promise<boolean>;
76
76
  /**
77
77
  * set value and run the event handlers if needed
78
78
  *
@@ -81,6 +81,15 @@ export declare class SimpleObject extends MapableObject {
81
81
  * @param value
82
82
  */
83
83
  setPreferApply(key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType): Promise<boolean>;
84
+ /**
85
+ * set key of subObject
86
+ * @param key
87
+ * @param value
88
+ * @param subvalue
89
+ * @param sendChanges
90
+ * @return true if changed , false otherwise
91
+ */
92
+ setSubValue<MKey extends PropOf<this>>(key: MKey, objKey: string, subvalue: any, sendChanges?: sendChangesType): Promise<boolean>;
84
93
  setTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
85
94
  /**
86
95
  * load all properties in `initObject` into the current object
@@ -124,15 +133,6 @@ export declare class SimpleObject extends MapableObject {
124
133
  * @returns
125
134
  */
126
135
  setDefault: (key: WriteablePropOf<this>, value: any) => boolean;
127
- /**
128
- * set key of subObject
129
- * @param key
130
- * @param value
131
- * @param subvalue
132
- * @param sendChanges
133
- * @return true if changed , false otherwise
134
- */
135
- setSubValue<MKey extends PropOf<this>>(key: MKey, objKey: string, subvalue: any, sendChanges?: sendChangesType): Promise<boolean>;
136
136
  /**
137
137
  * Push a single value to array property
138
138
  * @param key
@@ -160,12 +160,13 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
160
160
  var _set = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
161
161
  var shouldNotify,
162
162
  autoApply,
163
+ isValueChanged,
164
+ mkey,
165
+ keyExists,
163
166
  keysp,
164
- key_part,
165
167
  subkey_part,
166
- keyExists,
168
+ subval,
167
169
  old_value,
168
- needsChange,
169
170
  _this$manager,
170
171
  _args = arguments;
171
172
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -181,55 +182,64 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
181
182
  _context.next = 7;
182
183
  break;
183
184
  }
184
- throw Error("Cant use set (".concat(String(key), ") when on readonly mode"));
185
+ throw Error("Cant use set(".concat(String(key), ") when on readonly mode"));
185
186
  case 7:
186
187
  return _context.abrupt("return", false);
187
188
  case 8:
188
- if (!(typeof key === "string" && key.includes("."))) {
189
- _context.next = 15;
190
- break;
189
+ /* -------------------------------------------------------------------------- */
190
+ keyExists = false;
191
+ if (typeof key === "string" && key.includes(".")) {
192
+ /* -------------------------------------------------------------------------- */
193
+ /* set value of object */
194
+ /* -------------------------------------------------------------------------- */
195
+ keysp = key.split(".");
196
+ mkey = keysp.shift();
197
+ keyExists = mkey in this.__delta;
198
+ subkey_part = keysp.shift(); //if accessing subval of an object, make sure the object is not null
199
+ subval = _assertClassBrand(_SimpleObject_brand, this, _getSubProperty).call(this, mkey, subkey_part);
200
+ isValueChanged = !(0, _object.object_equals)(subval, value, {
201
+ ignoredStartingWords: "_",
202
+ strictArrayCheck: true
203
+ });
204
+ if (isValueChanged) _assertClassBrand(_SimpleObject_brand, this, _setSubProperty).call(this, mkey, subkey_part, value);
205
+ } else {
206
+ /* -------------------------------------------------------------------------- */
207
+ /* set basic value */
208
+ /* -------------------------------------------------------------------------- */
209
+ mkey = key;
210
+ keyExists = mkey in this.__delta;
211
+ old_value = this.get(mkey);
212
+ isValueChanged = !(0, _object.object_equals)(old_value, value, {
213
+ strictArrayCheck: true,
214
+ ignoredStartingWords: "_"
215
+ });
216
+ if (isValueChanged) _assertClassBrand(_SimpleObject_brand, this, _setProperty).call(this, mkey, value);
191
217
  }
192
- keysp = key.split(".");
193
- key_part = keysp.shift();
194
- subkey_part = keysp.shift();
195
- _context.next = 14;
196
- return this.setSubValue(key_part, subkey_part, value, shouldNotify);
197
- case 14:
198
- return _context.abrupt("return", _context.sent);
199
- case 15:
200
- /* --------------------------- set if not changed --------------------------- */
201
- keyExists = key in this.__delta;
202
- old_value = this.get(key);
203
- needsChange = !(0, _object.object_equals)(old_value, value, {
204
- strictArrayCheck: true,
205
- ignoredStartingWords: "_"
206
- });
207
- if (needsChange) {
208
- _assertClassBrand(_SimpleObject_brand, this, _setProperty).call(this, key, value);
218
+ if (autoApply && keyExists === false) {
219
+ /**
220
+ * if the field is not in delta
221
+ * instantly calls the `apply` function to remove from delta
222
+ */
223
+ this.apply(mkey);
224
+ if (shouldNotify === "auto") shouldNotify = false;
225
+ }
226
+ if (isValueChanged) {
209
227
  /**
210
228
  * notify the manager when the state of `__has_delta` is changed
211
229
  * managers can use this to detect if they need to save
212
230
  */
213
231
  (_this$manager = this.manager) === null || _this$manager === void 0 || _this$manager.checkIsChanged();
214
232
  }
215
- /**
216
- * if the field is not in delta
217
- * instantly calls the `apply` function to remove from delta
218
- */
219
- if (autoApply && !keyExists) {
220
- this.apply(key);
221
- if (shouldNotify === "auto") shouldNotify = false;
222
- }
223
233
  /* --------------------------------- notify --------------------------------- */
224
- if (!(shouldNotify === true || shouldNotify === "auto" && needsChange)) {
225
- _context.next = 23;
234
+ if (!(shouldNotify === true || shouldNotify === "auto" && isValueChanged)) {
235
+ _context.next = 15;
226
236
  break;
227
237
  }
228
- _context.next = 23;
238
+ _context.next = 15;
229
239
  return this.notifyChanged("", key, value);
230
- case 23:
231
- return _context.abrupt("return", needsChange);
232
- case 24:
240
+ case 15:
241
+ return _context.abrupt("return", isValueChanged);
242
+ case 16:
233
243
  case "end":
234
244
  return _context.stop();
235
245
  }
@@ -273,6 +283,40 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
273
283
  }
274
284
  return setPreferApply;
275
285
  }()
286
+ /**
287
+ * set key of subObject
288
+ * @param key
289
+ * @param value
290
+ * @param subvalue
291
+ * @param sendChanges
292
+ * @return true if changed , false otherwise
293
+ */
294
+ )
295
+ }, {
296
+ key: "setSubValue",
297
+ value: (function () {
298
+ var _setSubValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, objKey, subvalue) {
299
+ var sendChanges,
300
+ _args3 = arguments;
301
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
302
+ while (1) switch (_context3.prev = _context3.next) {
303
+ case 0:
304
+ sendChanges = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : "auto";
305
+ _context3.next = 3;
306
+ return this.set("".concat(String(key), ".").concat(objKey), subvalue, sendChanges);
307
+ case 3:
308
+ return _context3.abrupt("return", _context3.sent);
309
+ case 4:
310
+ case "end":
311
+ return _context3.stop();
312
+ }
313
+ }, _callee3, this);
314
+ }));
315
+ function setSubValue(_x5, _x6, _x7) {
316
+ return _setSubValue.apply(this, arguments);
317
+ }
318
+ return setSubValue;
319
+ }()
276
320
  /* -------------------------------------------------------------------------- */
277
321
  /* Load */
278
322
  /* -------------------------------------------------------------------------- */
@@ -280,33 +324,33 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
280
324
  }, {
281
325
  key: "setTemp",
282
326
  value: (function () {
283
- var _setTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
327
+ var _setTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, value) {
284
328
  var sendChanges,
285
329
  isValueChanged,
286
- _args3 = arguments;
287
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
288
- while (1) switch (_context3.prev = _context3.next) {
330
+ _args4 = arguments;
331
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
332
+ while (1) switch (_context4.prev = _context4.next) {
289
333
  case 0:
290
- sendChanges = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : false;
291
- _context3.next = 3;
334
+ sendChanges = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : false;
335
+ _context4.next = 3;
292
336
  return _get(_getPrototypeOf(SimpleObject.prototype), "setTemp", this).call(this, key, value);
293
337
  case 3:
294
- isValueChanged = _context3.sent;
338
+ isValueChanged = _context4.sent;
295
339
  if (!(sendChanges === true || sendChanges === "auto" && isValueChanged)) {
296
- _context3.next = 7;
340
+ _context4.next = 7;
297
341
  break;
298
342
  }
299
- _context3.next = 7;
343
+ _context4.next = 7;
300
344
  return this.notifyChanged("temp", key, value);
301
345
  case 7:
302
- return _context3.abrupt("return", isValueChanged);
346
+ return _context4.abrupt("return", isValueChanged);
303
347
  case 8:
304
348
  case "end":
305
- return _context3.stop();
349
+ return _context4.stop();
306
350
  }
307
- }, _callee3, this);
351
+ }, _callee4, this);
308
352
  }));
309
- function setTemp(_x5, _x6) {
353
+ function setTemp(_x8, _x9) {
310
354
  return _setTemp.apply(this, arguments);
311
355
  }
312
356
  return setTemp;
@@ -328,16 +372,16 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
328
372
  }, {
329
373
  key: "clearRefreshFunction",
330
374
  value: ( /* ---------------------------- refresh functions --------------------------- */function () {
331
- var _clearRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
332
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
333
- while (1) switch (_context4.prev = _context4.next) {
375
+ var _clearRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
376
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
377
+ while (1) switch (_context5.prev = _context5.next) {
334
378
  case 0:
335
379
  this.__refresh_functions = undefined;
336
380
  case 1:
337
381
  case "end":
338
- return _context4.stop();
382
+ return _context5.stop();
339
383
  }
340
- }, _callee4, this);
384
+ }, _callee5, this);
341
385
  }));
342
386
  function clearRefreshFunction() {
343
387
  return _clearRefreshFunction.apply(this, arguments);
@@ -347,21 +391,21 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
347
391
  }, {
348
392
  key: "setRefreshFunction",
349
393
  value: function () {
350
- var _setRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(new_fnc) {
351
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
352
- while (1) switch (_context5.prev = _context5.next) {
394
+ var _setRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(new_fnc) {
395
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
396
+ while (1) switch (_context6.prev = _context6.next) {
353
397
  case 0:
354
- _context5.next = 2;
398
+ _context6.next = 2;
355
399
  return this.addRefreshFunction(new_fnc);
356
400
  case 2:
357
- return _context5.abrupt("return", _context5.sent);
401
+ return _context6.abrupt("return", _context6.sent);
358
402
  case 3:
359
403
  case "end":
360
- return _context5.stop();
404
+ return _context6.stop();
361
405
  }
362
- }, _callee5, this);
406
+ }, _callee6, this);
363
407
  }));
364
- function setRefreshFunction(_x7) {
408
+ function setRefreshFunction(_x10) {
365
409
  return _setRefreshFunction.apply(this, arguments);
366
410
  }
367
411
  return setRefreshFunction;
@@ -369,10 +413,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
369
413
  }, {
370
414
  key: "addRefreshFunction",
371
415
  value: function () {
372
- var _addRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(key, new_fnc) {
416
+ var _addRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(key, new_fnc) {
373
417
  var oldFunctions;
374
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
375
- while (1) switch (_context6.prev = _context6.next) {
418
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
419
+ while (1) switch (_context7.prev = _context7.next) {
376
420
  case 0:
377
421
  if (typeof key === "function") {
378
422
  new_fnc = key;
@@ -385,11 +429,11 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
385
429
  this.__refresh_functions = oldFunctions;
386
430
  case 6:
387
431
  case "end":
388
- return _context6.stop();
432
+ return _context7.stop();
389
433
  }
390
- }, _callee6, this);
434
+ }, _callee7, this);
391
435
  }));
392
- function addRefreshFunction(_x8, _x9) {
436
+ function addRefreshFunction(_x11, _x12) {
393
437
  return _addRefreshFunction.apply(this, arguments);
394
438
  }
395
439
  return addRefreshFunction;
@@ -397,7 +441,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
397
441
  }, {
398
442
  key: "runRefreshFunction",
399
443
  value: function () {
400
- var _runRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
444
+ var _runRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
401
445
  var oldFunctions,
402
446
  fncArray,
403
447
  _len,
@@ -405,39 +449,39 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
405
449
  _key,
406
450
  index,
407
451
  fnc,
408
- _args7 = arguments;
409
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
410
- while (1) switch (_context7.prev = _context7.next) {
452
+ _args8 = arguments;
453
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
454
+ while (1) switch (_context8.prev = _context8.next) {
411
455
  case 0:
412
456
  oldFunctions = this.__refresh_functions;
413
457
  if (!(oldFunctions == null || _typeof(oldFunctions) !== "object")) {
414
- _context7.next = 3;
458
+ _context8.next = 3;
415
459
  break;
416
460
  }
417
- return _context7.abrupt("return");
461
+ return _context8.abrupt("return");
418
462
  case 3:
419
463
  fncArray = Object.values(oldFunctions);
420
- for (_len = _args7.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
421
- params[_key] = _args7[_key];
464
+ for (_len = _args8.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
465
+ params[_key] = _args8[_key];
422
466
  }
423
467
  index = 0;
424
468
  case 6:
425
469
  if (!(index < fncArray.length)) {
426
- _context7.next = 13;
470
+ _context8.next = 13;
427
471
  break;
428
472
  }
429
473
  fnc = fncArray[index];
430
- _context7.next = 10;
474
+ _context8.next = 10;
431
475
  return _object.fn_eval.apply(void 0, [fnc].concat(params));
432
476
  case 10:
433
477
  index++;
434
- _context7.next = 6;
478
+ _context8.next = 6;
435
479
  break;
436
480
  case 13:
437
481
  case "end":
438
- return _context7.stop();
482
+ return _context8.stop();
439
483
  }
440
- }, _callee7, this);
484
+ }, _callee8, this);
441
485
  }));
442
486
  function runRefreshFunction() {
443
487
  return _runRefreshFunction.apply(this, arguments);
@@ -454,47 +498,47 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
454
498
  }, {
455
499
  key: "setAll",
456
500
  value: (function () {
457
- var _setAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(setObj) {
501
+ var _setAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(setObj) {
458
502
  var changeablesOnly,
459
503
  finalRes,
460
504
  checkKeys,
461
505
  index,
462
506
  key,
463
- _args8 = arguments;
464
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
465
- while (1) switch (_context8.prev = _context8.next) {
507
+ _args9 = arguments;
508
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
509
+ while (1) switch (_context9.prev = _context9.next) {
466
510
  case 0:
467
- changeablesOnly = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : true;
511
+ changeablesOnly = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : true;
468
512
  finalRes = true;
469
513
  checkKeys = changeablesOnly ? (0, _object.array_intersection)(this.__changeables, Object.keys(setObj)) : Object.keys(setObj);
470
514
  index = 0;
471
515
  case 4:
472
516
  if (!(index < checkKeys.length)) {
473
- _context8.next = 13;
517
+ _context9.next = 13;
474
518
  break;
475
519
  }
476
520
  key = checkKeys[index];
477
- _context8.next = 8;
521
+ _context9.next = 8;
478
522
  return this.set(key, setObj[key]);
479
523
  case 8:
480
- if (_context8.sent) {
481
- _context8.next = 10;
524
+ if (_context9.sent) {
525
+ _context9.next = 10;
482
526
  break;
483
527
  }
484
528
  finalRes = false;
485
529
  case 10:
486
530
  index++;
487
- _context8.next = 4;
531
+ _context9.next = 4;
488
532
  break;
489
533
  case 13:
490
- return _context8.abrupt("return", finalRes);
534
+ return _context9.abrupt("return", finalRes);
491
535
  case 14:
492
536
  case "end":
493
- return _context8.stop();
537
+ return _context9.stop();
494
538
  }
495
- }, _callee8, this);
539
+ }, _callee9, this);
496
540
  }));
497
- function setAll(_x10) {
541
+ function setAll(_x13) {
498
542
  return _setAll.apply(this, arguments);
499
543
  }
500
544
  return setAll;
@@ -512,72 +556,8 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
512
556
  return _assertClassBrand(_SimpleObject_brand, this, _setDefaultProperty).call(this, key, value);
513
557
  }
514
558
  }, {
515
- key: "setSubValue",
559
+ key: "pushValue",
516
560
  value: (
517
- /**
518
- * set key of subObject
519
- * @param key
520
- * @param value
521
- * @param subvalue
522
- * @param sendChanges
523
- * @return true if changed , false otherwise
524
- */
525
- function () {
526
- var _setSubValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(key, objKey, subvalue) {
527
- var sendChanges,
528
- isValueChanged,
529
- subval,
530
- _args9 = arguments;
531
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
532
- while (1) switch (_context9.prev = _context9.next) {
533
- case 0:
534
- sendChanges = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : "auto";
535
- if (this.canModify) {
536
- _context9.next = 7;
537
- break;
538
- }
539
- if (!(this.__throw_errors !== false)) {
540
- _context9.next = 6;
541
- break;
542
- }
543
- throw Error("Cant use setSubValue (".concat(String(key), ") when on readonly mode"));
544
- case 6:
545
- return _context9.abrupt("return", false);
546
- case 7:
547
- isValueChanged = false;
548
- _context9.prev = 8;
549
- //if accessing subval of an object, make sure the object is not null
550
- subval = _assertClassBrand(_SimpleObject_brand, this, _getSubProperty).call(this, key, objKey);
551
- if (!(0, _object.object_equals)(subval, subvalue, {
552
- ignoredStartingWords: "_",
553
- strictArrayCheck: true
554
- })) {
555
- _assertClassBrand(_SimpleObject_brand, this, _setSubProperty).call(this, key, objKey, subvalue);
556
- isValueChanged = true;
557
- } else isValueChanged = false;
558
- case 11:
559
- _context9.prev = 11;
560
- if (!(sendChanges === true || sendChanges === "auto" && isValueChanged)) {
561
- _context9.next = 15;
562
- break;
563
- }
564
- _context9.next = 15;
565
- return this.notifyChanged("", key, objKey, subvalue);
566
- case 15:
567
- return _context9.finish(11);
568
- case 16:
569
- return _context9.abrupt("return", isValueChanged);
570
- case 17:
571
- case "end":
572
- return _context9.stop();
573
- }
574
- }, _callee9, this, [[8,, 11, 16]]);
575
- }));
576
- function setSubValue(_x11, _x12, _x13) {
577
- return _setSubValue.apply(this, arguments);
578
- }
579
- return setSubValue;
580
- }()
581
561
  /**
582
562
  * Push a single value to array property
583
563
  * @param key
@@ -585,10 +565,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
585
565
  * @param sendChanges
586
566
  * @returns
587
567
  */
588
- )
589
- }, {
590
- key: "pushValue",
591
- value: (function () {
568
+ function () {
592
569
  var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, value) {
593
570
  var sendChanges,
594
571
  _args10 = arguments;
@@ -1264,9 +1241,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
1264
1241
  }
1265
1242
  return obj[key];
1266
1243
  }
1267
- /* -------------------------------------------------------------------------- */
1268
- /* set */
1269
- /* -------------------------------------------------------------------------- */
1270
1244
  }, {
1271
1245
  key: "loadValues",
1272
1246
  value: function loadValues(obj, initObject) {
@@ -1666,6 +1640,15 @@ function _setDefaultPropertyNow(key) {
1666
1640
  }
1667
1641
  return false;
1668
1642
  }
1643
+ function _getSubProperty(key, subkey) {
1644
+ var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1645
+ var subobj = this.get(key, original);
1646
+ if (subobj == null || _typeof(subobj) !== "object") return undefined;
1647
+ return subobj[subkey];
1648
+ }
1649
+ /* -------------------------------------------------------------------------- */
1650
+ /* set */
1651
+ /* -------------------------------------------------------------------------- */
1669
1652
  function _setSubProperty(key, subkey, value) {
1670
1653
  var subobj = this.get(key);
1671
1654
  //@ts-ignore
@@ -1673,12 +1656,6 @@ function _setSubProperty(key, subkey, value) {
1673
1656
  subobj[subkey] = value;
1674
1657
  _assertClassBrand(_SimpleObject_brand, this, _setProperty).call(this, key, subobj);
1675
1658
  }
1676
- function _getSubProperty(key, subkey) {
1677
- var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1678
- var subobj = this.get(key, original);
1679
- if (subobj == null || _typeof(subobj) !== "object") return undefined;
1680
- return subobj[subkey];
1681
- }
1682
1659
  /**
1683
1660
  * update a property on this object by updating the `__delta`
1684
1661
  * or update the object property directly depending on `__use_delta` setting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.5.8",
3
+ "version": "1.5.10",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@azrico/convert": "^1.0.13",
73
- "@azrico/event": "^1.2.52",
73
+ "@azrico/event": "^1.2.56",
74
74
  "@azrico/global": "^1.3.85",
75
75
  "@azrico/math": "^1.0.5",
76
76
  "@azrico/object": "^1.4.112",