@azrico/webobject 1.4.66 → 1.4.67

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.
@@ -53,6 +53,9 @@ export declare class SimpleObject extends MapableObject {
53
53
  setValue(key: WriteablePropOf<this>, value: any, sendChanges?: sendChangesType): Promise<boolean>;
54
54
  set: (key: WriteablePropOf<this>, value: any, sendChanges?: sendChangesType) => Promise<boolean>;
55
55
  setTemp: (key: string, value: any) => any;
56
+ setAll<K extends WriteablePropOf<this>>(setObj: {
57
+ [key in K]: any;
58
+ }): Promise<boolean>;
56
59
  /**
57
60
  * set value of a key only if the value is empty
58
61
  * @param key
@@ -46,7 +46,7 @@ var _getProperty = /*#__PURE__*/new WeakSet();
46
46
  var _getTempProperty = /*#__PURE__*/new WeakSet();
47
47
  var _setTempProperty = /*#__PURE__*/new WeakSet();
48
48
  var _setSaveResultObject = /*#__PURE__*/new WeakSet();
49
- var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValue, _pushValue, _notifyChanged, _reset, _resetAll, _event_run, _event_add) {
49
+ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setAll, _setSubValue, _pushValue, _notifyChanged, _reset, _resetAll, _event_run, _event_add) {
50
50
  _inherits(SimpleObject, _MapableObject);
51
51
  var _super = _createSuper(SimpleObject);
52
52
  function SimpleObject() {
@@ -189,15 +189,50 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValu
189
189
  }))).apply(this, arguments);
190
190
  }
191
191
  }, {
192
- key: "setDefaultValue",
193
- value:
192
+ key: "setAll",
193
+ value: function setAll(_x3) {
194
+ return (_setAll = _setAll || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(setObj) {
195
+ var finalRes, key;
196
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
197
+ while (1) switch (_context2.prev = _context2.next) {
198
+ case 0:
199
+ finalRes = true;
200
+ _context2.t0 = _regeneratorRuntime().keys(setObj);
201
+ case 2:
202
+ if ((_context2.t1 = _context2.t0()).done) {
203
+ _context2.next = 10;
204
+ break;
205
+ }
206
+ key = _context2.t1.value;
207
+ _context2.next = 6;
208
+ return this.setValue(key, setObj[key]);
209
+ case 6:
210
+ if (_context2.sent) {
211
+ _context2.next = 8;
212
+ break;
213
+ }
214
+ finalRes = false;
215
+ case 8:
216
+ _context2.next = 2;
217
+ break;
218
+ case 10:
219
+ return _context2.abrupt("return", finalRes);
220
+ case 11:
221
+ case "end":
222
+ return _context2.stop();
223
+ }
224
+ }, _callee2, this);
225
+ }))).apply(this, arguments);
226
+ }
194
227
  /**
195
228
  * set value of a key only if the value is empty
196
229
  * @param key
197
230
  * @param value
198
231
  * @returns
199
232
  */
200
- function setDefaultValue(key, value) {
233
+ }, {
234
+ key: "setDefaultValue",
235
+ value: function setDefaultValue(key, value) {
201
236
  return _classPrivateMethodGet(this, _setDefaultProperty, _setDefaultProperty2).call(this, key, value);
202
237
  }
203
238
  }, {
@@ -210,30 +245,30 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValu
210
245
  * @param subvalue
211
246
  * @return true if changed , false otherwise
212
247
  */
213
- function setSubValue(_x3, _x4, _x5) {
214
- return (_setSubValue = _setSubValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, objKey, subvalue) {
248
+ function setSubValue(_x4, _x5, _x6) {
249
+ return (_setSubValue = _setSubValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, objKey, subvalue) {
215
250
  var sendChanges,
216
251
  isValueChanged,
217
252
  subval,
218
- _args2 = arguments;
219
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
220
- while (1) switch (_context2.prev = _context2.next) {
253
+ _args3 = arguments;
254
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
255
+ while (1) switch (_context3.prev = _context3.next) {
221
256
  case 0:
222
- sendChanges = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : "auto";
257
+ sendChanges = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : "auto";
223
258
  if (this.canModify) {
224
- _context2.next = 7;
259
+ _context3.next = 7;
225
260
  break;
226
261
  }
227
262
  if (!(this.__throw_errors !== false)) {
228
- _context2.next = 6;
263
+ _context3.next = 6;
229
264
  break;
230
265
  }
231
266
  throw Error("Cant use setValue when on readonly mode");
232
267
  case 6:
233
- return _context2.abrupt("return", false);
268
+ return _context3.abrupt("return", false);
234
269
  case 7:
235
270
  isValueChanged = false;
236
- _context2.prev = 8;
271
+ _context3.prev = 8;
237
272
  //if accessing subval of an object, make sure the object is not null
238
273
  subval = _classPrivateMethodGet(this, _getSubProperty, _getSubProperty2).call(this, key, objKey);
239
274
  if (!(0, _object.object_equals)(subval, subvalue, {
@@ -244,22 +279,22 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValu
244
279
  isValueChanged = true;
245
280
  } else isValueChanged = false;
246
281
  case 11:
247
- _context2.prev = 11;
282
+ _context3.prev = 11;
248
283
  if (!(sendChanges === true || sendChanges === "auto" && isValueChanged)) {
249
- _context2.next = 15;
284
+ _context3.next = 15;
250
285
  break;
251
286
  }
252
- _context2.next = 15;
287
+ _context3.next = 15;
253
288
  return this.notifyChanged("", key, objKey, subvalue);
254
289
  case 15:
255
- return _context2.finish(11);
290
+ return _context3.finish(11);
256
291
  case 16:
257
- return _context2.abrupt("return", isValueChanged);
292
+ return _context3.abrupt("return", isValueChanged);
258
293
  case 17:
259
294
  case "end":
260
- return _context2.stop();
295
+ return _context3.stop();
261
296
  }
262
- }, _callee2, this, [[8,, 11, 16]]);
297
+ }, _callee3, this, [[8,, 11, 16]]);
263
298
  }))).apply(this, arguments);
264
299
  }
265
300
  }, {
@@ -272,72 +307,72 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValu
272
307
  * @param sendChanges
273
308
  * @returns
274
309
  */
275
- function pushValue(_x6, _x7) {
276
- return (_pushValue = _pushValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
310
+ function pushValue(_x7, _x8) {
311
+ return (_pushValue = _pushValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, value) {
277
312
  var sendChanges,
278
313
  tempArray,
279
- _args3 = arguments;
280
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
281
- while (1) switch (_context3.prev = _context3.next) {
314
+ _args4 = arguments;
315
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
316
+ while (1) switch (_context4.prev = _context4.next) {
282
317
  case 0:
283
- sendChanges = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : "auto";
318
+ sendChanges = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "auto";
284
319
  if (!(value == null)) {
285
- _context3.next = 3;
320
+ _context4.next = 3;
286
321
  break;
287
322
  }
288
- return _context3.abrupt("return", false);
323
+ return _context4.abrupt("return", false);
289
324
  case 3:
290
325
  if (this.canModify) {
291
- _context3.next = 9;
326
+ _context4.next = 9;
292
327
  break;
293
328
  }
294
329
  if (!(this.__throw_errors !== false)) {
295
- _context3.next = 8;
330
+ _context4.next = 8;
296
331
  break;
297
332
  }
298
333
  throw Error("Cant use pushValue when on readonly mode");
299
334
  case 8:
300
- return _context3.abrupt("return", false);
335
+ return _context4.abrupt("return", false);
301
336
  case 9:
302
337
  if (_classPrivateMethodGet(this, _getProperty, _getProperty2).call(this, key) == null) {
303
338
  _classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, []);
304
339
  }
305
340
  tempArray = _classPrivateMethodGet(this, _getProperty, _getProperty2).call(this, key);
306
341
  if (Array.isArray(tempArray)) {
307
- _context3.next = 17;
342
+ _context4.next = 17;
308
343
  break;
309
344
  }
310
345
  if (!(this.__throw_errors !== false)) {
311
- _context3.next = 16;
346
+ _context4.next = 16;
312
347
  break;
313
348
  }
314
349
  throw Error("Cant use pushValue on non Array keys");
315
350
  case 16:
316
- return _context3.abrupt("return", false);
351
+ return _context4.abrupt("return", false);
317
352
  case 17:
318
353
  _classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, [].concat(_toConsumableArray(tempArray), [value]));
319
354
  if (!(sendChanges === true || sendChanges === "auto")) {
320
- _context3.next = 21;
355
+ _context4.next = 21;
321
356
  break;
322
357
  }
323
- _context3.next = 21;
358
+ _context4.next = 21;
324
359
  return this.notifyChanged("", key, value);
325
360
  case 21:
326
- return _context3.abrupt("return", tempArray);
361
+ return _context4.abrupt("return", tempArray);
327
362
  case 22:
328
363
  case "end":
329
- return _context3.stop();
364
+ return _context4.stop();
330
365
  }
331
- }, _callee3, this);
366
+ }, _callee4, this);
332
367
  }))).apply(this, arguments);
333
368
  }
334
369
  }, {
335
370
  key: "notifyChanged",
336
- value: function notifyChanged(_x8, _x9, _x10, _x11) {
337
- return (_notifyChanged = _notifyChanged || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(type, key, value, subvalue) {
371
+ value: function notifyChanged(_x9, _x10, _x11, _x12) {
372
+ return (_notifyChanged = _notifyChanged || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(type, key, value, subvalue) {
338
373
  var lc, manager_class;
339
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
340
- while (1) switch (_context4.prev = _context4.next) {
374
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
375
+ while (1) switch (_context5.prev = _context5.next) {
341
376
  case 0:
342
377
  if (value === undefined && type != "meta") value = this.getValue(key);
343
378
  this.__changed = true;
@@ -352,16 +387,16 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValu
352
387
  /* --------------------------- notify the manager --------------------------- */
353
388
  manager_class = this.manager;
354
389
  if (!(manager_class instanceof _ObjectManager["default"])) {
355
- _context4.next = 10;
390
+ _context5.next = 10;
356
391
  break;
357
392
  }
358
- _context4.next = 10;
393
+ _context5.next = 10;
359
394
  return manager_class.notifyChanged(type, key, value, subvalue);
360
395
  case 10:
361
396
  case "end":
362
- return _context4.stop();
397
+ return _context5.stop();
363
398
  }
364
- }, _callee4, this);
399
+ }, _callee5, this);
365
400
  }))).apply(this, arguments);
366
401
  }
367
402
  /**
@@ -405,23 +440,23 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValu
405
440
  */
406
441
  }, {
407
442
  key: "reset",
408
- value: function reset(_x12) {
409
- return (_reset = _reset || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key) {
443
+ value: function reset(_x13) {
444
+ return (_reset = _reset || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(key) {
410
445
  var notifyChanged,
411
- _args5 = arguments;
412
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
413
- while (1) switch (_context5.prev = _context5.next) {
446
+ _args6 = arguments;
447
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
448
+ while (1) switch (_context6.prev = _context6.next) {
414
449
  case 0:
415
- notifyChanged = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : "auto";
416
- _context5.next = 3;
450
+ notifyChanged = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : "auto";
451
+ _context6.next = 3;
417
452
  return this.setValue(key, this[key], notifyChanged);
418
453
  case 3:
419
- return _context5.abrupt("return", _context5.sent);
454
+ return _context6.abrupt("return", _context6.sent);
420
455
  case 4:
421
456
  case "end":
422
- return _context5.stop();
457
+ return _context6.stop();
423
458
  }
424
- }, _callee5, this);
459
+ }, _callee6, this);
425
460
  }))).apply(this, arguments);
426
461
  }
427
462
  /**
@@ -432,43 +467,43 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValu
432
467
  }, {
433
468
  key: "resetAll",
434
469
  value: function resetAll() {
435
- return (_resetAll = _resetAll || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
470
+ return (_resetAll = _resetAll || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
436
471
  var notifyChanged,
437
472
  fr,
438
473
  key,
439
- _args6 = arguments;
440
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
441
- while (1) switch (_context6.prev = _context6.next) {
474
+ _args7 = arguments;
475
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
476
+ while (1) switch (_context7.prev = _context7.next) {
442
477
  case 0:
443
- notifyChanged = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : "auto";
478
+ notifyChanged = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : "auto";
444
479
  fr = true;
445
- _context6.t0 = _regeneratorRuntime().keys(this.__delta);
480
+ _context7.t0 = _regeneratorRuntime().keys(this.__delta);
446
481
  case 3:
447
- if ((_context6.t1 = _context6.t0()).done) {
448
- _context6.next = 13;
482
+ if ((_context7.t1 = _context7.t0()).done) {
483
+ _context7.next = 13;
449
484
  break;
450
485
  }
451
- key = _context6.t1.value;
452
- _context6.t2 = fr;
453
- if (!_context6.t2) {
454
- _context6.next = 10;
486
+ key = _context7.t1.value;
487
+ _context7.t2 = fr;
488
+ if (!_context7.t2) {
489
+ _context7.next = 10;
455
490
  break;
456
491
  }
457
- _context6.next = 9;
492
+ _context7.next = 9;
458
493
  return this.reset(key, notifyChanged);
459
494
  case 9:
460
- _context6.t2 = _context6.sent;
495
+ _context7.t2 = _context7.sent;
461
496
  case 10:
462
- fr = _context6.t2;
463
- _context6.next = 3;
497
+ fr = _context7.t2;
498
+ _context7.next = 3;
464
499
  break;
465
500
  case 13:
466
- return _context6.abrupt("return", fr);
501
+ return _context7.abrupt("return", fr);
467
502
  case 14:
468
503
  case "end":
469
- return _context6.stop();
504
+ return _context7.stop();
470
505
  }
471
- }, _callee6, this);
506
+ }, _callee7, this);
472
507
  }))).apply(this, arguments);
473
508
  }
474
509
  /**
@@ -632,35 +667,35 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValu
632
667
  /* -------------------------------------------------------------------------- */
633
668
  /* Events */
634
669
  /* -------------------------------------------------------------------------- */
635
- function event_run(_x13) {
636
- return (_event_run = _event_run || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventName) {
670
+ function event_run(_x14) {
671
+ return (_event_run = _event_run || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(eventName) {
637
672
  var _this$manager;
638
673
  var _len,
639
674
  params,
640
675
  _key,
641
- _args7 = arguments;
642
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
643
- while (1) switch (_context7.prev = _context7.next) {
676
+ _args8 = arguments;
677
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
678
+ while (1) switch (_context8.prev = _context8.next) {
644
679
  case 0:
645
680
  if (this.manager) {
646
- _context7.next = 3;
681
+ _context8.next = 3;
647
682
  break;
648
683
  }
649
684
  if (this.__showErrors === true) console.error("you cant use events if your object has no manager");
650
- return _context7.abrupt("return");
685
+ return _context8.abrupt("return");
651
686
  case 3:
652
- for (_len = _args7.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
653
- params[_key - 1] = _args7[_key];
687
+ for (_len = _args8.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
688
+ params[_key - 1] = _args8[_key];
654
689
  }
655
- _context7.next = 6;
690
+ _context8.next = 6;
656
691
  return (_this$manager = this.manager).event_run.apply(_this$manager, [eventName].concat(params));
657
692
  case 6:
658
- return _context7.abrupt("return", _context7.sent);
693
+ return _context8.abrupt("return", _context8.sent);
659
694
  case 7:
660
695
  case "end":
661
- return _context7.stop();
696
+ return _context8.stop();
662
697
  }
663
- }, _callee7, this);
698
+ }, _callee8, this);
664
699
  }))).apply(this, arguments);
665
700
  }
666
701
  }, {
@@ -685,30 +720,30 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setSubValu
685
720
  }
686
721
  }, {
687
722
  key: "event_add",
688
- value: function event_add(_x14, _x15, _x16) {
689
- return (_event_add = _event_add || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(name, uname, runEvent) {
723
+ value: function event_add(_x15, _x16, _x17) {
724
+ return (_event_add = _event_add || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(name, uname, runEvent) {
690
725
  var onlyOn,
691
726
  runOnce,
692
- _args8 = arguments;
693
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
694
- while (1) switch (_context8.prev = _context8.next) {
727
+ _args9 = arguments;
728
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
729
+ while (1) switch (_context9.prev = _context9.next) {
695
730
  case 0:
696
- onlyOn = _args8.length > 3 && _args8[3] !== undefined ? _args8[3] : null;
697
- runOnce = _args8.length > 4 && _args8[4] !== undefined ? _args8[4] : false;
731
+ onlyOn = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : null;
732
+ runOnce = _args9.length > 4 && _args9[4] !== undefined ? _args9[4] : false;
698
733
  if (this.manager) {
699
- _context8.next = 5;
734
+ _context9.next = 5;
700
735
  break;
701
736
  }
702
737
  if (this.__showErrors === true) console.error("you cant use events if your object has no manager");
703
- return _context8.abrupt("return");
738
+ return _context9.abrupt("return");
704
739
  case 5:
705
- _context8.next = 7;
740
+ _context9.next = 7;
706
741
  return this.manager.event_add(name, uname, runEvent, onlyOn, runOnce);
707
742
  case 7:
708
743
  case "end":
709
- return _context8.stop();
744
+ return _context9.stop();
710
745
  }
711
- }, _callee8, this);
746
+ }, _callee9, this);
712
747
  }))).apply(this, arguments);
713
748
  }
714
749
  /* -------------------------------------------------------------------------- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.66",
3
+ "version": "1.4.67",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",