securemark 0.227.0 → 0.227.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.227.1
4
+
5
+ - Update dependencies.
6
+
3
7
  ## 0.227.0
4
8
 
5
9
  - Change a syntax name from hashref to hashnum.
@@ -1,4 +1,4 @@
1
- /*! securemark v0.227.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.227.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
2
2
  require = function () {
3
3
  function r(e, n, t) {
4
4
  function o(i, f) {
@@ -402,7 +402,6 @@ require = function () {
402
402
  Object.defineProperty(exports, '__esModule', { value: true });
403
403
  exports.Cache = void 0;
404
404
  const global_1 = _dereq_('./global');
405
- const alias_1 = _dereq_('./alias');
406
405
  const clock_1 = _dereq_('./clock');
407
406
  const invlist_1 = _dereq_('./invlist');
408
407
  const assign_1 = _dereq_('./assign');
@@ -455,7 +454,6 @@ require = function () {
455
454
  this.capacity = settings.capacity;
456
455
  if (this.capacity >= 1 === false)
457
456
  throw new Error(`Spica: Cache: Capacity must be 1 or more.`);
458
- this.frequency = (0, alias_1.max)(this.capacity / 100 | 0, 1);
459
457
  this.space = settings.space;
460
458
  this.life = this.capacity * settings.life;
461
459
  this.limit = settings.limit;
@@ -466,7 +464,7 @@ require = function () {
466
464
  get size() {
467
465
  return this.SIZE;
468
466
  }
469
- dispose(node, record, callback) {
467
+ evict(node, record, callback) {
470
468
  var _a, _b, _c;
471
469
  const index = node.value;
472
470
  callback && (callback = !!this.settings.disposer);
@@ -492,24 +490,22 @@ require = function () {
492
490
  const lastIndex = lastNode === null || lastNode === void 0 ? void 0 : lastNode.value;
493
491
  let target;
494
492
  switch (true) {
495
- case LRU.length === 0:
496
- target = LFU.last;
497
- target = target !== skip ? target : target.prev;
498
- break;
499
493
  case lastIndex && lastIndex.clock < this.clock - this.life:
500
494
  case lastIndex && lastIndex.expiry !== global_1.Infinity && lastIndex.expiry < (0, clock_1.now)():
501
- target = lastNode;
495
+ target = lastNode.list === OVF ? lastNode.value.parent : lastNode;
496
+ break;
497
+ case LRU.length === 0:
498
+ target = LFU.last !== skip ? LFU.last : LFU.last.prev;
502
499
  break;
503
500
  case LFU.length > this.capacity * this.ratio / 100:
504
- target = LFU.last;
505
- LRU.unshiftNode(target);
506
- target.value.overflow = OVF.unshift(target.value);
501
+ LRU.unshiftNode(LFU.last);
502
+ LRU.head.value.parent = LRU.head;
503
+ LRU.head.value.overflow = OVF.unshift(LRU.head.value);
507
504
  default:
508
- target = LRU.last;
509
- target = target !== skip ? target : target.prev !== skip ? target.prev : LFU.last;
505
+ target = LRU.last !== skip ? LRU.last : LRU.last.prev !== skip ? LRU.last.prev : LFU.last;
510
506
  }
511
- this.dispose(target, void 0, true);
512
- skip = (skip === null || skip === void 0 ? void 0 : skip.list) ? skip : void 0;
507
+ this.evict(target, void 0, true);
508
+ skip = (skip === null || skip === void 0 ? void 0 : skip.list) && skip;
513
509
  size = (_c = skip === null || skip === void 0 ? void 0 : skip.value.size) !== null && _c !== void 0 ? _c : 0;
514
510
  }
515
511
  }
@@ -530,7 +526,7 @@ require = function () {
530
526
  const val = record.value;
531
527
  const index = node.value;
532
528
  this.ensure(size, node);
533
- index.clock = ++this.clockR;
529
+ index.clock = index.region === 'LRU' ? ++this.clockR : ++this.clock;
534
530
  index.expiry = expiry;
535
531
  this.SIZE += size - index.size;
536
532
  index.size = size;
@@ -547,7 +543,7 @@ require = function () {
547
543
  size,
548
544
  clock: ++this.clockR,
549
545
  expiry,
550
- stat: this.stats.LRU
546
+ region: 'LRU'
551
547
  }),
552
548
  value
553
549
  });
@@ -564,7 +560,7 @@ require = function () {
564
560
  const node = record.index;
565
561
  const expiry = node.value.expiry;
566
562
  if (expiry !== global_1.Infinity && expiry < (0, clock_1.now)()) {
567
- this.dispose(node, record, true);
563
+ this.evict(node, record, true);
568
564
  return;
569
565
  }
570
566
  if (this.capacity >= 10 && node === node.list.head)
@@ -579,7 +575,7 @@ require = function () {
579
575
  return false;
580
576
  const expiry = record.index.value.expiry;
581
577
  if (expiry !== global_1.Infinity && expiry < (0, clock_1.now)()) {
582
- this.dispose(record.index, record, true);
578
+ this.evict(record.index, record, true);
583
579
  return false;
584
580
  }
585
581
  return true;
@@ -588,7 +584,7 @@ require = function () {
588
584
  const record = this.memory.get(key);
589
585
  if (!record)
590
586
  return false;
591
- this.dispose(record.index, record, this.settings.capture.delete === true);
587
+ this.evict(record.index, record, this.settings.capture.delete === true);
592
588
  return true;
593
589
  }
594
590
  clear() {
@@ -617,22 +613,23 @@ require = function () {
617
613
  }
618
614
  slide() {
619
615
  const {LRU, LFU} = this.stats;
620
- const {capacity, frequency, ratio, limit, indexes} = this;
616
+ const {capacity, ratio, limit, indexes} = this;
621
617
  const window = capacity;
622
618
  LRU[0] + LFU[0] === window && this.stats.slide();
623
- if ((LRU[0] + LFU[0]) % frequency || LRU[1] + LFU[1] === 0)
619
+ if ((LRU[0] + LFU[0]) * 100 % capacity || LRU[1] + LFU[1] === 0)
624
620
  return;
625
621
  const lenR = indexes.LRU.length;
626
622
  const lenF = indexes.LFU.length;
627
623
  const lenV = indexes.OVF.length;
628
624
  const r = (lenF + lenV) * 1000 / (lenR + lenF) | 0;
629
- const rateR = rate(window, LRU[0], LRU[0] + LFU[0], LRU[1], LRU[1] + LFU[1]) * (1 + r);
630
- const rateF = rate(window, LFU[0], LRU[0] + LFU[0], LFU[1], LRU[1] + LFU[1]) * (1001 - r);
631
- if (ratio > 0 && rateR > rateF || ratio > 0 && rateF < rate(window, LFU[1], LRU[1] + LFU[1], LFU[0], LRU[0] + LFU[0]) * (1001 - r) * 0.95) {
625
+ const rateR0 = rate(window, LRU[0], LRU[0] + LFU[0], LRU[1], LRU[1] + LFU[1], 0) * (1 + r);
626
+ const rateF0 = rate(window, LFU[0], LRU[0] + LFU[0], LFU[1], LRU[1] + LFU[1], 0) * (1001 - r);
627
+ const rateF1 = rate(window, LFU[1], LRU[1] + LFU[1], LFU[0], LRU[0] + LFU[0], 5) * (1001 - r);
628
+ if (ratio > 0 && (rateR0 > rateF0 || rateF0 < rateF1 * 0.95)) {
632
629
  if (lenR >= capacity * (100 - ratio) / 100) {
633
630
  --this.ratio;
634
631
  }
635
- } else if (ratio < limit && rateF > rateR) {
632
+ } else if (ratio < limit && rateF0 > rateR0) {
636
633
  if (lenF >= capacity * ratio / 100) {
637
634
  ++this.ratio;
638
635
  }
@@ -645,14 +642,14 @@ require = function () {
645
642
  var _a;
646
643
  const index = node.value;
647
644
  const {LRU, LFU} = this.indexes;
648
- ++index.stat[0];
645
+ ++this.stats[index.region][0];
649
646
  if (!index.overflow && index.clock >= this.clockR - LRU.length / 3 && this.capacity > 3) {
650
647
  index.clock = ++this.clockR;
651
648
  node.moveToHead();
652
649
  return true;
653
650
  }
654
651
  index.clock = ++this.clock;
655
- index.stat = this.stats.LFU;
652
+ index.region = 'LFU';
656
653
  (_a = index.overflow) === null || _a === void 0 ? void 0 : _a.delete();
657
654
  LFU.unshiftNode(node);
658
655
  return true;
@@ -662,24 +659,24 @@ require = function () {
662
659
  const {LFU} = this.indexes;
663
660
  if (node.list !== LFU)
664
661
  return false;
665
- ++index.stat[0];
662
+ ++this.stats[index.region][0];
666
663
  index.clock = ++this.clock;
667
664
  node.moveToHead();
668
665
  return true;
669
666
  }
670
667
  }
671
668
  exports.Cache = Cache;
672
- function rate(window, currHits, currTotal, prevHits, prevTotal) {
673
- window = (0, alias_1.min)(currTotal + prevTotal, window);
674
- const currRate = currHits * 100 / currTotal | 0;
675
- const currRatio = (0, alias_1.min)(currTotal * 100 / window | 0, 100);
669
+ function rate(window, currHits, currTotal, prevHits, prevTotal, offset) {
676
670
  const prevRate = prevHits * 100 / prevTotal | 0;
671
+ const currRatio = currTotal * 100 / window - offset | 0;
672
+ if (currRatio <= 0)
673
+ return prevRate * 100;
674
+ const currRate = currHits * 100 / currTotal | 0;
677
675
  const prevRatio = 100 - currRatio;
678
676
  return currRate * currRatio + prevRate * prevRatio;
679
677
  }
680
678
  },
681
679
  {
682
- './alias': 5,
683
680
  './assign': 8,
684
681
  './clock': 10,
685
682
  './global': 15,
@@ -1435,7 +1432,7 @@ require = function () {
1435
1432
  const cache_1 = _dereq_('../cache');
1436
1433
  function standardize(url, base) {
1437
1434
  const u = new ReadonlyURL(url, base);
1438
- url = u.origin !== 'null' ? u.origin.toLowerCase() + u.href.slice(u.origin.length) : u.protocol.toLowerCase() + u.href.slice(u.protocol.length);
1435
+ url = u.origin === 'null' ? u.protocol.toLowerCase() + u.href.slice(u.protocol.length) : u.origin.toLowerCase() + u.href.slice(u.origin.length);
1439
1436
  return encode(url);
1440
1437
  }
1441
1438
  exports.standardize = standardize;
@@ -1446,16 +1443,26 @@ require = function () {
1446
1443
  const internal = Symbol.for('spica/url::internal');
1447
1444
  class ReadonlyURL {
1448
1445
  constructor(source, base) {
1449
- var _a, _b;
1450
1446
  this.source = source;
1451
1447
  this.base = base;
1452
- const i = (_a = base === null || base === void 0 ? void 0 : base.indexOf('#')) !== null && _a !== void 0 ? _a : -1;
1453
- if (i > -1) {
1454
- base = base === null || base === void 0 ? void 0 : base.slice(0, i);
1455
- }
1456
- const j = (_b = base === null || base === void 0 ? void 0 : base.indexOf('?')) !== null && _b !== void 0 ? _b : -1;
1457
- if (i > -1 && source.indexOf('#') === -1) {
1458
- base = base === null || base === void 0 ? void 0 : base.slice(0, j);
1448
+ switch (source.slice(0, source.lastIndexOf('://', 9) + 1).toLowerCase()) {
1449
+ case 'http:':
1450
+ case 'https:':
1451
+ base = void 0;
1452
+ break;
1453
+ default:
1454
+ switch (base === null || base === void 0 ? void 0 : base.slice(0, base.lastIndexOf('://', 9) + 1).toLowerCase()) {
1455
+ case 'http:':
1456
+ case 'https:':
1457
+ const i = base.indexOf('#');
1458
+ if (i > -1) {
1459
+ base = base.slice(0, i);
1460
+ }
1461
+ const j = base.indexOf('?');
1462
+ if (i > -1 && source.indexOf('#') === -1) {
1463
+ base = base.slice(0, j);
1464
+ }
1465
+ }
1459
1466
  }
1460
1467
  this[internal] = {
1461
1468
  share: ReadonlyURL.get(source, base),
@@ -6046,7 +6053,7 @@ require = function () {
6046
6053
  (0, combinator_1.guard)(context => {
6047
6054
  var _a;
6048
6055
  return (_a = context.header) !== null && _a !== void 0 ? _a : true;
6049
- }, (0, combinator_1.focus)(/^---[^\S\v\f\r\n]*\r?\n(?:[A-Za-z][0-9A-Za-z]*(?:-[A-Za-z][0-9A-Za-z]*)*:[ \t]+\S[^\v\f\r\n]*\r?\n){1,100}---[^\S\v\f\r\n]*(?:$|\r?\n)/, (0, combinator_1.convert)(source => (0, normalize_1.normalize)(source.slice(source.indexOf('\n') + 1, source.trimEnd().lastIndexOf('\n'))).replace(/\s+$/mg, ''), (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([field])), es => [(0, typed_dom_1.html)('details', {
6056
+ }, (0, combinator_1.focus)(/^---[^\S\v\f\r\n]*\r?\n(?:[A-Za-z][0-9A-Za-z]*(?:-[A-Za-z][0-9A-Za-z]*)*:[ \t]+\S[^\v\f\r\n]*\r?\n){1,100}---[^\S\v\f\r\n]*(?:$|\r?\n)/, (0, combinator_1.convert)(source => (0, normalize_1.normalize)(source.slice(source.indexOf('\n') + 1, source.trimEnd().lastIndexOf('\n'))).replace(/(\S)\s+$/mg, '$1'), (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([field])), es => [(0, typed_dom_1.html)('details', {
6050
6057
  class: 'header',
6051
6058
  open: ''
6052
6059
  }, (0, typed_dom_1.defrag)([