vis-data 7.1.1 → 7.1.4
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/declarations/data-interface.d.ts +1 -28
- package/declarations/data-interface.d.ts.map +1 -1
- package/declarations/data-pipe.d.ts +0 -8
- package/declarations/data-pipe.d.ts.map +1 -1
- package/declarations/data-set-check.d.ts +0 -1
- package/declarations/data-set-check.d.ts.map +1 -1
- package/declarations/data-set-part.d.ts.map +1 -1
- package/declarations/data-set.d.ts +0 -16
- package/declarations/data-set.d.ts.map +1 -1
- package/declarations/data-stream.d.ts +0 -16
- package/declarations/data-stream.d.ts.map +1 -1
- package/declarations/data-view-check.d.ts +0 -1
- package/declarations/data-view-check.d.ts.map +1 -1
- package/declarations/data-view.d.ts +0 -1
- package/declarations/data-view.d.ts.map +1 -1
- package/declarations/queue.d.ts +0 -1
- package/declarations/queue.d.ts.map +1 -1
- package/dist/esm.js +7716 -2996
- package/dist/esm.js.map +1 -1
- package/dist/umd.js +12503 -7782
- package/dist/umd.js.map +1 -1
- package/esnext/esm/vis-data.js +64 -101
- package/esnext/esm/vis-data.js.map +1 -1
- package/esnext/esm/vis-data.min.js +3 -3
- package/esnext/esm/vis-data.min.js.map +1 -1
- package/esnext/umd/vis-data.js +67 -106
- package/esnext/umd/vis-data.js.map +1 -1
- package/esnext/umd/vis-data.min.js +3 -3
- package/esnext/umd/vis-data.min.js.map +1 -1
- package/package.json +36 -33
- package/peer/esm/vis-data.js +7713 -2991
- package/peer/esm/vis-data.js.map +1 -1
- package/peer/esm/vis-data.min.js +8 -27
- package/peer/esm/vis-data.min.js.map +1 -1
- package/peer/umd/vis-data.js +12459 -7737
- package/peer/umd/vis-data.js.map +1 -1
- package/peer/umd/vis-data.min.js +9 -28
- package/peer/umd/vis-data.min.js.map +1 -1
- package/standalone/esm/vis-data.js +7713 -2991
- package/standalone/esm/vis-data.js.map +1 -1
- package/standalone/esm/vis-data.min.js +8 -27
- package/standalone/esm/vis-data.min.js.map +1 -1
- package/standalone/umd/vis-data.js +12459 -7737
- package/standalone/umd/vis-data.js.map +1 -1
- package/standalone/umd/vis-data.min.js +9 -28
- package/standalone/umd/vis-data.min.js.map +1 -1
package/esnext/esm/vis-data.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Manage unstructured data using DataSet. Add, update, and remove data, and listen for changes in the data.
|
|
6
6
|
*
|
|
7
|
-
* @version 7.1.
|
|
8
|
-
* @date
|
|
7
|
+
* @version 7.1.4
|
|
8
|
+
* @date 2022-03-15T15:23:59.245Z
|
|
9
9
|
*
|
|
10
10
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
|
11
11
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
|
@@ -32,7 +32,6 @@ import { v4 } from 'uuid';
|
|
|
32
32
|
* Create new data pipe.
|
|
33
33
|
*
|
|
34
34
|
* @param from - The source data set or data view.
|
|
35
|
-
*
|
|
36
35
|
* @remarks
|
|
37
36
|
* Example usage:
|
|
38
37
|
* ```typescript
|
|
@@ -59,7 +58,6 @@ import { v4 } from 'uuid';
|
|
|
59
58
|
*
|
|
60
59
|
* pipe.start();
|
|
61
60
|
* ```
|
|
62
|
-
*
|
|
63
61
|
* @returns A factory whose methods can be used to configure the pipe.
|
|
64
62
|
*/
|
|
65
63
|
function createNewDataPipeFrom(from) {
|
|
@@ -75,6 +73,17 @@ function createNewDataPipeFrom(from) {
|
|
|
75
73
|
* @typeParam TP - Target item type's id property name.
|
|
76
74
|
*/
|
|
77
75
|
class SimpleDataPipe {
|
|
76
|
+
_source;
|
|
77
|
+
_transformers;
|
|
78
|
+
_target;
|
|
79
|
+
/**
|
|
80
|
+
* Bound listeners for use with `DataInterface['on' | 'off']`.
|
|
81
|
+
*/
|
|
82
|
+
_listeners = {
|
|
83
|
+
add: this._add.bind(this),
|
|
84
|
+
remove: this._remove.bind(this),
|
|
85
|
+
update: this._update.bind(this),
|
|
86
|
+
};
|
|
78
87
|
/**
|
|
79
88
|
* Create a new data pipe.
|
|
80
89
|
*
|
|
@@ -87,14 +96,6 @@ class SimpleDataPipe {
|
|
|
87
96
|
this._source = _source;
|
|
88
97
|
this._transformers = _transformers;
|
|
89
98
|
this._target = _target;
|
|
90
|
-
/**
|
|
91
|
-
* Bound listeners for use with `DataInterface['on' | 'off']`.
|
|
92
|
-
*/
|
|
93
|
-
this._listeners = {
|
|
94
|
-
add: this._add.bind(this),
|
|
95
|
-
remove: this._remove.bind(this),
|
|
96
|
-
update: this._update.bind(this),
|
|
97
|
-
};
|
|
98
99
|
}
|
|
99
100
|
/** @inheritDoc */
|
|
100
101
|
all() {
|
|
@@ -119,7 +120,6 @@ class SimpleDataPipe {
|
|
|
119
120
|
* Apply the transformers to the items.
|
|
120
121
|
*
|
|
121
122
|
* @param items - The items to be transformed.
|
|
122
|
-
*
|
|
123
123
|
* @returns The transformed items.
|
|
124
124
|
*/
|
|
125
125
|
_transformItems(items) {
|
|
@@ -172,6 +172,12 @@ class SimpleDataPipe {
|
|
|
172
172
|
* @typeParam TP - Target item type's id property name.
|
|
173
173
|
*/
|
|
174
174
|
class DataPipeUnderConstruction {
|
|
175
|
+
_source;
|
|
176
|
+
/**
|
|
177
|
+
* Array transformers used to transform items within the pipe. This is typed
|
|
178
|
+
* as any for the sake of simplicity.
|
|
179
|
+
*/
|
|
180
|
+
_transformers = [];
|
|
175
181
|
/**
|
|
176
182
|
* Create a new data pipe factory. This is an internal constructor that
|
|
177
183
|
* should never be called from outside of this file.
|
|
@@ -180,18 +186,12 @@ class DataPipeUnderConstruction {
|
|
|
180
186
|
*/
|
|
181
187
|
constructor(_source) {
|
|
182
188
|
this._source = _source;
|
|
183
|
-
/**
|
|
184
|
-
* Array transformers used to transform items within the pipe. This is typed
|
|
185
|
-
* as any for the sake of simplicity.
|
|
186
|
-
*/
|
|
187
|
-
this._transformers = [];
|
|
188
189
|
}
|
|
189
190
|
/**
|
|
190
191
|
* Filter the items.
|
|
191
192
|
*
|
|
192
193
|
* @param callback - A filtering function that returns true if given item
|
|
193
194
|
* should be piped and false if not.
|
|
194
|
-
*
|
|
195
195
|
* @returns This factory for further configuration.
|
|
196
196
|
*/
|
|
197
197
|
filter(callback) {
|
|
@@ -203,10 +203,8 @@ class DataPipeUnderConstruction {
|
|
|
203
203
|
*
|
|
204
204
|
* @param callback - A mapping function that takes a source item and returns
|
|
205
205
|
* corresponding mapped item.
|
|
206
|
-
*
|
|
207
206
|
* @typeParam TI - Target item type.
|
|
208
207
|
* @typeParam TP - Target item type's id property name.
|
|
209
|
-
*
|
|
210
208
|
* @returns This factory for further configuration.
|
|
211
209
|
*/
|
|
212
210
|
map(callback) {
|
|
@@ -218,10 +216,8 @@ class DataPipeUnderConstruction {
|
|
|
218
216
|
*
|
|
219
217
|
* @param callback - A mapping function that takes a source item and returns
|
|
220
218
|
* an array of corresponding mapped items.
|
|
221
|
-
*
|
|
222
219
|
* @typeParam TI - Target item type.
|
|
223
220
|
* @typeParam TP - Target item type's id property name.
|
|
224
|
-
*
|
|
225
221
|
* @returns This factory for further configuration.
|
|
226
222
|
*/
|
|
227
223
|
flatMap(callback) {
|
|
@@ -232,7 +228,6 @@ class DataPipeUnderConstruction {
|
|
|
232
228
|
* Connect this pipe to given data set.
|
|
233
229
|
*
|
|
234
230
|
* @param target - The data set that will receive the items from this pipe.
|
|
235
|
-
*
|
|
236
231
|
* @returns The pipe connected between given data sets and performing
|
|
237
232
|
* configured transformation on the processed items.
|
|
238
233
|
*/
|
|
@@ -245,7 +240,6 @@ class DataPipeUnderConstruction {
|
|
|
245
240
|
* Determine whether a value can be used as an id.
|
|
246
241
|
*
|
|
247
242
|
* @param value - Input value of unknown type.
|
|
248
|
-
*
|
|
249
243
|
* @returns True if the value is valid id, false otherwise.
|
|
250
244
|
*/
|
|
251
245
|
function isId(value) {
|
|
@@ -258,15 +252,19 @@ function isId(value) {
|
|
|
258
252
|
* @typeParam T - The type of method names to be replaced by queued versions.
|
|
259
253
|
*/
|
|
260
254
|
class Queue {
|
|
255
|
+
/** Delay in milliseconds. If defined the queue will be periodically flushed. */
|
|
256
|
+
delay;
|
|
257
|
+
/** Maximum number of entries in the queue before it will be flushed. */
|
|
258
|
+
max;
|
|
259
|
+
_queue = [];
|
|
260
|
+
_timeout = null;
|
|
261
|
+
_extended = null;
|
|
261
262
|
/**
|
|
262
263
|
* Construct a new Queue.
|
|
263
264
|
*
|
|
264
265
|
* @param options - Queue configuration.
|
|
265
266
|
*/
|
|
266
267
|
constructor(options) {
|
|
267
|
-
this._queue = [];
|
|
268
|
-
this._timeout = null;
|
|
269
|
-
this._extended = null;
|
|
270
268
|
// options
|
|
271
269
|
this.delay = null;
|
|
272
270
|
this.max = Infinity;
|
|
@@ -292,7 +290,6 @@ class Queue {
|
|
|
292
290
|
*
|
|
293
291
|
* @param object - The object to be extended.
|
|
294
292
|
* @param options - Additional options.
|
|
295
|
-
*
|
|
296
293
|
* @returns The created queue.
|
|
297
294
|
*/
|
|
298
295
|
static extend(object, options) {
|
|
@@ -421,22 +418,12 @@ class Queue {
|
|
|
421
418
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
422
419
|
*/
|
|
423
420
|
class DataSetPart {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
};
|
|
431
|
-
/**
|
|
432
|
-
* @deprecated Use on instead (PS: DataView.subscribe === DataView.on).
|
|
433
|
-
*/
|
|
434
|
-
this.subscribe = DataSetPart.prototype.on;
|
|
435
|
-
/**
|
|
436
|
-
* @deprecated Use off instead (PS: DataView.unsubscribe === DataView.off).
|
|
437
|
-
*/
|
|
438
|
-
this.unsubscribe = DataSetPart.prototype.off;
|
|
439
|
-
}
|
|
421
|
+
_subscribers = {
|
|
422
|
+
"*": [],
|
|
423
|
+
add: [],
|
|
424
|
+
remove: [],
|
|
425
|
+
update: [],
|
|
426
|
+
};
|
|
440
427
|
/**
|
|
441
428
|
* Trigger an event
|
|
442
429
|
*
|
|
@@ -456,7 +443,6 @@ class DataSetPart {
|
|
|
456
443
|
* Subscribe to an event, add an event listener.
|
|
457
444
|
*
|
|
458
445
|
* @remarks Non-function callbacks are ignored.
|
|
459
|
-
*
|
|
460
446
|
* @param event - Event name.
|
|
461
447
|
* @param callback - Callback method.
|
|
462
448
|
*/
|
|
@@ -470,13 +456,20 @@ class DataSetPart {
|
|
|
470
456
|
* Unsubscribe from an event, remove an event listener.
|
|
471
457
|
*
|
|
472
458
|
* @remarks If the same callback was subscribed more than once **all** occurences will be removed.
|
|
473
|
-
*
|
|
474
459
|
* @param event - Event name.
|
|
475
460
|
* @param callback - Callback method.
|
|
476
461
|
*/
|
|
477
462
|
off(event, callback) {
|
|
478
463
|
this._subscribers[event] = this._subscribers[event].filter((subscriber) => subscriber !== callback);
|
|
479
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* @deprecated Use on instead (PS: DataView.subscribe === DataView.on).
|
|
467
|
+
*/
|
|
468
|
+
subscribe = DataSetPart.prototype.on;
|
|
469
|
+
/**
|
|
470
|
+
* @deprecated Use off instead (PS: DataView.unsubscribe === DataView.off).
|
|
471
|
+
*/
|
|
472
|
+
unsubscribe = DataSetPart.prototype.off;
|
|
480
473
|
}
|
|
481
474
|
|
|
482
475
|
/**
|
|
@@ -486,10 +479,10 @@ class DataSetPart {
|
|
|
486
479
|
* [[DataStream]] offers an always up to date stream of items from a [[DataSet]] or [[DataView]].
|
|
487
480
|
* That means that the stream is evaluated at the time of iteration, conversion to another data type or when [[cache]] is called, not when the [[DataStream]] was created.
|
|
488
481
|
* Multiple invocations of for example [[toItemArray]] may yield different results (if the data source like for example [[DataSet]] gets modified).
|
|
489
|
-
*
|
|
490
482
|
* @typeParam Item - The item type this stream is going to work with.
|
|
491
483
|
*/
|
|
492
484
|
class DataStream {
|
|
485
|
+
_pairs;
|
|
493
486
|
/**
|
|
494
487
|
* Create a new data stream.
|
|
495
488
|
*
|
|
@@ -535,7 +528,6 @@ class DataStream {
|
|
|
535
528
|
*
|
|
536
529
|
* @remarks
|
|
537
530
|
* The array may contain duplicities.
|
|
538
|
-
*
|
|
539
531
|
* @returns The array with all ids from this stream.
|
|
540
532
|
*/
|
|
541
533
|
toIdArray() {
|
|
@@ -546,7 +538,6 @@ class DataStream {
|
|
|
546
538
|
*
|
|
547
539
|
* @remarks
|
|
548
540
|
* The array may contain duplicities.
|
|
549
|
-
*
|
|
550
541
|
* @returns The array with all items from this stream.
|
|
551
542
|
*/
|
|
552
543
|
toItemArray() {
|
|
@@ -557,7 +548,6 @@ class DataStream {
|
|
|
557
548
|
*
|
|
558
549
|
* @remarks
|
|
559
550
|
* The array may contain duplicities.
|
|
560
|
-
*
|
|
561
551
|
* @returns The array with all entries from this stream.
|
|
562
552
|
*/
|
|
563
553
|
toEntryArray() {
|
|
@@ -568,7 +558,6 @@ class DataStream {
|
|
|
568
558
|
*
|
|
569
559
|
* @remarks
|
|
570
560
|
* In case of duplicate ids (coerced to string so `7 == '7'`) the last encoutered appears in the returned object.
|
|
571
|
-
*
|
|
572
561
|
* @returns The object map of all id → item pairs from this stream.
|
|
573
562
|
*/
|
|
574
563
|
toObjectMap() {
|
|
@@ -622,7 +611,6 @@ class DataStream {
|
|
|
622
611
|
* ds.clear()
|
|
623
612
|
* chachedStream // Still has all the items.
|
|
624
613
|
* ```
|
|
625
|
-
*
|
|
626
614
|
* @returns A new [[DataStream]] with cached items (detached from the original [[DataSet]]).
|
|
627
615
|
*/
|
|
628
616
|
cache() {
|
|
@@ -632,9 +620,7 @@ class DataStream {
|
|
|
632
620
|
* Get the distinct values of given property.
|
|
633
621
|
*
|
|
634
622
|
* @param callback - The function that picks and possibly converts the property.
|
|
635
|
-
*
|
|
636
623
|
* @typeParam T - The type of the distinct value.
|
|
637
|
-
*
|
|
638
624
|
* @returns A set of all distinct properties.
|
|
639
625
|
*/
|
|
640
626
|
distinct(callback) {
|
|
@@ -648,7 +634,6 @@ class DataStream {
|
|
|
648
634
|
* Filter the items of the stream.
|
|
649
635
|
*
|
|
650
636
|
* @param callback - The function that decides whether an item will be included.
|
|
651
|
-
*
|
|
652
637
|
* @returns A new data stream with the filtered items.
|
|
653
638
|
*/
|
|
654
639
|
filter(callback) {
|
|
@@ -677,9 +662,7 @@ class DataStream {
|
|
|
677
662
|
* Map the items into a different type.
|
|
678
663
|
*
|
|
679
664
|
* @param callback - The function that does the conversion.
|
|
680
|
-
*
|
|
681
665
|
* @typeParam Mapped - The type of the item after mapping.
|
|
682
|
-
*
|
|
683
666
|
* @returns A new data stream with the mapped items.
|
|
684
667
|
*/
|
|
685
668
|
map(callback) {
|
|
@@ -696,7 +679,6 @@ class DataStream {
|
|
|
696
679
|
* Get the item with the maximum value of given property.
|
|
697
680
|
*
|
|
698
681
|
* @param callback - The function that picks and possibly converts the property.
|
|
699
|
-
*
|
|
700
682
|
* @returns The item with the maximum if found otherwise null.
|
|
701
683
|
*/
|
|
702
684
|
max(callback) {
|
|
@@ -721,7 +703,6 @@ class DataStream {
|
|
|
721
703
|
* Get the item with the minimum value of given property.
|
|
722
704
|
*
|
|
723
705
|
* @param callback - The function that picks and possibly converts the property.
|
|
724
|
-
*
|
|
725
706
|
* @returns The item with the minimum if found otherwise null.
|
|
726
707
|
*/
|
|
727
708
|
min(callback) {
|
|
@@ -747,9 +728,7 @@ class DataStream {
|
|
|
747
728
|
*
|
|
748
729
|
* @param callback - The function that does the reduction.
|
|
749
730
|
* @param accumulator - The initial value of the accumulator.
|
|
750
|
-
*
|
|
751
731
|
* @typeParam T - The type of the accumulated value.
|
|
752
|
-
*
|
|
753
732
|
* @returns The reduced value.
|
|
754
733
|
*/
|
|
755
734
|
reduce(callback, accumulator) {
|
|
@@ -762,7 +741,6 @@ class DataStream {
|
|
|
762
741
|
* Sort the items.
|
|
763
742
|
*
|
|
764
743
|
* @param callback - Item comparator.
|
|
765
|
-
*
|
|
766
744
|
* @returns A new stream with sorted items.
|
|
767
745
|
*/
|
|
768
746
|
sort(callback) {
|
|
@@ -778,13 +756,10 @@ class DataStream {
|
|
|
778
756
|
*
|
|
779
757
|
* @remarks
|
|
780
758
|
* The item will be modified.
|
|
781
|
-
*
|
|
782
759
|
* @param item - The item that will have an id after a call to this function.
|
|
783
760
|
* @param idProp - The key of the id property.
|
|
784
|
-
*
|
|
785
761
|
* @typeParam Item - Item type that may or may not have an id.
|
|
786
762
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
787
|
-
*
|
|
788
763
|
* @returns true
|
|
789
764
|
*/
|
|
790
765
|
function ensureFullItem(item, idProp) {
|
|
@@ -854,6 +829,18 @@ function ensureFullItem(item, idProp) {
|
|
|
854
829
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
855
830
|
*/
|
|
856
831
|
class DataSet extends DataSetPart {
|
|
832
|
+
/** Flush all queued calls. */
|
|
833
|
+
flush;
|
|
834
|
+
/** @inheritDoc */
|
|
835
|
+
length;
|
|
836
|
+
/** @inheritDoc */
|
|
837
|
+
get idProp() {
|
|
838
|
+
return this._idProp;
|
|
839
|
+
}
|
|
840
|
+
_options;
|
|
841
|
+
_data;
|
|
842
|
+
_idProp;
|
|
843
|
+
_queue = null;
|
|
857
844
|
/**
|
|
858
845
|
* Construct a new DataSet.
|
|
859
846
|
*
|
|
@@ -862,7 +849,6 @@ class DataSet extends DataSetPart {
|
|
|
862
849
|
*/
|
|
863
850
|
constructor(data, options) {
|
|
864
851
|
super();
|
|
865
|
-
this._queue = null;
|
|
866
852
|
// correctly read optional arguments
|
|
867
853
|
if (data && !Array.isArray(data)) {
|
|
868
854
|
options = data;
|
|
@@ -878,10 +864,6 @@ class DataSet extends DataSetPart {
|
|
|
878
864
|
}
|
|
879
865
|
this.setOptions(options);
|
|
880
866
|
}
|
|
881
|
-
/** @inheritDoc */
|
|
882
|
-
get idProp() {
|
|
883
|
-
return this._idProp;
|
|
884
|
-
}
|
|
885
867
|
/**
|
|
886
868
|
* Set new options.
|
|
887
869
|
*
|
|
@@ -932,9 +914,7 @@ class DataSet extends DataSetPart {
|
|
|
932
914
|
*
|
|
933
915
|
* @param data - Items to be added (ids will be generated if missing).
|
|
934
916
|
* @param senderId - Sender id.
|
|
935
|
-
*
|
|
936
917
|
* @returns addedIds - Array with the ids (generated if not present) of the added items.
|
|
937
|
-
*
|
|
938
918
|
* @throws When an item with the same id as any of the added items already exists.
|
|
939
919
|
*/
|
|
940
920
|
add(data, senderId) {
|
|
@@ -993,12 +973,9 @@ class DataSet extends DataSetPart {
|
|
|
993
973
|
*
|
|
994
974
|
* ## Warning for TypeScript users
|
|
995
975
|
* This method may introduce partial items into the data set. Use add or updateOnly instead for better type safety.
|
|
996
|
-
*
|
|
997
976
|
* @param data - Items to be updated (if the id is already present) or added (if the id is missing).
|
|
998
977
|
* @param senderId - Sender id.
|
|
999
|
-
*
|
|
1000
978
|
* @returns updatedIds - The ids of the added (these may be newly generated if there was no id in the item from the data) or updated items.
|
|
1001
|
-
*
|
|
1002
979
|
* @throws When the supplied data is neither an item nor an array of items.
|
|
1003
980
|
*/
|
|
1004
981
|
update(data, senderId) {
|
|
@@ -1087,12 +1064,9 @@ class DataSet extends DataSetPart {
|
|
|
1087
1064
|
*
|
|
1088
1065
|
* console.log(ids) // [2]
|
|
1089
1066
|
* ```
|
|
1090
|
-
*
|
|
1091
1067
|
* @param data - Updates (the id and optionally other props) to the items in this data set.
|
|
1092
1068
|
* @param senderId - Sender id.
|
|
1093
|
-
*
|
|
1094
1069
|
* @returns updatedIds - The ids of the updated items.
|
|
1095
|
-
*
|
|
1096
1070
|
* @throws When the supplied data is neither an item nor an array of items, when the ids are missing.
|
|
1097
1071
|
*/
|
|
1098
1072
|
updateOnly(data, senderId) {
|
|
@@ -1107,7 +1081,7 @@ class DataSet extends DataSetPart {
|
|
|
1107
1081
|
}
|
|
1108
1082
|
return { oldData, update };
|
|
1109
1083
|
})
|
|
1110
|
-
.map(({ oldData, update }) => {
|
|
1084
|
+
.map(({ oldData, update, }) => {
|
|
1111
1085
|
const id = oldData[this._idProp];
|
|
1112
1086
|
const updatedData = pureDeepObjectAssign(oldData, update);
|
|
1113
1087
|
this._data.set(id, updatedData);
|
|
@@ -1360,9 +1334,7 @@ class DataSet extends DataSetPart {
|
|
|
1360
1334
|
*
|
|
1361
1335
|
* @param item - The item whose fields should be filtered.
|
|
1362
1336
|
* @param fields - The names of the fields that will be kept.
|
|
1363
|
-
*
|
|
1364
1337
|
* @typeParam K - Field name type.
|
|
1365
|
-
*
|
|
1366
1338
|
* @returns The item without any additional fields.
|
|
1367
1339
|
*/
|
|
1368
1340
|
_filterFields(item, fields) {
|
|
@@ -1384,7 +1356,6 @@ class DataSet extends DataSetPart {
|
|
|
1384
1356
|
*
|
|
1385
1357
|
* @param items - Items to be sorted in place.
|
|
1386
1358
|
* @param order - A field name or custom sort function.
|
|
1387
|
-
*
|
|
1388
1359
|
* @typeParam T - The type of the items in the items array.
|
|
1389
1360
|
*/
|
|
1390
1361
|
_sort(items, order) {
|
|
@@ -1432,7 +1403,6 @@ class DataSet extends DataSetPart {
|
|
|
1432
1403
|
*
|
|
1433
1404
|
* @param id - One or more items or ids of items to be removed.
|
|
1434
1405
|
* @param senderId - Sender id.
|
|
1435
|
-
*
|
|
1436
1406
|
* @returns The ids of the removed items.
|
|
1437
1407
|
*/
|
|
1438
1408
|
remove(id, senderId) {
|
|
@@ -1459,7 +1429,6 @@ class DataSet extends DataSetPart {
|
|
|
1459
1429
|
* Remove an item by its id or reference.
|
|
1460
1430
|
*
|
|
1461
1431
|
* @param id - Id of an item or the item itself.
|
|
1462
|
-
*
|
|
1463
1432
|
* @returns The removed item if removed, null otherwise.
|
|
1464
1433
|
*/
|
|
1465
1434
|
_remove(id) {
|
|
@@ -1488,7 +1457,6 @@ class DataSet extends DataSetPart {
|
|
|
1488
1457
|
* After the items are removed, the [[DataSet]] will trigger an event `remove` for all removed items. When a `senderId` is provided, this id will be passed with the triggered event to all subscribers.
|
|
1489
1458
|
*
|
|
1490
1459
|
* @param senderId - Sender id.
|
|
1491
|
-
*
|
|
1492
1460
|
* @returns removedIds - The ids of all removed items.
|
|
1493
1461
|
*/
|
|
1494
1462
|
clear(senderId) {
|
|
@@ -1506,7 +1474,6 @@ class DataSet extends DataSetPart {
|
|
|
1506
1474
|
* Find the item with maximum value of a specified field.
|
|
1507
1475
|
*
|
|
1508
1476
|
* @param field - Name of the property that should be searched for max value.
|
|
1509
|
-
*
|
|
1510
1477
|
* @returns Item containing max value, or null if no items.
|
|
1511
1478
|
*/
|
|
1512
1479
|
max(field) {
|
|
@@ -1526,7 +1493,6 @@ class DataSet extends DataSetPart {
|
|
|
1526
1493
|
* Find the item with minimum value of a specified field.
|
|
1527
1494
|
*
|
|
1528
1495
|
* @param field - Name of the property that should be searched for min value.
|
|
1529
|
-
*
|
|
1530
1496
|
* @returns Item containing min value, or null if no items.
|
|
1531
1497
|
*/
|
|
1532
1498
|
min(field) {
|
|
@@ -1546,7 +1512,6 @@ class DataSet extends DataSetPart {
|
|
|
1546
1512
|
* Find all distinct values of a specified field
|
|
1547
1513
|
*
|
|
1548
1514
|
* @param prop - The property name whose distinct values should be returned.
|
|
1549
|
-
*
|
|
1550
1515
|
* @returns Unordered array containing all distinct values. Items without specified property are ignored.
|
|
1551
1516
|
*/
|
|
1552
1517
|
distinct(prop) {
|
|
@@ -1576,7 +1541,6 @@ class DataSet extends DataSetPart {
|
|
|
1576
1541
|
* Add a single item. Will fail when an item with the same id already exists.
|
|
1577
1542
|
*
|
|
1578
1543
|
* @param item - A new item to be added.
|
|
1579
|
-
*
|
|
1580
1544
|
* @returns Added item's id. An id is generated when it is not present in the item.
|
|
1581
1545
|
*/
|
|
1582
1546
|
_addItem(item) {
|
|
@@ -1596,7 +1560,6 @@ class DataSet extends DataSetPart {
|
|
|
1596
1560
|
* Will fail when the item has no id, or when there does not exist an item with the same id.
|
|
1597
1561
|
*
|
|
1598
1562
|
* @param update - The new item
|
|
1599
|
-
*
|
|
1600
1563
|
* @returns The id of the updated item.
|
|
1601
1564
|
*/
|
|
1602
1565
|
_updateItem(update) {
|
|
@@ -1683,6 +1646,16 @@ class DataSet extends DataSetPart {
|
|
|
1683
1646
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
1684
1647
|
*/
|
|
1685
1648
|
class DataView extends DataSetPart {
|
|
1649
|
+
/** @inheritDoc */
|
|
1650
|
+
length = 0;
|
|
1651
|
+
/** @inheritDoc */
|
|
1652
|
+
get idProp() {
|
|
1653
|
+
return this.getDataSet().idProp;
|
|
1654
|
+
}
|
|
1655
|
+
_listener;
|
|
1656
|
+
_data; // constructor → setData
|
|
1657
|
+
_ids = new Set(); // ids of the items currently in memory (just contains a boolean true)
|
|
1658
|
+
_options;
|
|
1686
1659
|
/**
|
|
1687
1660
|
* Create a DataView.
|
|
1688
1661
|
*
|
|
@@ -1691,24 +1664,16 @@ class DataView extends DataSetPart {
|
|
|
1691
1664
|
*/
|
|
1692
1665
|
constructor(data, options) {
|
|
1693
1666
|
super();
|
|
1694
|
-
/** @inheritDoc */
|
|
1695
|
-
this.length = 0;
|
|
1696
|
-
this._ids = new Set(); // ids of the items currently in memory (just contains a boolean true)
|
|
1697
1667
|
this._options = options || {};
|
|
1698
1668
|
this._listener = this._onEvent.bind(this);
|
|
1699
1669
|
this.setData(data);
|
|
1700
1670
|
}
|
|
1701
|
-
/** @inheritDoc */
|
|
1702
|
-
get idProp() {
|
|
1703
|
-
return this.getDataSet().idProp;
|
|
1704
|
-
}
|
|
1705
1671
|
// TODO: implement a function .config() to dynamically update things like configured filter
|
|
1706
1672
|
// and trigger changes accordingly
|
|
1707
1673
|
/**
|
|
1708
1674
|
* Set a data source for the view.
|
|
1709
1675
|
*
|
|
1710
1676
|
* @param data - The instance containing data (directly or indirectly).
|
|
1711
|
-
*
|
|
1712
1677
|
* @remarks
|
|
1713
1678
|
* Note that when the data view is bound to a data set it won't be garbage
|
|
1714
1679
|
* collected unless the data set is too. Use `dataView.setData(null)` or
|
|
@@ -2030,7 +1995,6 @@ class DataView extends DataSetPart {
|
|
|
2030
1995
|
*
|
|
2031
1996
|
* @param idProp - The expected property to contain item id.
|
|
2032
1997
|
* @param v - The value to be tested.
|
|
2033
|
-
*
|
|
2034
1998
|
* @returns True if all expected values and methods match, false otherwise.
|
|
2035
1999
|
*/
|
|
2036
2000
|
function isDataSetLike(idProp, v) {
|
|
@@ -2062,7 +2026,6 @@ function isDataSetLike(idProp, v) {
|
|
|
2062
2026
|
*
|
|
2063
2027
|
* @param idProp - The expected property to contain item id.
|
|
2064
2028
|
* @param v - The value to be tested.
|
|
2065
|
-
*
|
|
2066
2029
|
* @returns True if all expected values and methods match, false otherwise.
|
|
2067
2030
|
*/
|
|
2068
2031
|
function isDataViewLike(idProp, v) {
|