@azrico/webobject 1.3.5 → 1.3.6

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/README.md CHANGED
@@ -1,52 +1,52 @@
1
- # deus-object
2
-
3
- > Some useful object functions
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install --save deus-object
9
- ```
10
-
11
- ## Functions
12
-
13
- ```js
14
- object_clone(object);
15
- object_first(object);
16
- object_update(a, b);
17
- object_delta(a, b);
18
- object_has_delta(object);
19
- object_equals(a, b);
20
- isEmpty(object);
21
- ```
22
-
23
- ## Usage
24
-
25
- ```js
26
- import React, { Component } from 'react'
27
- import { View } from 'react-native'
28
- import FuncObject from 'deus-object'
29
-
30
- class Example extends Component {
31
-
32
- let eq1=FuncObject.object_equals({a:"b"},{a:"b"});//true
33
- let eq2=FuncObject.object_equals({a:"b"},{a:"c"});//false
34
-
35
- let ie1=FuncObject.isEmpty({}); //true
36
- let ie2=FuncObject.isEmpty([]); //true
37
- let ie3=FuncObject.isEmpty(null);//true
38
- let ie4=FuncObject.isEmpty({test:"a"});//false
39
-
40
- let if1=FuncObject.object_first({a:"a",b:"b",c:"c"});// a:"a"
41
- let if2=FuncObject.object_first([1,2,3,4]);//1
42
-
43
-
44
- render() {
45
- return <View></View>
46
- }
47
- }
48
- ```
49
-
50
- ## License
51
-
52
- MIT © [](https://github.com/)
1
+ # deus-object
2
+
3
+ > Some useful object functions
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install --save deus-object
9
+ ```
10
+
11
+ ## Functions
12
+
13
+ ```js
14
+ object_clone(object);
15
+ object_first(object);
16
+ object_update(a, b);
17
+ object_delta(a, b);
18
+ object_has_delta(object);
19
+ object_equals(a, b);
20
+ isEmpty(object);
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```js
26
+ import React, { Component } from 'react'
27
+ import { View } from 'react-native'
28
+ import FuncObject from 'deus-object'
29
+
30
+ class Example extends Component {
31
+
32
+ let eq1=FuncObject.object_equals({a:"b"},{a:"b"});//true
33
+ let eq2=FuncObject.object_equals({a:"b"},{a:"c"});//false
34
+
35
+ let ie1=FuncObject.isEmpty({}); //true
36
+ let ie2=FuncObject.isEmpty([]); //true
37
+ let ie3=FuncObject.isEmpty(null);//true
38
+ let ie4=FuncObject.isEmpty({test:"a"});//false
39
+
40
+ let if1=FuncObject.object_first({a:"a",b:"b",c:"c"});// a:"a"
41
+ let if2=FuncObject.object_first([1,2,3,4]);//1
42
+
43
+
44
+ render() {
45
+ return <View></View>
46
+ }
47
+ }
48
+ ```
49
+
50
+ ## License
51
+
52
+ MIT © [](https://github.com/)
@@ -30,6 +30,8 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
30
30
  var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
31
31
  _inherits(WebObjectManager, _ObjectManager);
32
32
  var _super = _createSuper(WebObjectManager);
33
+ //we use this as backup
34
+
33
35
  /* -------------------------------------------------------------------------- */
34
36
  function WebObjectManager() {
35
37
  var _this;
@@ -331,7 +333,6 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
331
333
  return WebObjectManager;
332
334
  }(_ObjectManager2["default"]);
333
335
  exports.WebObjectManager = WebObjectManager;
334
- //we use this as backup
335
336
  _defineProperty(WebObjectManager, "__web_path", "");
336
337
  _defineProperty(WebObjectManager, "__web_type", "");
337
338
  _defineProperty(WebObjectManager, "__save_message", true);
@@ -12,14 +12,15 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
12
12
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
13
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
14
  var ObjectArray = /*#__PURE__*/function () {
15
+ /* -------------------------------------------------------------------------- */
16
+ /* Values */
17
+ /* -------------------------------------------------------------------------- */
18
+
15
19
  /* -------------------------------------------------------------------------- */
16
20
  /* Base */
17
21
  /* -------------------------------------------------------------------------- */
18
22
  function ObjectArray(initObject, mapto_type) {
19
23
  _classCallCheck(this, ObjectArray);
20
- /* -------------------------------------------------------------------------- */
21
- /* Values */
22
- /* -------------------------------------------------------------------------- */
23
24
  _defineProperty(this, "objArray", []);
24
25
  this.setObjects(initObject, mapto_type);
25
26
  }
@@ -34,8 +34,8 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
34
34
  getSaveResultType(): saveResultType | null;
35
35
  setSaveResult(toObj: any, type: saveResultType): void | undefined;
36
36
  apply_changes(): boolean;
37
- getValue(key: PropOf<ObjType>, original?: boolean): import("./SimpleObject").PropType<ObjType, any> | undefined;
38
- get: (key: PropOf<ObjType>, original?: boolean) => import("./SimpleObject").PropType<ObjType, any> | undefined;
37
+ getValue(key: PropOf<ObjType>, original?: boolean): import("./SimpleObject").PropType<ObjType, any> | null;
38
+ get: (key: PropOf<ObjType>, original?: boolean) => import("./SimpleObject").PropType<ObjType, any> | null;
39
39
  /**
40
40
  * set value
41
41
  * @param key
@@ -166,9 +166,10 @@ var ObjectManager = /*#__PURE__*/function () {
166
166
  }, {
167
167
  key: "getValue",
168
168
  value: function getValue(key) {
169
- var _this$obj6;
170
169
  var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
171
- return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.getValue(key, original);
170
+ var thisobj = this.obj;
171
+ if (thisobj == null || typeof thisobj.getValue != "function") return null;
172
+ return thisobj.getValue(key, original);
172
173
  }
173
174
  }, {
174
175
  key: "setValue",
@@ -181,22 +182,29 @@ var ObjectManager = /*#__PURE__*/function () {
181
182
  */
182
183
  function () {
183
184
  var _setValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
184
- var _this$obj7;
185
+ var thisobj;
185
186
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
186
187
  while (1) switch (_context2.prev = _context2.next) {
187
188
  case 0:
188
- _context2.next = 2;
189
- return (_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.setValue(key, value);
190
- case 2:
189
+ thisobj = this.obj;
190
+ if (!(thisobj == null || typeof thisobj.setValue != "function")) {
191
+ _context2.next = 3;
192
+ break;
193
+ }
194
+ return _context2.abrupt("return", false);
195
+ case 3:
196
+ _context2.next = 5;
197
+ return thisobj.setValue(key, value);
198
+ case 5:
191
199
  _context2.t0 = _context2.sent;
192
200
  if (_context2.t0) {
193
- _context2.next = 5;
201
+ _context2.next = 8;
194
202
  break;
195
203
  }
196
204
  _context2.t0 = false;
197
- case 5:
205
+ case 8:
198
206
  return _context2.abrupt("return", _context2.t0);
199
- case 6:
207
+ case 9:
200
208
  case "end":
201
209
  return _context2.stop();
202
210
  }
@@ -218,12 +226,12 @@ var ObjectManager = /*#__PURE__*/function () {
218
226
  key: "setSubValue",
219
227
  value: function () {
220
228
  var _setSubValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, objKey, subvalue) {
221
- var _this$obj8;
229
+ var _this$obj6;
222
230
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
223
231
  while (1) switch (_context3.prev = _context3.next) {
224
232
  case 0:
225
233
  _context3.next = 2;
226
- return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.setSubValue(key, objKey, subvalue);
234
+ return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.setSubValue(key, objKey, subvalue);
227
235
  case 2:
228
236
  _context3.t0 = _context3.sent;
229
237
  if (_context3.t0) {
@@ -248,12 +256,12 @@ var ObjectManager = /*#__PURE__*/function () {
248
256
  key: "pushValue",
249
257
  value: function () {
250
258
  var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, value) {
251
- var _this$obj9;
259
+ var _this$obj7;
252
260
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
253
261
  while (1) switch (_context4.prev = _context4.next) {
254
262
  case 0:
255
263
  _context4.next = 2;
256
- return (_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.pushValue(key, value);
264
+ return (_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.pushValue(key, value);
257
265
  case 2:
258
266
  _context4.t0 = _context4.sent;
259
267
  if (_context4.t0) {
@@ -277,20 +285,20 @@ var ObjectManager = /*#__PURE__*/function () {
277
285
  }, {
278
286
  key: "getIndexOrID",
279
287
  value: function getIndexOrID() {
280
- var _this$obj10;
281
- return ((_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.getIndexOrID()) || -1;
288
+ var _this$obj8;
289
+ return ((_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.getIndexOrID()) || -1;
282
290
  }
283
291
  }, {
284
292
  key: "getIndex",
285
293
  value: function getIndex() {
286
- var _this$obj11;
287
- return ((_this$obj11 = this.obj) === null || _this$obj11 === void 0 ? void 0 : _this$obj11.getIndex()) || -1;
294
+ var _this$obj9;
295
+ return ((_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.getIndex()) || -1;
288
296
  }
289
297
  }, {
290
298
  key: "getID",
291
299
  value: function getID() {
292
- var _this$obj12;
293
- return ((_this$obj12 = this.obj) === null || _this$obj12 === void 0 ? void 0 : _this$obj12.getID()) || "";
300
+ var _this$obj10;
301
+ return ((_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.getID()) || "";
294
302
  }
295
303
  /* -------------------------------------------------------------------------- */
296
304
  /* Getters */
@@ -97,7 +97,14 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
97
97
  }
98
98
  _createClass(SimpleObject, [{
99
99
  key: "_static",
100
- value: function _static() {
100
+ value:
101
+ //these properties should not be changed and are usually set by server
102
+
103
+ //these properties can be directly changed and are included in deltaObject
104
+
105
+ //these properties usually are not directly changed and sometimes are included in deltaObject
106
+
107
+ function _static() {
101
108
  return this.constructor;
102
109
  }
103
110
  }, {
@@ -859,11 +866,8 @@ function _setSaveResultObject2(toObj) {
859
866
  this.__saveResultObject = toObj;
860
867
  }
861
868
  _defineProperty(SimpleObject, "__cache_name", void 0);
862
- //these properties should not be changed and are usually set by server
863
869
  _defineProperty(SimpleObject, "__unchangeables", void 0);
864
- //these properties can be directly changed and are included in deltaObject
865
870
  _defineProperty(SimpleObject, "__changeables", void 0);
866
- //these properties usually are not directly changed and sometimes are included in deltaObject
867
871
  _defineProperty(SimpleObject, "__extraProperties", void 0);
868
872
  _defineProperty(SimpleObject, "__use_delta", true);
869
873
  var _default = SimpleObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",