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