@adviser/cement 0.3.17 → 0.3.18
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/cf/index.cjs +28 -25
- package/cf/index.cjs.map +1 -1
- package/cf/index.js +2 -2
- package/{chunk-JELISEAH.js → chunk-ERFPFVXB.js} +2 -2
- package/{chunk-ZWI2F6RL.js → chunk-NYHENJUJ.js} +60 -27
- package/chunk-NYHENJUJ.js.map +1 -0
- package/{chunk-ZYKVQZJH.js → chunk-RQKI6UPM.js} +3 -3
- package/deno/index.cjs +28 -25
- package/deno/index.cjs.map +1 -1
- package/deno/index.js +1 -1
- package/index.cjs +61 -27
- package/index.cjs.map +1 -1
- package/index.d.cts +21 -9
- package/index.d.ts +21 -9
- package/index.js +7 -5
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/index.cjs +28 -25
- package/node/index.cjs.map +1 -1
- package/node/index.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/jsr.json +1 -1
- package/src/{lru-cache.ts → lru-map-set.ts} +68 -27
- package/src/resolve-once.ts +4 -4
- package/test/index.cjs +28 -25
- package/test/index.cjs.map +1 -1
- package/test/index.js +3 -3
- package/ts/src/index.d.ts +1 -1
- package/ts/src/index.d.ts.map +1 -1
- package/ts/src/index.js +1 -1
- package/ts/src/index.js.map +1 -1
- package/ts/src/lru-map-set.d.ts +32 -0
- package/ts/src/lru-map-set.d.ts.map +1 -0
- package/ts/src/lru-map-set.js +114 -0
- package/ts/src/lru-map-set.js.map +1 -0
- package/ts/src/lru-map-set.test.d.ts +2 -0
- package/ts/src/lru-map-set.test.d.ts.map +1 -0
- package/ts/src/{lru-cache.test.js → lru-map-set.test.js} +15 -15
- package/ts/src/lru-map-set.test.js.map +1 -0
- package/ts/src/resolve-once.d.ts +3 -3
- package/ts/src/resolve-once.d.ts.map +1 -1
- package/ts/src/resolve-once.js +2 -2
- package/ts/src/resolve-once.js.map +1 -1
- package/web/index.cjs +28 -25
- package/web/index.cjs.map +1 -1
- package/web/index.js +2 -2
- package/chunk-ZWI2F6RL.js.map +0 -1
- package/ts/src/lru-cache.d.ts +0 -20
- package/ts/src/lru-cache.d.ts.map +0 -1
- package/ts/src/lru-cache.js +0 -82
- package/ts/src/lru-cache.js.map +0 -1
- package/ts/src/lru-cache.test.d.ts +0 -2
- package/ts/src/lru-cache.test.d.ts.map +0 -1
- package/ts/src/lru-cache.test.js.map +0 -1
- /package/{chunk-JELISEAH.js.map → chunk-ERFPFVXB.js.map} +0 -0
- /package/{chunk-ZYKVQZJH.js.map → chunk-RQKI6UPM.js.map} +0 -0
package/test/index.cjs
CHANGED
@@ -865,31 +865,31 @@ var WrapperSysAbstraction = class {
|
|
865
865
|
}
|
866
866
|
};
|
867
867
|
|
868
|
-
// src/lru-
|
869
|
-
var
|
868
|
+
// src/lru-map-set.ts
|
869
|
+
var LRUMap = class {
|
870
870
|
constructor(c = {}) {
|
871
|
-
this.
|
871
|
+
this._map = /* @__PURE__ */ new Map();
|
872
872
|
this.param = {
|
873
873
|
maxEntries: c.maxEntries || 100,
|
874
874
|
maxAge: c.maxAge || 0
|
875
875
|
};
|
876
876
|
}
|
877
877
|
touch(key) {
|
878
|
-
if (!this.
|
878
|
+
if (!this._map.has(key)) {
|
879
879
|
throw new Error(`key not found in cache: ${key}`);
|
880
880
|
}
|
881
|
-
const value = this.
|
882
|
-
this.
|
883
|
-
this.
|
881
|
+
const value = this._map.get(key);
|
882
|
+
this._map.delete(key);
|
883
|
+
this._map.set(key, value);
|
884
884
|
return value;
|
885
885
|
}
|
886
886
|
setParam(param2 = {}) {
|
887
887
|
if (typeof param2.maxEntries === "number") {
|
888
888
|
this.param.maxEntries = param2.maxEntries;
|
889
|
-
if (param2.maxEntries > 0 && this.
|
889
|
+
if (param2.maxEntries > 0 && this._map.size > param2.maxEntries) {
|
890
890
|
const toDelete = [];
|
891
|
-
let cacheSize = this.
|
892
|
-
for (const key of this.
|
891
|
+
let cacheSize = this._map.size;
|
892
|
+
for (const key of this._map.keys()) {
|
893
893
|
if (cacheSize > param2.maxEntries) {
|
894
894
|
toDelete.push(key);
|
895
895
|
cacheSize--;
|
@@ -898,15 +898,18 @@ var LRUCache = class {
|
|
898
898
|
}
|
899
899
|
}
|
900
900
|
for (const key of toDelete) {
|
901
|
-
this.
|
901
|
+
this._map.delete(key);
|
902
902
|
}
|
903
903
|
}
|
904
904
|
}
|
905
905
|
}
|
906
|
+
has(key) {
|
907
|
+
return this._map.has(key);
|
908
|
+
}
|
906
909
|
get size() {
|
907
|
-
return this.
|
910
|
+
return this._map.size;
|
908
911
|
}
|
909
|
-
async
|
912
|
+
async getSet(key, createFN) {
|
910
913
|
const val = this.get(key);
|
911
914
|
if (val) {
|
912
915
|
return val;
|
@@ -917,31 +920,31 @@ var LRUCache = class {
|
|
917
920
|
}
|
918
921
|
}
|
919
922
|
get(key) {
|
920
|
-
if (this.
|
923
|
+
if (this._map.has(key)) {
|
921
924
|
return this.touch(key);
|
922
925
|
}
|
923
|
-
return this.
|
926
|
+
return this._map.get(key);
|
924
927
|
}
|
925
928
|
set(key, value) {
|
926
|
-
this.
|
927
|
-
if (this.param.maxEntries > 0 && this.
|
928
|
-
this.
|
929
|
-
this.
|
929
|
+
this._map.delete(key);
|
930
|
+
if (this.param.maxEntries > 0 && this._map.size >= this.param.maxEntries) {
|
931
|
+
this._map.delete(this._map.keys().next().value);
|
932
|
+
this._map.set(key, value);
|
930
933
|
} else {
|
931
|
-
this.
|
934
|
+
this._map.set(key, value);
|
932
935
|
}
|
933
936
|
}
|
934
937
|
delete(key) {
|
935
|
-
this.
|
938
|
+
this._map.delete(key);
|
936
939
|
}
|
937
940
|
clear() {
|
938
|
-
this.
|
941
|
+
this._map.clear();
|
939
942
|
}
|
940
943
|
forEach(callbackfn) {
|
941
|
-
this.
|
944
|
+
this._map.forEach(callbackfn);
|
942
945
|
}
|
943
946
|
entries() {
|
944
|
-
return this.
|
947
|
+
return this._map.entries();
|
945
948
|
}
|
946
949
|
// *entries(): IterableIterator<[T, K]> {
|
947
950
|
// for (const x of this._cache.entries()) {
|
@@ -1052,7 +1055,7 @@ var Keyed = class {
|
|
1052
1055
|
constructor(factory, params) {
|
1053
1056
|
var _a;
|
1054
1057
|
this.factory = factory;
|
1055
|
-
this._map = new
|
1058
|
+
this._map = new LRUMap((_a = params == null ? void 0 : params.lru) != null ? _a : { maxEntries: -1 });
|
1056
1059
|
}
|
1057
1060
|
setParam(params) {
|
1058
1061
|
this._map.setParam(params.lru);
|