@ejfdelgado/ejflab-common 1.16.6 → 1.16.9
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 +17 -6
- package/src/MyTuples.test.js +6 -2
package/package.json
CHANGED
package/src/MyTuples.js
CHANGED
|
@@ -4,6 +4,15 @@ const { SimpleObj } = require("./SimpleObj");
|
|
|
4
4
|
const TAMANIO_ALEATORIO = 10;
|
|
5
5
|
const MAX_BUFFER_CHANGES = 50;
|
|
6
6
|
|
|
7
|
+
const assureSorted = (batch) => {
|
|
8
|
+
const compFun = (a, b) => {
|
|
9
|
+
return a.k.length - b.k.length;
|
|
10
|
+
};
|
|
11
|
+
batch['*'].sort(compFun);
|
|
12
|
+
batch['-'].sort(compFun);
|
|
13
|
+
batch['+'].sort(compFun);
|
|
14
|
+
};
|
|
15
|
+
|
|
7
16
|
const fakeProcessor = ({ min = 500, max = 1000 }) => {
|
|
8
17
|
return new Promise((resolve) => {
|
|
9
18
|
const tiempo = min + Math.random() * (max - min);
|
|
@@ -327,6 +336,10 @@ class MyTuples {
|
|
|
327
336
|
},
|
|
328
337
|
affect: (batch, listenerKeys = [], callback = null) => {
|
|
329
338
|
const tuplas1 = MyTuples.getTuples(JSON.parse(myFreeze));
|
|
339
|
+
|
|
340
|
+
// assure changes are sorted
|
|
341
|
+
assureSorted(batch);
|
|
342
|
+
|
|
330
343
|
const llavesBorrar = batch["-"];
|
|
331
344
|
const llavesNuevasModificadas = batch["*"].concat(batch["+"]);
|
|
332
345
|
|
|
@@ -420,18 +433,16 @@ class MyTuples {
|
|
|
420
433
|
}
|
|
421
434
|
}
|
|
422
435
|
|
|
423
|
-
|
|
424
|
-
return b.k.length - a.k.length;
|
|
425
|
-
};
|
|
426
|
-
batch['*'].sort(compFun);
|
|
427
|
-
batch['-'].sort(compFun);
|
|
428
|
-
batch['+'].sort(compFun);
|
|
436
|
+
assureSorted(batch);
|
|
429
437
|
|
|
430
438
|
batch.total = batch['*'].length + batch['-'].length + batch['+'].length;
|
|
431
439
|
if (batch.total > 0) {
|
|
432
440
|
myFreeze = JSON.stringify(nuevo);
|
|
433
441
|
pending.push(batch);
|
|
434
442
|
startProcess();
|
|
443
|
+
} else {
|
|
444
|
+
// Nothing to do...
|
|
445
|
+
setActivityStatus(false);
|
|
435
446
|
}
|
|
436
447
|
|
|
437
448
|
return batch;
|
package/src/MyTuples.test.js
CHANGED
|
@@ -173,8 +173,11 @@ const test = async () => {
|
|
|
173
173
|
throw Error(`referencia ${referencia} \nintercambio ${intercambio}\nresultadoTxt ${resultadoTxt}`);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
prueba.e.r = differences.r;
|
|
177
|
+
prueba.e.t = differences.t;
|
|
178
|
+
prueba.e.total = differences.total;
|
|
176
179
|
if (sortify(prueba.e) != differencesTxt) {
|
|
177
|
-
throw Error(`Modificación fallida ${
|
|
180
|
+
throw Error(`Modificación fallida ${sortify(prueba.e)}\n${differencesTxt}`);
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
if (sortify(prueba.f) != sortify(afectado)) {
|
|
@@ -325,6 +328,7 @@ const testSimple = () => {
|
|
|
325
328
|
console.log(afectado3);
|
|
326
329
|
}
|
|
327
330
|
|
|
328
|
-
|
|
331
|
+
test();
|
|
332
|
+
//testSimple();
|
|
329
333
|
//testArrayCompress();
|
|
330
334
|
//testConverter();
|