1 | import {Transform, stableCompare} from 'vega-dataflow';
|
2 | import {inherits} from 'vega-util';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export default function SortItems(params) {
|
12 | Transform.call(this, null, params);
|
13 | }
|
14 |
|
15 | var prototype = inherits(SortItems, Transform);
|
16 |
|
17 | prototype.transform = function(_, pulse) {
|
18 | var mod = _.modified('sort')
|
19 | || pulse.changed(pulse.ADD)
|
20 | || pulse.modified(_.sort.fields)
|
21 | || pulse.modified('datum');
|
22 |
|
23 | if (mod) pulse.source.sort(stableCompare(_.sort));
|
24 |
|
25 | this.modified(mod);
|
26 | return pulse;
|
27 | };
|