hyoo_sync_client 0.0.312 → 0.0.314

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/web.meta.tree CHANGED
@@ -39,7 +39,7 @@
39
39
  pack match git \https://github.com/hyoo-ru/match.hyoo.ru.git
40
40
  pack meme git \https://github.com/hyoo-ru/meme.hyoo.ru.git
41
41
  pack meta git \https://github.com/hyoo-ru/hyoo_meta.git
42
- pack mill git \https://github.com/hyoo-ru/mill.git
42
+ pack mill git \https://github.com/hyoo-ru/hyoo_mill.git
43
43
  pack mol git \https://github.com/hyoo-ru/mol.hyoo.ru.git
44
44
  pack notes git \https://github.com/hyoo-ru/notes.hyoo.ru.git
45
45
  pack offer git \https://github.com/hyoo-ru/offer.hyoo.ru.git
package/web.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  function require( path ){ return $node[ path ] };
3
4
 
package/web.test.js CHANGED
@@ -202,7 +202,12 @@ var $;
202
202
  var $;
203
203
  (function ($) {
204
204
  function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
205
- return new Proxy(new $mol_range2_array(), {
205
+ const source = typeof item === 'function' ? new $mol_range2_array() : item;
206
+ if (typeof item !== 'function') {
207
+ item = index => source[index];
208
+ size = () => source.length;
209
+ }
210
+ return new Proxy(source, {
206
211
  get(target, field) {
207
212
  if (typeof field === 'string') {
208
213
  if (field === 'length')
@@ -215,7 +220,7 @@ var $;
215
220
  if (index === Math.trunc(index))
216
221
  return item(index);
217
222
  }
218
- return target[field];
223
+ return $mol_range2_array.prototype[field];
219
224
  },
220
225
  set(target, field) {
221
226
  return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
@@ -256,13 +261,16 @@ var $;
256
261
  return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
257
262
  }
258
263
  filter(check, context) {
259
- const filtered = new $mol_range2_array();
260
- for (let index = 0; index < this.length; ++index) {
261
- const item = this[index];
262
- if (check.call(context, item, index, this))
263
- filtered.push(item);
264
- }
265
- return filtered;
264
+ const filtered = [];
265
+ let cursor = -1;
266
+ return $mol_range2(index => {
267
+ while (cursor < this.length && index >= filtered.length - 1) {
268
+ const val = this[++cursor];
269
+ if (check(val, cursor, this))
270
+ filtered.push(val);
271
+ }
272
+ return filtered[index];
273
+ }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
266
274
  }
267
275
  forEach(proceed, context) {
268
276
  for (let [key, value] of this.entries())
@@ -322,7 +330,7 @@ var $;
322
330
  'lazy calls'() {
323
331
  let calls = 0;
324
332
  const list = $mol_range2(index => (++calls, index), () => 10);
325
- $mol_assert_ok(list instanceof Array);
333
+ $mol_assert_equal(true, list instanceof Array);
326
334
  $mol_assert_equal(list.length, 10);
327
335
  $mol_assert_equal(list[-1], undefined);
328
336
  $mol_assert_equal(list[0], 0);
@@ -365,11 +373,17 @@ var $;
365
373
  $mol_range2(i => i, () => 5).forEach(i => log += i);
366
374
  $mol_assert_equal(log, '01234');
367
375
  },
376
+ 'reduce'() {
377
+ let calls = 0;
378
+ const list = $mol_range2().slice(1, 6);
379
+ $mol_assert_equal(list.reduce((s, v) => s + v), 15);
380
+ $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
381
+ },
368
382
  'lazy concat'() {
369
383
  let calls1 = 0;
370
384
  let calls2 = 0;
371
385
  const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
372
- $mol_assert_ok(list instanceof Array);
386
+ $mol_assert_equal(true, list instanceof Array);
373
387
  $mol_assert_equal(list.length, 15);
374
388
  $mol_assert_equal(list[0], 0);
375
389
  $mol_assert_equal(list[4], 4);
@@ -381,32 +395,26 @@ var $;
381
395
  $mol_assert_equal(calls1, 2);
382
396
  $mol_assert_equal(calls2, 2);
383
397
  },
384
- 'filter'() {
398
+ 'lazy filter'() {
385
399
  let calls = 0;
386
- const list = $mol_range2(index => (++calls, index), () => 10).filter(v => v % 2).slice(0, 3);
387
- $mol_assert_ok(list instanceof Array);
400
+ const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
401
+ $mol_assert_equal(true, list instanceof Array);
388
402
  $mol_assert_equal(list.length, 3);
389
403
  $mol_assert_equal(list[0], 1);
390
404
  $mol_assert_equal(list[2], 5);
391
405
  $mol_assert_equal(list[3], undefined);
392
- $mol_assert_equal(calls, 10);
406
+ $mol_assert_equal(calls, 8);
393
407
  },
394
- 'reverse'() {
408
+ 'lazy reverse'() {
395
409
  let calls = 0;
396
410
  const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
397
- $mol_assert_ok(list instanceof Array);
411
+ $mol_assert_equal(true, list instanceof Array);
398
412
  $mol_assert_equal(list.length, 3);
399
413
  $mol_assert_equal(list[0], 9);
400
414
  $mol_assert_equal(list[2], 7);
401
415
  $mol_assert_equal(list[3], undefined);
402
416
  $mol_assert_equal(calls, 2);
403
417
  },
404
- 'reduce'() {
405
- let calls = 0;
406
- const list = $mol_range2().slice(1, 6);
407
- $mol_assert_equal(list.reduce((s, v) => s + v), 15);
408
- $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
409
- },
410
418
  'lazy map'() {
411
419
  let calls1 = 0;
412
420
  let calls2 = 0;
@@ -416,7 +424,7 @@ var $;
416
424
  $mol_assert_equal(source, self);
417
425
  return index + 10;
418
426
  }, () => 5);
419
- $mol_assert_ok(target instanceof Array);
427
+ $mol_assert_equal(true, target instanceof Array);
420
428
  $mol_assert_equal(target.length, 5);
421
429
  $mol_assert_equal(target[0], 10);
422
430
  $mol_assert_equal(target[4], 14);
@@ -427,7 +435,7 @@ var $;
427
435
  'lazy slice'() {
428
436
  let calls = 0;
429
437
  const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
430
- $mol_assert_ok(list instanceof Array);
438
+ $mol_assert_equal(true, list instanceof Array);
431
439
  $mol_assert_equal(list.length, 4);
432
440
  $mol_assert_equal(list[0], 3);
433
441
  $mol_assert_equal(list[3], 6);
@@ -436,22 +444,22 @@ var $;
436
444
  },
437
445
  'lazy some'() {
438
446
  let calls = 0;
439
- $mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
447
+ $mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
440
448
  $mol_assert_equal(calls, 3);
441
- $mol_assert_not($mol_range2(i => i, () => 0).some(v => true));
442
- $mol_assert_ok($mol_range2(i => i).some(v => v > 5));
449
+ $mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
450
+ $mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
443
451
  },
444
452
  'lazy every'() {
445
453
  let calls = 0;
446
- $mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
454
+ $mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
447
455
  $mol_assert_equal(calls, 3);
448
- $mol_assert_ok($mol_range2(i => i, () => 0).every(v => false));
449
- $mol_assert_not($mol_range2(i => i).every(v => v < 5));
456
+ $mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
457
+ $mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
450
458
  },
451
459
  'lazyfy'() {
452
460
  let calls = 0;
453
- const list = new $mol_range2_array(...[0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
454
- $mol_assert_ok(list instanceof Array);
461
+ const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
462
+ $mol_assert_equal(true, list instanceof Array);
455
463
  $mol_assert_equal(list.length, 4);
456
464
  $mol_assert_equal(calls, 0);
457
465
  $mol_assert_equal(list[0], 12);