mol_plot_all 1.2.753 → 1.2.754

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.mjs CHANGED
@@ -944,6 +944,8 @@ var $;
944
944
  result = compare_pojo(left, right);
945
945
  else if (!Reflect.getPrototypeOf(left_proto))
946
946
  result = compare_pojo(left, right);
947
+ else if (Symbol.toPrimitive in left)
948
+ result = compare_primitive(left, right);
947
949
  else if (Array.isArray(left))
948
950
  result = compare_array(left, right);
949
951
  else if (left instanceof Set)
@@ -954,8 +956,6 @@ var $;
954
956
  result = compare_buffer(left, right);
955
957
  else if (Symbol.iterator in left)
956
958
  result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
957
- else if (Symbol.toPrimitive in left)
958
- result = compare_primitive(left, right);
959
959
  else
960
960
  result = false;
961
961
  }
package/web.test.js CHANGED
@@ -324,6 +324,283 @@ var $;
324
324
  ;
325
325
  "use strict";
326
326
  var $;
327
+ (function ($) {
328
+ function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
329
+ return new Proxy(new $mol_range2_array(), {
330
+ get(target, field) {
331
+ if (typeof field === 'string') {
332
+ if (field === 'length')
333
+ return size();
334
+ const index = Number(field);
335
+ if (index < 0)
336
+ return undefined;
337
+ if (index >= size())
338
+ return undefined;
339
+ if (index === Math.trunc(index))
340
+ return item(index);
341
+ }
342
+ return target[field];
343
+ },
344
+ set(target, field) {
345
+ return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
346
+ },
347
+ ownKeys(target) {
348
+ return [...Array(size())].map((v, i) => String(i)).concat('length');
349
+ },
350
+ getOwnPropertyDescriptor(target, field) {
351
+ if (field === "length")
352
+ return {
353
+ value: size(),
354
+ writable: true,
355
+ enumerable: false,
356
+ configurable: false,
357
+ };
358
+ const index = Number(field);
359
+ if (index === Math.trunc(index))
360
+ return {
361
+ get: () => this.get(target, field, this),
362
+ enumerable: true,
363
+ configurable: true,
364
+ };
365
+ return Object.getOwnPropertyDescriptor(target, field);
366
+ }
367
+ });
368
+ }
369
+ $.$mol_range2 = $mol_range2;
370
+ class $mol_range2_array extends Array {
371
+ concat(...tail) {
372
+ if (tail.length === 0)
373
+ return this;
374
+ if (tail.length > 1) {
375
+ let list = this;
376
+ for (let item of tail)
377
+ list = list.concat(item);
378
+ return list;
379
+ }
380
+ return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
381
+ }
382
+ filter(check, context) {
383
+ const filtered = new $mol_range2_array();
384
+ for (let index = 0; index < this.length; ++index) {
385
+ const item = this[index];
386
+ if (check.call(context, item, index, this))
387
+ filtered.push(item);
388
+ }
389
+ return filtered;
390
+ }
391
+ forEach(proceed, context) {
392
+ for (let [key, value] of this.entries())
393
+ proceed.call(context, value, key, this);
394
+ }
395
+ map(proceed, context) {
396
+ return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
397
+ }
398
+ reduce(merge, result) {
399
+ let index = 0;
400
+ if (arguments.length === 1) {
401
+ result = this[index++];
402
+ }
403
+ for (; index < this.length; ++index) {
404
+ result = merge(result, this[index], index, this);
405
+ }
406
+ return result;
407
+ }
408
+ toReversed() {
409
+ return $mol_range2(index => this[this.length - 1 - index], () => this.length);
410
+ }
411
+ slice(from = 0, to = this.length) {
412
+ return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
413
+ }
414
+ some(check, context) {
415
+ for (let index = 0; index < this.length; ++index) {
416
+ if (check.call(context, this[index], index, this))
417
+ return true;
418
+ }
419
+ return false;
420
+ }
421
+ every(check, context) {
422
+ for (let index = 0; index < this.length; ++index) {
423
+ if (!check.call(context, this[index], index, this))
424
+ return false;
425
+ }
426
+ return true;
427
+ }
428
+ reverse() {
429
+ return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
430
+ }
431
+ sort() {
432
+ return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
433
+ }
434
+ [Symbol.toPrimitive]() {
435
+ return $mol_guid();
436
+ }
437
+ }
438
+ $.$mol_range2_array = $mol_range2_array;
439
+ })($ || ($ = {}));
440
+ //mol/range2/range2.ts
441
+ ;
442
+ "use strict";
443
+ var $;
444
+ (function ($) {
445
+ $mol_test({
446
+ 'lazy calls'() {
447
+ let calls = 0;
448
+ const list = $mol_range2(index => (++calls, index), () => 10);
449
+ $mol_assert_ok(list instanceof Array);
450
+ $mol_assert_equal(list.length, 10);
451
+ $mol_assert_equal(list[-1], undefined);
452
+ $mol_assert_equal(list[0], 0);
453
+ $mol_assert_equal(list[9], 9);
454
+ $mol_assert_equal(list[9.5], undefined);
455
+ $mol_assert_equal(list[10], undefined);
456
+ $mol_assert_equal(calls, 2);
457
+ },
458
+ 'infinity list'() {
459
+ let calls = 0;
460
+ const list = $mol_range2(index => (++calls, index));
461
+ $mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
462
+ $mol_assert_equal(list[0], 0);
463
+ $mol_assert_equal(list[4], 4);
464
+ $mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
465
+ $mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
466
+ $mol_assert_equal(calls, 3);
467
+ },
468
+ 'stringify'() {
469
+ const list = $mol_range2(i => i, () => 5);
470
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
471
+ $mol_assert_equal(list.join(';'), '0;1;2;3;4');
472
+ },
473
+ 'for-of'() {
474
+ let log = '';
475
+ for (let i of $mol_range2(i => i + 1, () => 5)) {
476
+ log += i;
477
+ }
478
+ $mol_assert_equal(log, '12345');
479
+ },
480
+ 'for-in'() {
481
+ let log = '';
482
+ for (let i in $mol_range2(i => i, () => 5)) {
483
+ log += i;
484
+ }
485
+ $mol_assert_equal(log, '01234');
486
+ },
487
+ 'forEach'() {
488
+ let log = '';
489
+ $mol_range2(i => i, () => 5).forEach(i => log += i);
490
+ $mol_assert_equal(log, '01234');
491
+ },
492
+ 'lazy concat'() {
493
+ let calls1 = 0;
494
+ let calls2 = 0;
495
+ const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
496
+ $mol_assert_ok(list instanceof Array);
497
+ $mol_assert_equal(list.length, 15);
498
+ $mol_assert_equal(list[0], 0);
499
+ $mol_assert_equal(list[4], 4);
500
+ $mol_assert_equal(list[5], 0);
501
+ $mol_assert_equal(list[9], 4);
502
+ $mol_assert_equal(list[10], 0);
503
+ $mol_assert_equal(list[14], 4);
504
+ $mol_assert_equal(list[15], undefined);
505
+ $mol_assert_equal(calls1, 2);
506
+ $mol_assert_equal(calls2, 2);
507
+ },
508
+ 'filter'() {
509
+ let calls = 0;
510
+ const list = $mol_range2(index => (++calls, index), () => 10).filter(v => v % 2).slice(0, 3);
511
+ $mol_assert_ok(list instanceof Array);
512
+ $mol_assert_equal(list.length, 3);
513
+ $mol_assert_equal(list[0], 1);
514
+ $mol_assert_equal(list[2], 5);
515
+ $mol_assert_equal(list[3], undefined);
516
+ $mol_assert_equal(calls, 10);
517
+ },
518
+ 'reverse'() {
519
+ let calls = 0;
520
+ const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
521
+ $mol_assert_ok(list instanceof Array);
522
+ $mol_assert_equal(list.length, 3);
523
+ $mol_assert_equal(list[0], 9);
524
+ $mol_assert_equal(list[2], 7);
525
+ $mol_assert_equal(list[3], undefined);
526
+ $mol_assert_equal(calls, 2);
527
+ },
528
+ 'reduce'() {
529
+ let calls = 0;
530
+ const list = $mol_range2().slice(1, 6);
531
+ $mol_assert_equal(list.reduce((s, v) => s + v), 15);
532
+ $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
533
+ },
534
+ 'lazy map'() {
535
+ let calls1 = 0;
536
+ let calls2 = 0;
537
+ const source = $mol_range2(index => (++calls1, index), () => 5);
538
+ const target = source.map((item, index, self) => {
539
+ ++calls2;
540
+ $mol_assert_equal(source, self);
541
+ return index + 10;
542
+ }, () => 5);
543
+ $mol_assert_ok(target instanceof Array);
544
+ $mol_assert_equal(target.length, 5);
545
+ $mol_assert_equal(target[0], 10);
546
+ $mol_assert_equal(target[4], 14);
547
+ $mol_assert_equal(target[5], undefined);
548
+ $mol_assert_equal(calls1, 2);
549
+ $mol_assert_equal(calls2, 2);
550
+ },
551
+ 'lazy slice'() {
552
+ let calls = 0;
553
+ const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
554
+ $mol_assert_ok(list instanceof Array);
555
+ $mol_assert_equal(list.length, 4);
556
+ $mol_assert_equal(list[0], 3);
557
+ $mol_assert_equal(list[3], 6);
558
+ $mol_assert_equal(list[4], undefined);
559
+ $mol_assert_equal(calls, 2);
560
+ },
561
+ 'lazy some'() {
562
+ let calls = 0;
563
+ $mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
564
+ $mol_assert_equal(calls, 3);
565
+ $mol_assert_not($mol_range2(i => i, () => 0).some(v => true));
566
+ $mol_assert_ok($mol_range2(i => i).some(v => v > 5));
567
+ },
568
+ 'lazy every'() {
569
+ let calls = 0;
570
+ $mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
571
+ $mol_assert_equal(calls, 3);
572
+ $mol_assert_ok($mol_range2(i => i, () => 0).every(v => false));
573
+ $mol_assert_not($mol_range2(i => i).every(v => v < 5));
574
+ },
575
+ 'lazyfy'() {
576
+ let calls = 0;
577
+ const list = new $mol_range2_array(...[0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
578
+ $mol_assert_ok(list instanceof Array);
579
+ $mol_assert_equal(list.length, 4);
580
+ $mol_assert_equal(calls, 0);
581
+ $mol_assert_equal(list[0], 12);
582
+ $mol_assert_equal(list[3], 15);
583
+ $mol_assert_equal(list[4], undefined);
584
+ $mol_assert_equal(calls, 2);
585
+ },
586
+ 'prevent modification'() {
587
+ const list = $mol_range2(i => i, () => 5);
588
+ $mol_assert_fail(() => list.push(4), TypeError);
589
+ $mol_assert_fail(() => list.pop(), TypeError);
590
+ $mol_assert_fail(() => list.unshift(4), TypeError);
591
+ $mol_assert_fail(() => list.shift(), TypeError);
592
+ $mol_assert_fail(() => list.splice(1, 2), TypeError);
593
+ $mol_assert_fail(() => list[1] = 2, TypeError);
594
+ $mol_assert_fail(() => list.reverse(), TypeError);
595
+ $mol_assert_fail(() => list.sort(), TypeError);
596
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
597
+ }
598
+ });
599
+ })($ || ($ = {}));
600
+ //mol/range2/range2.test.ts
601
+ ;
602
+ "use strict";
603
+ var $;
327
604
  (function ($) {
328
605
  $mol_test({
329
606
  'nulls & undefineds'() {
@@ -353,6 +630,8 @@ var $;
353
630
  $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
354
631
  $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
355
632
  $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
633
+ $mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
634
+ $mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
356
635
  },
357
636
  'Non POJO are different'() {
358
637
  class Thing extends Object {