dataflux 1.2.5 → 1.4.2
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 +29 -24
- package/dist/Model.js +44 -6
- package/dist/Obj.js +46 -10
- package/dist/fingerprint.js +13 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -160,6 +160,8 @@ If now a book is inserted/deleted/edited:
|
|
|
160
160
|
* if the book has `price < 20`, `drawBooksCallback` will be called again with the new dataset;
|
|
161
161
|
* if the book has `price > 20`, `drawBooksCallback` will NOT be called again (because the new book doesn't impact our selection).
|
|
162
162
|
|
|
163
|
+
> Warning: if you edit the objects inside your callback (e.g., you do `.set()`), you will trigger the subscription's callback again in an infinite loop! If you want to set an attribute of an object inside your callback, before drawing it, use `setConstant()`.
|
|
164
|
+
|
|
163
165
|
You can terminate the subscription with `store.unsubscribe()`:
|
|
164
166
|
|
|
165
167
|
```js
|
|
@@ -261,17 +263,18 @@ const book = new Model("book", options);
|
|
|
261
263
|
|
|
262
264
|
All the possible options for a model creation are (they are all optional):
|
|
263
265
|
|
|
264
|
-
| Name
|
|
265
|
-
|
|
266
|
-
| retrieve
|
|
267
|
-
| insert
|
|
268
|
-
| update
|
|
269
|
-
| delete
|
|
270
|
-
| fields
|
|
271
|
-
| headers
|
|
272
|
-
| load
|
|
273
|
-
| axios
|
|
274
|
-
|
|
266
|
+
| Name | Description | Default |
|
|
267
|
+
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------|
|
|
268
|
+
| retrieve | Describes the operation to retrieve the collection of objects from the REST API. It can be an operation object or a function. See [operations](#operations). | `{method: "get"}` |
|
|
269
|
+
| insert | Describes the operation to insert a new object in the collection. It can be an operation object or a function. See [operations](#operations). | `{method: "post"}` |
|
|
270
|
+
| update | Describes the operation to update objects of the collection. It can be an operation object or a function. See [operations](#operations). | `{method: "put"}` |
|
|
271
|
+
| delete | Describes the operation to remove objects from the collection. It can be an operation object or a function. See [operations](#operations). | `{method: "delete"}` |
|
|
272
|
+
| fields | An array of strings defining which attributes the retrieved objects should have. Essentially, it allows you to contemporarily specify the [X-Fields header](https://flask-restplus.readthedocs.io/en/stable/mask.html) and the [fields GET parameter](https://developers.google.com/slides/api/guides/performance#partial). This reduces transfer size and memory usage. E.g., if you have a collection of books, of which you are interested only in the name, you can define `fields: ["name"]`. In combination with `load` it allows for partial lazy load of the objects. | All the fields |
|
|
273
|
+
| headers | A dictionary of headers for the HTTP request. E.g., `{"Authorization": "bearer XXXX"}`. | No headers |
|
|
274
|
+
| load | A function that allows to enrich the objects on demand. E.g., you can use `fields` to download only the titles of a collection of books, and `load` to load completely the object. See [object enrichment](#object-enrichment). |
|
|
275
|
+
| axios | It allows to specify an axios instance to be used for the queries. If not specified, a new one will be used. | A new axios instance |
|
|
276
|
+
| parseMoment | Automatically creates Moment.js objects out of ISO8601 strings. E.g., if an object has a property `createdAt: "2022-01-07T21:38:50.295Z"`, this will be transformed to a moment object. | |
|
|
277
|
+
| hiddenFields | An array of attribute names that will never be sent back to the API. E.g., if you set `hiddenFields: ["pages"]`, a book object can contain an attribute `pages` locally, but this will be stripped out in PUT/POST requests. |
|
|
275
278
|
|
|
276
279
|
### Operations
|
|
277
280
|
As described in the table above, there are four possible operations: **retrieve, insert, update,** and **delete**. An operation can be defined as an operation object or a function.
|
|
@@ -480,18 +483,20 @@ The store emits the following events:
|
|
|
480
483
|
Each object created is enriched with the following methods.
|
|
481
484
|
|
|
482
485
|
|
|
483
|
-
| Method | Description
|
|
484
|
-
|
|
485
|
-
| getId() | It returns a unique ID used by the store to identify the object. The ID is unique inside a single model. Be aware, `object.id` and `objet.getId()` may return different values, since store's IDs can be different from the one of the REST API.
|
|
486
|
-
| set(attribute, value)
|
|
487
|
-
|
|
|
488
|
-
|
|
|
489
|
-
|
|
|
490
|
-
|
|
|
491
|
-
|
|
|
492
|
-
|
|
493
|
-
|
|
|
494
|
-
|
|
|
486
|
+
| Method | Description |
|
|
487
|
+
|------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
488
|
+
| getId() | It returns a unique ID used by the store to identify the object. The ID is unique inside a single model. Be aware, `object.id` and `objet.getId()` may return different values, since store's IDs can be different from the one of the REST API. |
|
|
489
|
+
| set(attribute, value, hidden) | A method to set an attribute to the object. It provides some advantages compared to doing `object.attribute = value`, these are discussed in [below](#editing-objects). The third parameter is optional, and when set to true will set the attribute as hidden (see [hiddenFields](#models-creation)). |
|
|
490
|
+
| setConstant(attribute, value) | A method to set an unmodifiable hidden attribute on the object. Setting the attribute as a constant will not propagate an update. |
|
|
491
|
+
| get(attribute, defaultValue) | Method to retrieve the value of an attribute. It does not provide any advantage compared to accessing directly the attribute (e.g., `author.name`); except for hidden fields and constants, which can be retrieved only with the `.get` method. Additionally, you can provide a default value as a second parameter in case the object doesn't have that attribute. |
|
|
492
|
+
| getRelation(model, filterFunction) | To get all the objects respecting a specific relation with this object (see [model relations](#model-relations)). |
|
|
493
|
+
| save() | Method to save the object. You can do `store.save()` instead. |
|
|
494
|
+
| destroy() | Method to delete the object. You can do `store.delete()` instead. |
|
|
495
|
+
|
|
496
|
+
| toJSON() | It returns a pure JSON representation of the object. |
|
|
497
|
+
| toString() | It returns a string representation of the object. |
|
|
498
|
+
| getFingerprint() | It returns a hash of the object. The hash changes at every change of the object or of any nested object. Useful to detect object changes. |
|
|
499
|
+
| getModel() | It returns the model of this object. Mostly useful to do `object.getModel().getType()` and obtain a string defining the type of the object. |
|
|
495
500
|
|
|
496
501
|
## Editing objects
|
|
497
502
|
The option `autoSave` can be `true`, `false`, or a number (milliseconds).
|
|
@@ -517,7 +522,7 @@ The option `autoSave` can be `true`, `false`, or a number (milliseconds).
|
|
|
517
522
|
|
|
518
523
|
The store will perform as if the `autoSave` was set to `true`; hence, changes performed with `.set(attribute, value)` are synced. However, it will periodically attempt also a `store.save()`. Since `store.save()` is always able to recognize edited objects, also changes directly operated on an attribute of the object (`object.name = "Dante"`) are synced.
|
|
519
524
|
|
|
520
|
-
|
|
525
|
+
> The method set takes 3 parameters in input, "attribute, value, hidden". The "hidden" parameter allows you to set an attribute to the object that will not trigger autoSave. However, hidden attributes cannot be persisted (they act like "hiddenFields" specified during model creation).
|
|
521
526
|
|
|
522
527
|
## API interaction
|
|
523
528
|
DataFlux is able to identify three sets of objects: inserted, updated, deleted.
|
package/dist/Model.js
CHANGED
|
@@ -19,14 +19,16 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
19
19
|
|
|
20
20
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
21
|
|
|
22
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
-
|
|
24
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
25
|
-
|
|
26
22
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
27
23
|
|
|
28
24
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
25
|
|
|
26
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
27
|
+
|
|
28
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
|
+
|
|
30
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
31
|
+
|
|
30
32
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
31
33
|
|
|
32
34
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -87,12 +89,16 @@ var _axios = /*#__PURE__*/new WeakMap();
|
|
|
87
89
|
|
|
88
90
|
var _loadFunction = /*#__PURE__*/new WeakMap();
|
|
89
91
|
|
|
92
|
+
var _hiddenFields = /*#__PURE__*/new WeakMap();
|
|
93
|
+
|
|
90
94
|
var _error = /*#__PURE__*/new WeakSet();
|
|
91
95
|
|
|
92
96
|
var _addRelationByField = /*#__PURE__*/new WeakMap();
|
|
93
97
|
|
|
94
98
|
var _addRelationByFilter = /*#__PURE__*/new WeakMap();
|
|
95
99
|
|
|
100
|
+
var _removeHiddenFields = /*#__PURE__*/new WeakMap();
|
|
101
|
+
|
|
96
102
|
var _bulkOperation = /*#__PURE__*/new WeakMap();
|
|
97
103
|
|
|
98
104
|
var _toArray = /*#__PURE__*/new WeakMap();
|
|
@@ -167,6 +173,11 @@ var Model = /*#__PURE__*/_createClass(function Model(name) {
|
|
|
167
173
|
value: void 0
|
|
168
174
|
});
|
|
169
175
|
|
|
176
|
+
_classPrivateFieldInitSpec(this, _hiddenFields, {
|
|
177
|
+
writable: true,
|
|
178
|
+
value: void 0
|
|
179
|
+
});
|
|
180
|
+
|
|
170
181
|
_defineProperty(this, "getStore", function () {
|
|
171
182
|
return _classPrivateFieldGet(_this, _store);
|
|
172
183
|
});
|
|
@@ -293,16 +304,37 @@ var Model = /*#__PURE__*/_createClass(function Model(name) {
|
|
|
293
304
|
}
|
|
294
305
|
});
|
|
295
306
|
|
|
307
|
+
_classPrivateFieldInitSpec(this, _removeHiddenFields, {
|
|
308
|
+
writable: true,
|
|
309
|
+
value: function value(json) {
|
|
310
|
+
var _iterator = _createForOfIteratorHelper(_classPrivateFieldGet(_this, _hiddenFields)),
|
|
311
|
+
_step;
|
|
312
|
+
|
|
313
|
+
try {
|
|
314
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
315
|
+
var attribute = _step.value;
|
|
316
|
+
delete json[attribute];
|
|
317
|
+
}
|
|
318
|
+
} catch (err) {
|
|
319
|
+
_iterator.e(err);
|
|
320
|
+
} finally {
|
|
321
|
+
_iterator.f();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return json;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
|
|
296
328
|
_classPrivateFieldInitSpec(this, _bulkOperation, {
|
|
297
329
|
writable: true,
|
|
298
330
|
value: function value(objects, action) {
|
|
299
331
|
if (_classPrivateFieldGet(_this, _singleItemQuery)) {
|
|
300
332
|
return (0, _batchPromises["default"])(_classPrivateFieldGet(_this, _batchSize), objects.map(function (i) {
|
|
301
|
-
return i.toJSON();
|
|
333
|
+
return _classPrivateFieldGet(_this, _removeHiddenFields).call(_this, i.toJSON());
|
|
302
334
|
}), action);
|
|
303
335
|
} else {
|
|
304
336
|
return action(objects.map(function (i) {
|
|
305
|
-
return i.toJSON();
|
|
337
|
+
return _classPrivateFieldGet(_this, _removeHiddenFields).call(_this, i.toJSON());
|
|
306
338
|
}));
|
|
307
339
|
}
|
|
308
340
|
}
|
|
@@ -342,12 +374,18 @@ var Model = /*#__PURE__*/_createClass(function Model(name) {
|
|
|
342
374
|
|
|
343
375
|
_classPrivateFieldSet(this, _type, name);
|
|
344
376
|
|
|
377
|
+
this.options = {
|
|
378
|
+
parseMoment: options.parseMoment
|
|
379
|
+
};
|
|
380
|
+
|
|
345
381
|
_classPrivateFieldSet(this, _store, null);
|
|
346
382
|
|
|
347
383
|
_classPrivateFieldSet(this, _includes, {});
|
|
348
384
|
|
|
349
385
|
_classPrivateFieldSet(this, _axios, options.axios || _axios2["default"]);
|
|
350
386
|
|
|
387
|
+
_classPrivateFieldSet(this, _hiddenFields, options.hiddenFields || []);
|
|
388
|
+
|
|
351
389
|
_classPrivateFieldSet(this, _loadFunction, options.load || null);
|
|
352
390
|
|
|
353
391
|
if (!name || !options) {
|
package/dist/Obj.js
CHANGED
|
@@ -9,6 +9,8 @@ var _fingerprint = _interopRequireDefault(require("./fingerprint"));
|
|
|
9
9
|
|
|
10
10
|
var _uuid = require("uuid");
|
|
11
11
|
|
|
12
|
+
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
13
|
+
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
15
|
|
|
14
16
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -33,8 +35,12 @@ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!priva
|
|
|
33
35
|
|
|
34
36
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
35
37
|
|
|
38
|
+
var dateRegex = new RegExp("^[0-9][0-9][0-9][0-9]-[0-9].*T[0-9].*Z$");
|
|
39
|
+
|
|
36
40
|
var _loaded = /*#__PURE__*/new WeakMap();
|
|
37
41
|
|
|
42
|
+
var _setHidden = /*#__PURE__*/new WeakMap();
|
|
43
|
+
|
|
38
44
|
var Obj = /*#__PURE__*/_createClass(function Obj(values, _model) {
|
|
39
45
|
var _this = this;
|
|
40
46
|
|
|
@@ -45,6 +51,11 @@ var Obj = /*#__PURE__*/_createClass(function Obj(values, _model) {
|
|
|
45
51
|
value: false
|
|
46
52
|
});
|
|
47
53
|
|
|
54
|
+
_classPrivateFieldInitSpec(this, _setHidden, {
|
|
55
|
+
writable: true,
|
|
56
|
+
value: {}
|
|
57
|
+
});
|
|
58
|
+
|
|
48
59
|
_defineProperty(this, "load", function () {
|
|
49
60
|
if (_classPrivateFieldGet(_this, _loaded)) {
|
|
50
61
|
return Promise.resolve(_this);
|
|
@@ -65,23 +76,36 @@ var Obj = /*#__PURE__*/_createClass(function Obj(values, _model) {
|
|
|
65
76
|
return (0, _fingerprint["default"])(_this.toJSON());
|
|
66
77
|
});
|
|
67
78
|
|
|
68
|
-
_defineProperty(this, "get", function (attribute) {
|
|
69
|
-
|
|
79
|
+
_defineProperty(this, "get", function (attribute, defaultValue) {
|
|
80
|
+
var _ref, _classPrivateFieldGet2;
|
|
81
|
+
|
|
82
|
+
return (_ref = (_classPrivateFieldGet2 = _classPrivateFieldGet(_this, _setHidden)[attribute]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : _this[attribute]) !== null && _ref !== void 0 ? _ref : defaultValue;
|
|
70
83
|
});
|
|
71
84
|
|
|
72
85
|
_defineProperty(this, "getRelation", function (type, filterFunction) {
|
|
73
86
|
return _this.getModel().getRelation(_this, type, filterFunction);
|
|
74
87
|
});
|
|
75
88
|
|
|
76
|
-
_defineProperty(this, "set", function (attribute, value) {
|
|
77
|
-
if (
|
|
78
|
-
|
|
89
|
+
_defineProperty(this, "set", function (attribute, value, hidden) {
|
|
90
|
+
if (hidden) {
|
|
91
|
+
_classPrivateFieldGet(_this, _setHidden)[attribute] = value;
|
|
92
|
+
} else {
|
|
93
|
+
if (attribute === "id") {
|
|
94
|
+
throw new Error("You cannot change the ID");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
_this[attribute] = value;
|
|
79
98
|
}
|
|
80
99
|
|
|
81
|
-
_this[attribute] = value;
|
|
82
100
|
return _this.getModel().getStore().update([_this]);
|
|
83
101
|
});
|
|
84
102
|
|
|
103
|
+
_defineProperty(this, "setConstant", function (attribute, value) {
|
|
104
|
+
var _classPrivateFieldGet3;
|
|
105
|
+
|
|
106
|
+
_classPrivateFieldGet(_this, _setHidden)[attribute] = (_classPrivateFieldGet3 = _classPrivateFieldGet(_this, _setHidden)[attribute]) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : value;
|
|
107
|
+
});
|
|
108
|
+
|
|
85
109
|
_defineProperty(this, "save", function () {
|
|
86
110
|
return _this.getModel().getStore().save([_this]);
|
|
87
111
|
});
|
|
@@ -97,7 +121,11 @@ var Obj = /*#__PURE__*/_createClass(function Obj(values, _model) {
|
|
|
97
121
|
for (var _i = 0, _attrs = attrs; _i < _attrs.length; _i++) {
|
|
98
122
|
var a = _attrs[_i];
|
|
99
123
|
|
|
100
|
-
if (
|
|
124
|
+
if (_this[a] instanceof _moment["default"]) {
|
|
125
|
+
out[a] = _this[a].toISOString();
|
|
126
|
+
} else if (_this[a] instanceof Date) {
|
|
127
|
+
out[a] = (0, _moment["default"])(_this[a]).toISOString();
|
|
128
|
+
} else if (typeof _this[a] !== "function") {
|
|
101
129
|
out[a] = _this[a];
|
|
102
130
|
}
|
|
103
131
|
}
|
|
@@ -113,9 +141,17 @@ var Obj = /*#__PURE__*/_createClass(function Obj(values, _model) {
|
|
|
113
141
|
return _model;
|
|
114
142
|
};
|
|
115
143
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
144
|
+
var frEach = _model.options.parseMoment ? function (key) {
|
|
145
|
+
if (dateRegex.test(values[key])) {
|
|
146
|
+
var mmnt = (0, _moment["default"])(values[key]);
|
|
147
|
+
_this[key] = mmnt.isValid() ? mmnt : values[key];
|
|
148
|
+
} else {
|
|
149
|
+
_this[key] = values[key];
|
|
150
|
+
}
|
|
151
|
+
} : function (key) {
|
|
152
|
+
return _this[key] = values[key];
|
|
153
|
+
};
|
|
154
|
+
Object.keys(values).forEach(frEach);
|
|
119
155
|
var id;
|
|
120
156
|
|
|
121
157
|
if (this.id && (typeof this.id === "string" || typeof this.id === "number")) {
|
package/dist/fingerprint.js
CHANGED
|
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = fingerprint;
|
|
7
7
|
|
|
8
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
|
|
8
12
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
9
13
|
|
|
10
14
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -18,7 +22,15 @@ var CRC32 = require('crc-32');
|
|
|
18
22
|
var _getFingerprint = function _getFingerprint(object) {
|
|
19
23
|
switch (_typeof(object)) {
|
|
20
24
|
case "object":
|
|
21
|
-
|
|
25
|
+
if (object._isAMomentObject) {
|
|
26
|
+
return "m:".concat(object.toISOString());
|
|
27
|
+
} else if (object instanceof Date) {
|
|
28
|
+
return "m:".concat((0, _moment["default"])(object).toISOString());
|
|
29
|
+
} else if (object !== null) {
|
|
30
|
+
return "o:".concat(getObjectFingerprint(object));
|
|
31
|
+
} else {
|
|
32
|
+
return "o:null";
|
|
33
|
+
}
|
|
22
34
|
|
|
23
35
|
case "boolean":
|
|
24
36
|
return "b:".concat(object ? "t" : "f");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dataflux",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "DataFlux, automatically interfaces with your REST APIs to create a 2-way-synced local data store. Transparently manages data propagation in the React state.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": "dist/index.js",
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
"batch-promises": "^0.0.3",
|
|
98
98
|
"brembo": "^2.0.6",
|
|
99
99
|
"crc-32": "^1.2.0",
|
|
100
|
+
"moment": "^2.29.1",
|
|
100
101
|
"uuid": "^8.3.2"
|
|
101
102
|
},
|
|
102
103
|
"resolutions": {}
|