@creejs/commons-collection 2.0.6 → 2.0.8
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/dist/cjs/index-dev.cjs +38 -0
- package/dist/cjs/index-dev.cjs.map +1 -1
- package/dist/cjs/index-min.cjs +1 -1
- package/dist/cjs/index-min.cjs.map +1 -1
- package/dist/esm/index-dev.js +38 -0
- package/dist/esm/index-dev.js.map +1 -1
- package/dist/esm/index-min.js +1 -1
- package/dist/esm/index-min.js.map +1 -1
- package/dist/umd/index.dev.js +38 -0
- package/dist/umd/index.dev.js.map +1 -1
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +1 -1
- package/types/hour24-time-wheel-cache.d.ts +6 -0
- package/types/time-wheel-cache.d.ts +6 -0
package/dist/umd/index.dev.js
CHANGED
|
@@ -248,6 +248,11 @@
|
|
|
248
248
|
this._autoStart && this._startAutoEvict();
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
get first () {
|
|
252
|
+
// Based on the ES6 Standard, Map keeps order of elements added
|
|
253
|
+
return this._cache.keys().next().value
|
|
254
|
+
}
|
|
255
|
+
|
|
251
256
|
get tickInterval () {
|
|
252
257
|
return this._tickInterval
|
|
253
258
|
}
|
|
@@ -388,6 +393,19 @@
|
|
|
388
393
|
return true
|
|
389
394
|
}
|
|
390
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Delete and Return the first key
|
|
398
|
+
* @returns {any|undefined}
|
|
399
|
+
*/
|
|
400
|
+
deleteFirst () {
|
|
401
|
+
const firstKey = this.first;
|
|
402
|
+
if (firstKey == null) {
|
|
403
|
+
return false
|
|
404
|
+
}
|
|
405
|
+
this.delete(firstKey);
|
|
406
|
+
return firstKey
|
|
407
|
+
}
|
|
408
|
+
|
|
391
409
|
/**
|
|
392
410
|
* Checks if the cache contains the specified key.
|
|
393
411
|
* @param {any} key - The key to check for existence in the cache.
|
|
@@ -531,6 +549,11 @@
|
|
|
531
549
|
this._init();
|
|
532
550
|
}
|
|
533
551
|
|
|
552
|
+
get first () {
|
|
553
|
+
// Based on the ES6 Standard, Map keeps order of elements added
|
|
554
|
+
return this._cache.keys().next().value
|
|
555
|
+
}
|
|
556
|
+
|
|
534
557
|
/**
|
|
535
558
|
* Max Time to Live, atom unit "millisecond"
|
|
536
559
|
* @returns {number}
|
|
@@ -596,6 +619,7 @@
|
|
|
596
619
|
});
|
|
597
620
|
|
|
598
621
|
this._secondWheel.on('expired', (/** @type {any} */key, /** @type {any} */value, /** @type {Timestamp} */expireTimestamp) => {
|
|
622
|
+
this._cache.delete(key);
|
|
599
623
|
this.emit(Event.Expired, key, value, expireTimestamp);
|
|
600
624
|
});
|
|
601
625
|
}
|
|
@@ -654,9 +678,23 @@
|
|
|
654
678
|
if (!wheel) {
|
|
655
679
|
return false
|
|
656
680
|
}
|
|
681
|
+
this._cache.delete(key);
|
|
657
682
|
return wheel.delete(key)
|
|
658
683
|
}
|
|
659
684
|
|
|
685
|
+
/**
|
|
686
|
+
* Delete and Return the first key
|
|
687
|
+
* @returns {any|undefined}
|
|
688
|
+
*/
|
|
689
|
+
deleteFirst () {
|
|
690
|
+
const firstKey = this.first;
|
|
691
|
+
if (firstKey == null) {
|
|
692
|
+
return false
|
|
693
|
+
}
|
|
694
|
+
this.delete(firstKey);
|
|
695
|
+
return firstKey
|
|
696
|
+
}
|
|
697
|
+
|
|
660
698
|
/**
|
|
661
699
|
* Checks if the cache contains the specified key.
|
|
662
700
|
* @param {any} key - The key to check for existence in the cache.
|