@ejfdelgado/ejflab-common 1.16.7 → 1.16.10
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/package.json +1 -1
- package/src/MyTuples.js +19 -6
package/package.json
CHANGED
package/src/MyTuples.js
CHANGED
|
@@ -4,6 +4,20 @@ const { SimpleObj } = require("./SimpleObj");
|
|
|
4
4
|
const TAMANIO_ALEATORIO = 10;
|
|
5
5
|
const MAX_BUFFER_CHANGES = 50;
|
|
6
6
|
|
|
7
|
+
const compFun = (a, b) => {
|
|
8
|
+
return a.k.length - b.k.length;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const compFunInverted = (a, b) => {
|
|
12
|
+
return b.k.length - a.k.length;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const assureSorted = (batch) => {
|
|
16
|
+
batch['*'].sort(compFun);
|
|
17
|
+
batch['-'].sort(compFunInverted);
|
|
18
|
+
batch['+'].sort(compFun);
|
|
19
|
+
};
|
|
20
|
+
|
|
7
21
|
const fakeProcessor = ({ min = 500, max = 1000 }) => {
|
|
8
22
|
return new Promise((resolve) => {
|
|
9
23
|
const tiempo = min + Math.random() * (max - min);
|
|
@@ -327,6 +341,10 @@ class MyTuples {
|
|
|
327
341
|
},
|
|
328
342
|
affect: (batch, listenerKeys = [], callback = null) => {
|
|
329
343
|
const tuplas1 = MyTuples.getTuples(JSON.parse(myFreeze));
|
|
344
|
+
|
|
345
|
+
// assure changes are sorted
|
|
346
|
+
assureSorted(batch);
|
|
347
|
+
|
|
330
348
|
const llavesBorrar = batch["-"];
|
|
331
349
|
const llavesNuevasModificadas = batch["*"].concat(batch["+"]);
|
|
332
350
|
|
|
@@ -420,12 +438,7 @@ class MyTuples {
|
|
|
420
438
|
}
|
|
421
439
|
}
|
|
422
440
|
|
|
423
|
-
|
|
424
|
-
return a.k.length - b.k.length;
|
|
425
|
-
};
|
|
426
|
-
batch['*'].sort(compFun);
|
|
427
|
-
batch['-'].sort(compFun);
|
|
428
|
-
batch['+'].sort(compFun);
|
|
441
|
+
assureSorted(batch);
|
|
429
442
|
|
|
430
443
|
batch.total = batch['*'].length + batch['-'].length + batch['+'].length;
|
|
431
444
|
if (batch.total > 0) {
|