@azrico/webobject 1.5.8 → 1.5.9
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.
- package/dist/src/structs/SimpleObject.d.ts +12 -12
- package/dist/src/structs/SimpleObject.js +150 -174
- package/package.json +2 -2
|
@@ -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:
|
|
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:
|
|
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
|
-
|
|
168
|
+
subval,
|
|
167
169
|
old_value,
|
|
168
|
-
needsChange,
|
|
169
170
|
_this$manager,
|
|
170
171
|
_args = arguments;
|
|
171
172
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -185,51 +186,59 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
185
186
|
case 7:
|
|
186
187
|
return _context.abrupt("return", false);
|
|
187
188
|
case 8:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
keyExists = false;
|
|
190
|
+
if (typeof key === "string" && key.includes(".")) {
|
|
191
|
+
/* -------------------------------------------------------------------------- */
|
|
192
|
+
/* set value of object */
|
|
193
|
+
/* -------------------------------------------------------------------------- */
|
|
194
|
+
keysp = key.split(".");
|
|
195
|
+
mkey = keysp.shift();
|
|
196
|
+
keyExists = mkey in this.__delta;
|
|
197
|
+
subkey_part = keysp.shift(); //if accessing subval of an object, make sure the object is not null
|
|
198
|
+
subval = _assertClassBrand(_SimpleObject_brand, this, _getSubProperty).call(this, mkey, subkey_part);
|
|
199
|
+
isValueChanged = !(0, _object.object_equals)(subval, value, {
|
|
200
|
+
ignoredStartingWords: "_",
|
|
201
|
+
strictArrayCheck: true
|
|
202
|
+
});
|
|
203
|
+
if (isValueChanged) _assertClassBrand(_SimpleObject_brand, this, _setSubProperty).call(this, mkey, subkey_part, value);
|
|
204
|
+
} else {
|
|
205
|
+
/* -------------------------------------------------------------------------- */
|
|
206
|
+
/* set basic value */
|
|
207
|
+
/* -------------------------------------------------------------------------- */
|
|
208
|
+
mkey = key;
|
|
209
|
+
keyExists = mkey in this.__delta;
|
|
210
|
+
old_value = this.get(mkey);
|
|
211
|
+
isValueChanged = !(0, _object.object_equals)(old_value, value, {
|
|
212
|
+
strictArrayCheck: true,
|
|
213
|
+
ignoredStartingWords: "_"
|
|
214
|
+
});
|
|
215
|
+
if (isValueChanged) _assertClassBrand(_SimpleObject_brand, this, _setProperty).call(this, mkey, value);
|
|
191
216
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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);
|
|
217
|
+
if (autoApply && keyExists === false) {
|
|
218
|
+
/**
|
|
219
|
+
* if the field is not in delta
|
|
220
|
+
* instantly calls the `apply` function to remove from delta
|
|
221
|
+
*/
|
|
222
|
+
this.apply(mkey);
|
|
223
|
+
if (shouldNotify === "auto") shouldNotify = false;
|
|
224
|
+
}
|
|
225
|
+
if (isValueChanged) {
|
|
209
226
|
/**
|
|
210
227
|
* notify the manager when the state of `__has_delta` is changed
|
|
211
228
|
* managers can use this to detect if they need to save
|
|
212
229
|
*/
|
|
213
230
|
(_this$manager = this.manager) === null || _this$manager === void 0 || _this$manager.checkIsChanged();
|
|
214
231
|
}
|
|
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
232
|
/* --------------------------------- notify --------------------------------- */
|
|
224
|
-
if (!(shouldNotify === true || shouldNotify === "auto" &&
|
|
225
|
-
_context.next =
|
|
233
|
+
if (!(shouldNotify === true || shouldNotify === "auto" && isValueChanged)) {
|
|
234
|
+
_context.next = 15;
|
|
226
235
|
break;
|
|
227
236
|
}
|
|
228
|
-
_context.next =
|
|
237
|
+
_context.next = 15;
|
|
229
238
|
return this.notifyChanged("", key, value);
|
|
230
|
-
case
|
|
231
|
-
return _context.abrupt("return",
|
|
232
|
-
case
|
|
239
|
+
case 15:
|
|
240
|
+
return _context.abrupt("return", isValueChanged);
|
|
241
|
+
case 16:
|
|
233
242
|
case "end":
|
|
234
243
|
return _context.stop();
|
|
235
244
|
}
|
|
@@ -273,6 +282,40 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
273
282
|
}
|
|
274
283
|
return setPreferApply;
|
|
275
284
|
}()
|
|
285
|
+
/**
|
|
286
|
+
* set key of subObject
|
|
287
|
+
* @param key
|
|
288
|
+
* @param value
|
|
289
|
+
* @param subvalue
|
|
290
|
+
* @param sendChanges
|
|
291
|
+
* @return true if changed , false otherwise
|
|
292
|
+
*/
|
|
293
|
+
)
|
|
294
|
+
}, {
|
|
295
|
+
key: "setSubValue",
|
|
296
|
+
value: (function () {
|
|
297
|
+
var _setSubValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, objKey, subvalue) {
|
|
298
|
+
var sendChanges,
|
|
299
|
+
_args3 = arguments;
|
|
300
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
301
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
302
|
+
case 0:
|
|
303
|
+
sendChanges = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : "auto";
|
|
304
|
+
_context3.next = 3;
|
|
305
|
+
return this.set("".concat(String(key), ".").concat(objKey), subvalue, sendChanges);
|
|
306
|
+
case 3:
|
|
307
|
+
return _context3.abrupt("return", _context3.sent);
|
|
308
|
+
case 4:
|
|
309
|
+
case "end":
|
|
310
|
+
return _context3.stop();
|
|
311
|
+
}
|
|
312
|
+
}, _callee3, this);
|
|
313
|
+
}));
|
|
314
|
+
function setSubValue(_x5, _x6, _x7) {
|
|
315
|
+
return _setSubValue.apply(this, arguments);
|
|
316
|
+
}
|
|
317
|
+
return setSubValue;
|
|
318
|
+
}()
|
|
276
319
|
/* -------------------------------------------------------------------------- */
|
|
277
320
|
/* Load */
|
|
278
321
|
/* -------------------------------------------------------------------------- */
|
|
@@ -280,33 +323,33 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
280
323
|
}, {
|
|
281
324
|
key: "setTemp",
|
|
282
325
|
value: (function () {
|
|
283
|
-
var _setTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
326
|
+
var _setTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, value) {
|
|
284
327
|
var sendChanges,
|
|
285
328
|
isValueChanged,
|
|
286
|
-
|
|
287
|
-
return _regeneratorRuntime().wrap(function
|
|
288
|
-
while (1) switch (
|
|
329
|
+
_args4 = arguments;
|
|
330
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
331
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
289
332
|
case 0:
|
|
290
|
-
sendChanges =
|
|
291
|
-
|
|
333
|
+
sendChanges = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : false;
|
|
334
|
+
_context4.next = 3;
|
|
292
335
|
return _get(_getPrototypeOf(SimpleObject.prototype), "setTemp", this).call(this, key, value);
|
|
293
336
|
case 3:
|
|
294
|
-
isValueChanged =
|
|
337
|
+
isValueChanged = _context4.sent;
|
|
295
338
|
if (!(sendChanges === true || sendChanges === "auto" && isValueChanged)) {
|
|
296
|
-
|
|
339
|
+
_context4.next = 7;
|
|
297
340
|
break;
|
|
298
341
|
}
|
|
299
|
-
|
|
342
|
+
_context4.next = 7;
|
|
300
343
|
return this.notifyChanged("temp", key, value);
|
|
301
344
|
case 7:
|
|
302
|
-
return
|
|
345
|
+
return _context4.abrupt("return", isValueChanged);
|
|
303
346
|
case 8:
|
|
304
347
|
case "end":
|
|
305
|
-
return
|
|
348
|
+
return _context4.stop();
|
|
306
349
|
}
|
|
307
|
-
},
|
|
350
|
+
}, _callee4, this);
|
|
308
351
|
}));
|
|
309
|
-
function setTemp(
|
|
352
|
+
function setTemp(_x8, _x9) {
|
|
310
353
|
return _setTemp.apply(this, arguments);
|
|
311
354
|
}
|
|
312
355
|
return setTemp;
|
|
@@ -328,16 +371,16 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
328
371
|
}, {
|
|
329
372
|
key: "clearRefreshFunction",
|
|
330
373
|
value: ( /* ---------------------------- refresh functions --------------------------- */function () {
|
|
331
|
-
var _clearRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
332
|
-
return _regeneratorRuntime().wrap(function
|
|
333
|
-
while (1) switch (
|
|
374
|
+
var _clearRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
375
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
376
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
334
377
|
case 0:
|
|
335
378
|
this.__refresh_functions = undefined;
|
|
336
379
|
case 1:
|
|
337
380
|
case "end":
|
|
338
|
-
return
|
|
381
|
+
return _context5.stop();
|
|
339
382
|
}
|
|
340
|
-
},
|
|
383
|
+
}, _callee5, this);
|
|
341
384
|
}));
|
|
342
385
|
function clearRefreshFunction() {
|
|
343
386
|
return _clearRefreshFunction.apply(this, arguments);
|
|
@@ -347,21 +390,21 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
347
390
|
}, {
|
|
348
391
|
key: "setRefreshFunction",
|
|
349
392
|
value: function () {
|
|
350
|
-
var _setRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
351
|
-
return _regeneratorRuntime().wrap(function
|
|
352
|
-
while (1) switch (
|
|
393
|
+
var _setRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(new_fnc) {
|
|
394
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
395
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
353
396
|
case 0:
|
|
354
|
-
|
|
397
|
+
_context6.next = 2;
|
|
355
398
|
return this.addRefreshFunction(new_fnc);
|
|
356
399
|
case 2:
|
|
357
|
-
return
|
|
400
|
+
return _context6.abrupt("return", _context6.sent);
|
|
358
401
|
case 3:
|
|
359
402
|
case "end":
|
|
360
|
-
return
|
|
403
|
+
return _context6.stop();
|
|
361
404
|
}
|
|
362
|
-
},
|
|
405
|
+
}, _callee6, this);
|
|
363
406
|
}));
|
|
364
|
-
function setRefreshFunction(
|
|
407
|
+
function setRefreshFunction(_x10) {
|
|
365
408
|
return _setRefreshFunction.apply(this, arguments);
|
|
366
409
|
}
|
|
367
410
|
return setRefreshFunction;
|
|
@@ -369,10 +412,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
369
412
|
}, {
|
|
370
413
|
key: "addRefreshFunction",
|
|
371
414
|
value: function () {
|
|
372
|
-
var _addRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
415
|
+
var _addRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(key, new_fnc) {
|
|
373
416
|
var oldFunctions;
|
|
374
|
-
return _regeneratorRuntime().wrap(function
|
|
375
|
-
while (1) switch (
|
|
417
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
418
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
376
419
|
case 0:
|
|
377
420
|
if (typeof key === "function") {
|
|
378
421
|
new_fnc = key;
|
|
@@ -385,11 +428,11 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
385
428
|
this.__refresh_functions = oldFunctions;
|
|
386
429
|
case 6:
|
|
387
430
|
case "end":
|
|
388
|
-
return
|
|
431
|
+
return _context7.stop();
|
|
389
432
|
}
|
|
390
|
-
},
|
|
433
|
+
}, _callee7, this);
|
|
391
434
|
}));
|
|
392
|
-
function addRefreshFunction(
|
|
435
|
+
function addRefreshFunction(_x11, _x12) {
|
|
393
436
|
return _addRefreshFunction.apply(this, arguments);
|
|
394
437
|
}
|
|
395
438
|
return addRefreshFunction;
|
|
@@ -397,7 +440,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
397
440
|
}, {
|
|
398
441
|
key: "runRefreshFunction",
|
|
399
442
|
value: function () {
|
|
400
|
-
var _runRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
443
|
+
var _runRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
401
444
|
var oldFunctions,
|
|
402
445
|
fncArray,
|
|
403
446
|
_len,
|
|
@@ -405,39 +448,39 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
405
448
|
_key,
|
|
406
449
|
index,
|
|
407
450
|
fnc,
|
|
408
|
-
|
|
409
|
-
return _regeneratorRuntime().wrap(function
|
|
410
|
-
while (1) switch (
|
|
451
|
+
_args8 = arguments;
|
|
452
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
453
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
411
454
|
case 0:
|
|
412
455
|
oldFunctions = this.__refresh_functions;
|
|
413
456
|
if (!(oldFunctions == null || _typeof(oldFunctions) !== "object")) {
|
|
414
|
-
|
|
457
|
+
_context8.next = 3;
|
|
415
458
|
break;
|
|
416
459
|
}
|
|
417
|
-
return
|
|
460
|
+
return _context8.abrupt("return");
|
|
418
461
|
case 3:
|
|
419
462
|
fncArray = Object.values(oldFunctions);
|
|
420
|
-
for (_len =
|
|
421
|
-
params[_key] =
|
|
463
|
+
for (_len = _args8.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
464
|
+
params[_key] = _args8[_key];
|
|
422
465
|
}
|
|
423
466
|
index = 0;
|
|
424
467
|
case 6:
|
|
425
468
|
if (!(index < fncArray.length)) {
|
|
426
|
-
|
|
469
|
+
_context8.next = 13;
|
|
427
470
|
break;
|
|
428
471
|
}
|
|
429
472
|
fnc = fncArray[index];
|
|
430
|
-
|
|
473
|
+
_context8.next = 10;
|
|
431
474
|
return _object.fn_eval.apply(void 0, [fnc].concat(params));
|
|
432
475
|
case 10:
|
|
433
476
|
index++;
|
|
434
|
-
|
|
477
|
+
_context8.next = 6;
|
|
435
478
|
break;
|
|
436
479
|
case 13:
|
|
437
480
|
case "end":
|
|
438
|
-
return
|
|
481
|
+
return _context8.stop();
|
|
439
482
|
}
|
|
440
|
-
},
|
|
483
|
+
}, _callee8, this);
|
|
441
484
|
}));
|
|
442
485
|
function runRefreshFunction() {
|
|
443
486
|
return _runRefreshFunction.apply(this, arguments);
|
|
@@ -454,47 +497,47 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
454
497
|
}, {
|
|
455
498
|
key: "setAll",
|
|
456
499
|
value: (function () {
|
|
457
|
-
var _setAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
500
|
+
var _setAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(setObj) {
|
|
458
501
|
var changeablesOnly,
|
|
459
502
|
finalRes,
|
|
460
503
|
checkKeys,
|
|
461
504
|
index,
|
|
462
505
|
key,
|
|
463
|
-
|
|
464
|
-
return _regeneratorRuntime().wrap(function
|
|
465
|
-
while (1) switch (
|
|
506
|
+
_args9 = arguments;
|
|
507
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
508
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
466
509
|
case 0:
|
|
467
|
-
changeablesOnly =
|
|
510
|
+
changeablesOnly = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : true;
|
|
468
511
|
finalRes = true;
|
|
469
512
|
checkKeys = changeablesOnly ? (0, _object.array_intersection)(this.__changeables, Object.keys(setObj)) : Object.keys(setObj);
|
|
470
513
|
index = 0;
|
|
471
514
|
case 4:
|
|
472
515
|
if (!(index < checkKeys.length)) {
|
|
473
|
-
|
|
516
|
+
_context9.next = 13;
|
|
474
517
|
break;
|
|
475
518
|
}
|
|
476
519
|
key = checkKeys[index];
|
|
477
|
-
|
|
520
|
+
_context9.next = 8;
|
|
478
521
|
return this.set(key, setObj[key]);
|
|
479
522
|
case 8:
|
|
480
|
-
if (
|
|
481
|
-
|
|
523
|
+
if (_context9.sent) {
|
|
524
|
+
_context9.next = 10;
|
|
482
525
|
break;
|
|
483
526
|
}
|
|
484
527
|
finalRes = false;
|
|
485
528
|
case 10:
|
|
486
529
|
index++;
|
|
487
|
-
|
|
530
|
+
_context9.next = 4;
|
|
488
531
|
break;
|
|
489
532
|
case 13:
|
|
490
|
-
return
|
|
533
|
+
return _context9.abrupt("return", finalRes);
|
|
491
534
|
case 14:
|
|
492
535
|
case "end":
|
|
493
|
-
return
|
|
536
|
+
return _context9.stop();
|
|
494
537
|
}
|
|
495
|
-
},
|
|
538
|
+
}, _callee9, this);
|
|
496
539
|
}));
|
|
497
|
-
function setAll(
|
|
540
|
+
function setAll(_x13) {
|
|
498
541
|
return _setAll.apply(this, arguments);
|
|
499
542
|
}
|
|
500
543
|
return setAll;
|
|
@@ -512,72 +555,8 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
512
555
|
return _assertClassBrand(_SimpleObject_brand, this, _setDefaultProperty).call(this, key, value);
|
|
513
556
|
}
|
|
514
557
|
}, {
|
|
515
|
-
key: "
|
|
558
|
+
key: "pushValue",
|
|
516
559
|
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
560
|
/**
|
|
582
561
|
* Push a single value to array property
|
|
583
562
|
* @param key
|
|
@@ -585,10 +564,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
585
564
|
* @param sendChanges
|
|
586
565
|
* @returns
|
|
587
566
|
*/
|
|
588
|
-
)
|
|
589
|
-
}, {
|
|
590
|
-
key: "pushValue",
|
|
591
|
-
value: (function () {
|
|
567
|
+
function () {
|
|
592
568
|
var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, value) {
|
|
593
569
|
var sendChanges,
|
|
594
570
|
_args10 = arguments;
|
|
@@ -1264,9 +1240,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1264
1240
|
}
|
|
1265
1241
|
return obj[key];
|
|
1266
1242
|
}
|
|
1267
|
-
/* -------------------------------------------------------------------------- */
|
|
1268
|
-
/* set */
|
|
1269
|
-
/* -------------------------------------------------------------------------- */
|
|
1270
1243
|
}, {
|
|
1271
1244
|
key: "loadValues",
|
|
1272
1245
|
value: function loadValues(obj, initObject) {
|
|
@@ -1666,6 +1639,15 @@ function _setDefaultPropertyNow(key) {
|
|
|
1666
1639
|
}
|
|
1667
1640
|
return false;
|
|
1668
1641
|
}
|
|
1642
|
+
function _getSubProperty(key, subkey) {
|
|
1643
|
+
var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1644
|
+
var subobj = this.get(key, original);
|
|
1645
|
+
if (subobj == null || _typeof(subobj) !== "object") return undefined;
|
|
1646
|
+
return subobj[subkey];
|
|
1647
|
+
}
|
|
1648
|
+
/* -------------------------------------------------------------------------- */
|
|
1649
|
+
/* set */
|
|
1650
|
+
/* -------------------------------------------------------------------------- */
|
|
1669
1651
|
function _setSubProperty(key, subkey, value) {
|
|
1670
1652
|
var subobj = this.get(key);
|
|
1671
1653
|
//@ts-ignore
|
|
@@ -1673,12 +1655,6 @@ function _setSubProperty(key, subkey, value) {
|
|
|
1673
1655
|
subobj[subkey] = value;
|
|
1674
1656
|
_assertClassBrand(_SimpleObject_brand, this, _setProperty).call(this, key, subobj);
|
|
1675
1657
|
}
|
|
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
1658
|
/**
|
|
1683
1659
|
* update a property on this object by updating the `__delta`
|
|
1684
1660
|
* 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.
|
|
3
|
+
"version": "1.5.9",
|
|
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.
|
|
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",
|