@visulima/string 1.0.0
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 +5 -0
- package/LICENSE.md +77 -0
- package/README.md +880 -0
- package/dist/case/camel-case.cjs +59 -0
- package/dist/case/camel-case.d.cts +7 -0
- package/dist/case/camel-case.d.mts +7 -0
- package/dist/case/camel-case.d.ts +7 -0
- package/dist/case/camel-case.mjs +57 -0
- package/dist/case/capital-case.cjs +51 -0
- package/dist/case/capital-case.d.cts +7 -0
- package/dist/case/capital-case.d.mts +7 -0
- package/dist/case/capital-case.d.ts +7 -0
- package/dist/case/capital-case.mjs +49 -0
- package/dist/case/constant-case.cjs +11 -0
- package/dist/case/constant-case.d.cts +7 -0
- package/dist/case/constant-case.d.mts +7 -0
- package/dist/case/constant-case.d.ts +7 -0
- package/dist/case/constant-case.mjs +9 -0
- package/dist/case/dot-case.cjs +11 -0
- package/dist/case/dot-case.d.cts +7 -0
- package/dist/case/dot-case.d.mts +7 -0
- package/dist/case/dot-case.d.ts +7 -0
- package/dist/case/dot-case.mjs +9 -0
- package/dist/case/flat-case.cjs +11 -0
- package/dist/case/flat-case.d.cts +7 -0
- package/dist/case/flat-case.d.mts +7 -0
- package/dist/case/flat-case.d.ts +7 -0
- package/dist/case/flat-case.mjs +9 -0
- package/dist/case/flip-case.cjs +61 -0
- package/dist/case/flip-case.d.cts +8 -0
- package/dist/case/flip-case.d.mts +8 -0
- package/dist/case/flip-case.d.ts +8 -0
- package/dist/case/flip-case.mjs +57 -0
- package/dist/case/identify-case.cjs +30 -0
- package/dist/case/identify-case.d.cts +7 -0
- package/dist/case/identify-case.d.mts +7 -0
- package/dist/case/identify-case.d.ts +7 -0
- package/dist/case/identify-case.mjs +28 -0
- package/dist/case/index.cjs +47 -0
- package/dist/case/index.d.cts +26 -0
- package/dist/case/index.d.mts +26 -0
- package/dist/case/index.d.ts +26 -0
- package/dist/case/index.mjs +20 -0
- package/dist/case/kebab-case.cjs +61 -0
- package/dist/case/kebab-case.d.cts +11 -0
- package/dist/case/kebab-case.d.mts +11 -0
- package/dist/case/kebab-case.d.ts +11 -0
- package/dist/case/kebab-case.mjs +57 -0
- package/dist/case/lower-first.cjs +13 -0
- package/dist/case/lower-first.d.cts +7 -0
- package/dist/case/lower-first.d.mts +7 -0
- package/dist/case/lower-first.d.ts +7 -0
- package/dist/case/lower-first.mjs +11 -0
- package/dist/case/no-case.cjs +11 -0
- package/dist/case/no-case.d.cts +7 -0
- package/dist/case/no-case.d.mts +7 -0
- package/dist/case/no-case.d.ts +7 -0
- package/dist/case/no-case.mjs +9 -0
- package/dist/case/pascal-case.cjs +52 -0
- package/dist/case/pascal-case.d.cts +7 -0
- package/dist/case/pascal-case.d.mts +7 -0
- package/dist/case/pascal-case.d.ts +7 -0
- package/dist/case/pascal-case.mjs +50 -0
- package/dist/case/pascal-snake-case.cjs +32 -0
- package/dist/case/pascal-snake-case.d.cts +7 -0
- package/dist/case/pascal-snake-case.d.mts +7 -0
- package/dist/case/pascal-snake-case.d.ts +7 -0
- package/dist/case/pascal-snake-case.mjs +30 -0
- package/dist/case/path-case.cjs +11 -0
- package/dist/case/path-case.d.cts +7 -0
- package/dist/case/path-case.d.mts +7 -0
- package/dist/case/path-case.d.ts +7 -0
- package/dist/case/path-case.mjs +9 -0
- package/dist/case/sentence-case.cjs +58 -0
- package/dist/case/sentence-case.d.cts +7 -0
- package/dist/case/sentence-case.d.mts +7 -0
- package/dist/case/sentence-case.d.ts +7 -0
- package/dist/case/sentence-case.mjs +56 -0
- package/dist/case/snake-case.cjs +11 -0
- package/dist/case/snake-case.d.cts +7 -0
- package/dist/case/snake-case.d.mts +7 -0
- package/dist/case/snake-case.d.ts +7 -0
- package/dist/case/snake-case.mjs +9 -0
- package/dist/case/split-by-case.cjs +638 -0
- package/dist/case/split-by-case.d.cts +16 -0
- package/dist/case/split-by-case.d.mts +16 -0
- package/dist/case/split-by-case.d.ts +16 -0
- package/dist/case/split-by-case.mjs +634 -0
- package/dist/case/title-case.cjs +47 -0
- package/dist/case/title-case.d.cts +7 -0
- package/dist/case/title-case.d.mts +7 -0
- package/dist/case/title-case.d.ts +7 -0
- package/dist/case/title-case.mjs +45 -0
- package/dist/case/train-case.cjs +44 -0
- package/dist/case/train-case.d.cts +7 -0
- package/dist/case/train-case.d.mts +7 -0
- package/dist/case/train-case.d.ts +7 -0
- package/dist/case/train-case.mjs +42 -0
- package/dist/case/upper-first.cjs +13 -0
- package/dist/case/upper-first.d.cts +7 -0
- package/dist/case/upper-first.d.mts +7 -0
- package/dist/case/upper-first.d.ts +7 -0
- package/dist/case/upper-first.mjs +11 -0
- package/dist/get-string-truncated-width.cjs +386 -0
- package/dist/get-string-truncated-width.d.cts +25 -0
- package/dist/get-string-truncated-width.d.mts +25 -0
- package/dist/get-string-truncated-width.d.ts +25 -0
- package/dist/get-string-truncated-width.mjs +382 -0
- package/dist/get-string-width.cjs +11 -0
- package/dist/get-string-width.d.cts +6 -0
- package/dist/get-string-width.d.mts +6 -0
- package/dist/get-string-width.d.ts +6 -0
- package/dist/get-string-width.mjs +7 -0
- package/dist/index.cjs +60 -0
- package/dist/index.d.cts +43 -0
- package/dist/index.d.mts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.mjs +26 -0
- package/dist/native-string-types.d.cts +128 -0
- package/dist/native-string-types.d.mts +128 -0
- package/dist/native-string-types.d.ts +128 -0
- package/dist/outdent.cjs +122 -0
- package/dist/outdent.d.cts +15 -0
- package/dist/outdent.d.mts +15 -0
- package/dist/outdent.d.ts +15 -0
- package/dist/outdent.mjs +118 -0
- package/dist/packem_shared/LRUCache-Crb-m7cw.cjs +53 -0
- package/dist/packem_shared/LRUCache-udNErhWw.mjs +51 -0
- package/dist/packem_shared/WrapMode-BgOOthJV.mjs +545 -0
- package/dist/packem_shared/WrapMode-ZqTeXK8X.cjs +550 -0
- package/dist/packem_shared/constants-BnVGLrDr.mjs +99 -0
- package/dist/packem_shared/constants-HevSYUjU.cjs +149 -0
- package/dist/packem_shared/generate-cache-key-D8f1auDB.cjs +10 -0
- package/dist/packem_shared/generate-cache-key-YSju5pj2.mjs +8 -0
- package/dist/packem_shared/joinSegments-BH1CT4dK.cjs +48 -0
- package/dist/packem_shared/joinSegments-BHY8PPnk.mjs +46 -0
- package/dist/packem_shared/normalize-german-eszett-DJK0S2qj.cjs +11 -0
- package/dist/packem_shared/normalize-german-eszett-fpJ4lZL6.mjs +9 -0
- package/dist/packem_shared/types-BAd3WDHo.d.mts +59 -0
- package/dist/packem_shared/types-BNbQJg02.d.cts +41 -0
- package/dist/packem_shared/types-BNbQJg02.d.mts +41 -0
- package/dist/packem_shared/types-BNbQJg02.d.ts +41 -0
- package/dist/packem_shared/types-BttWSSIk.d.ts +59 -0
- package/dist/packem_shared/types-D2-6p7t1.d.cts +59 -0
- package/dist/slice.cjs +413 -0
- package/dist/slice.d.cts +10 -0
- package/dist/slice.d.mts +10 -0
- package/dist/slice.d.ts +10 -0
- package/dist/slice.mjs +409 -0
- package/dist/test/utils.cjs +77 -0
- package/dist/test/utils.d.cts +30 -0
- package/dist/test/utils.d.mts +30 -0
- package/dist/test/utils.d.ts +30 -0
- package/dist/test/utils.mjs +71 -0
- package/dist/test/vitest.cjs +11 -0
- package/dist/test/vitest.d.cts +8 -0
- package/dist/test/vitest.d.mts +8 -0
- package/dist/test/vitest.d.ts +8 -0
- package/dist/test/vitest.mjs +7 -0
- package/dist/truncate.cjs +90 -0
- package/dist/truncate.d.cts +12 -0
- package/dist/truncate.d.mts +12 -0
- package/dist/truncate.d.ts +12 -0
- package/dist/truncate.mjs +86 -0
- package/dist/utils.cjs +9 -0
- package/dist/utils.d.cts +14 -0
- package/dist/utils.d.mts +14 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.mjs +1 -0
- package/package.json +468 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { expectAnsiStrings } from './utils.mjs';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const toEqualAnsi = /* @__PURE__ */ __name((actual, expected) => expectAnsiStrings(actual, expected), "toEqualAnsi");
|
|
6
|
+
|
|
7
|
+
export { toEqualAnsi };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const getStringTruncatedWidth = require('./get-string-truncated-width.cjs');
|
|
6
|
+
const slice = require('./slice.cjs');
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
const DEFAULT_ELLIPSIS = "…";
|
|
11
|
+
const MAX_SPACE_SEARCH_DISTANCE = 3;
|
|
12
|
+
const findNearestSpace = /* @__PURE__ */ __name((string_, startIndex, searchRight = false) => {
|
|
13
|
+
if (string_.charAt(startIndex) === " ") {
|
|
14
|
+
return startIndex;
|
|
15
|
+
}
|
|
16
|
+
const direction = searchRight ? 1 : -1;
|
|
17
|
+
const limit = Math.min(MAX_SPACE_SEARCH_DISTANCE, searchRight ? string_.length - startIndex : startIndex);
|
|
18
|
+
for (let offset = 1; offset <= limit; offset++) {
|
|
19
|
+
const index = startIndex + offset * direction;
|
|
20
|
+
if (string_.charAt(index) === " ") {
|
|
21
|
+
return index;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return startIndex;
|
|
25
|
+
}, "findNearestSpace");
|
|
26
|
+
const truncate = /* @__PURE__ */ __name((input, limit, options = {}) => {
|
|
27
|
+
if (typeof input !== "string") {
|
|
28
|
+
throw new TypeError(`Expected \`input\` to be a string, got ${typeof input}`);
|
|
29
|
+
}
|
|
30
|
+
if (typeof limit !== "number") {
|
|
31
|
+
throw new TypeError(`Expected \`limit\` to be a number, got ${typeof limit}`);
|
|
32
|
+
}
|
|
33
|
+
if (input === "" || limit <= 0) {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
const { ellipsis = DEFAULT_ELLIPSIS, position = "end", preferTruncationOnSpace = false } = options;
|
|
37
|
+
let ellipsisWidth = options.ellipsisWidth ?? ellipsis === DEFAULT_ELLIPSIS ? 2 : void 0;
|
|
38
|
+
if (ellipsisWidth === void 0) {
|
|
39
|
+
ellipsisWidth = getStringTruncatedWidth.getStringTruncatedWidth(ellipsis, {
|
|
40
|
+
...options.width,
|
|
41
|
+
ellipsis: "",
|
|
42
|
+
ellipsisWidth: 0,
|
|
43
|
+
limit: Number.POSITIVE_INFINITY
|
|
44
|
+
}).width;
|
|
45
|
+
}
|
|
46
|
+
if (limit === 1 && ellipsisWidth === 1) {
|
|
47
|
+
return ellipsis;
|
|
48
|
+
}
|
|
49
|
+
if (limit === 1) {
|
|
50
|
+
return "";
|
|
51
|
+
}
|
|
52
|
+
const { width } = getStringTruncatedWidth.getStringTruncatedWidth(input, {
|
|
53
|
+
...options.width,
|
|
54
|
+
ellipsis,
|
|
55
|
+
ellipsisWidth
|
|
56
|
+
});
|
|
57
|
+
if (width <= limit) {
|
|
58
|
+
return input;
|
|
59
|
+
}
|
|
60
|
+
switch (position) {
|
|
61
|
+
case "start": {
|
|
62
|
+
if (preferTruncationOnSpace) {
|
|
63
|
+
const nearestSpace = findNearestSpace(input, width - limit + 1, true);
|
|
64
|
+
return ellipsis + slice.slice(input, nearestSpace, width).trim();
|
|
65
|
+
}
|
|
66
|
+
return ellipsis + slice.slice(input, width - limit + ellipsisWidth, width);
|
|
67
|
+
}
|
|
68
|
+
case "middle": {
|
|
69
|
+
const half = Math.floor(limit / 2);
|
|
70
|
+
if (preferTruncationOnSpace) {
|
|
71
|
+
const firstBreak = findNearestSpace(input, half);
|
|
72
|
+
const secondBreak = findNearestSpace(input, width - (limit - half) + 1, true);
|
|
73
|
+
return slice.slice(input, 0, firstBreak) + ellipsis + slice.slice(input, secondBreak, width).trim();
|
|
74
|
+
}
|
|
75
|
+
return slice.slice(input, 0, half) + ellipsis + slice.slice(input, width - (limit - half) + ellipsisWidth, width);
|
|
76
|
+
}
|
|
77
|
+
case "end": {
|
|
78
|
+
if (preferTruncationOnSpace) {
|
|
79
|
+
const nearestSpace = findNearestSpace(input, limit - 1);
|
|
80
|
+
return slice.slice(input, 0, nearestSpace) + ellipsis;
|
|
81
|
+
}
|
|
82
|
+
return slice.slice(input, 0, limit - ellipsisWidth) + ellipsis;
|
|
83
|
+
}
|
|
84
|
+
default: {
|
|
85
|
+
throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${position}'`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, "truncate");
|
|
89
|
+
|
|
90
|
+
exports.truncate = truncate;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StringTruncatedWidthOptions } from './get-string-truncated-width.cjs';
|
|
2
|
+
|
|
3
|
+
type TruncateOptions = {
|
|
4
|
+
ellipsis?: string;
|
|
5
|
+
ellipsisWidth?: number;
|
|
6
|
+
position?: "end" | "middle" | "start";
|
|
7
|
+
preferTruncationOnSpace?: boolean;
|
|
8
|
+
width?: Omit<StringTruncatedWidthOptions, "ellipsis" | "ellipsisWidth" | "limit">;
|
|
9
|
+
};
|
|
10
|
+
declare const truncate: (input: string, limit: number, options?: TruncateOptions) => string;
|
|
11
|
+
|
|
12
|
+
export { type TruncateOptions, truncate };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StringTruncatedWidthOptions } from './get-string-truncated-width.mjs';
|
|
2
|
+
|
|
3
|
+
type TruncateOptions = {
|
|
4
|
+
ellipsis?: string;
|
|
5
|
+
ellipsisWidth?: number;
|
|
6
|
+
position?: "end" | "middle" | "start";
|
|
7
|
+
preferTruncationOnSpace?: boolean;
|
|
8
|
+
width?: Omit<StringTruncatedWidthOptions, "ellipsis" | "ellipsisWidth" | "limit">;
|
|
9
|
+
};
|
|
10
|
+
declare const truncate: (input: string, limit: number, options?: TruncateOptions) => string;
|
|
11
|
+
|
|
12
|
+
export { type TruncateOptions, truncate };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StringTruncatedWidthOptions } from './get-string-truncated-width.js';
|
|
2
|
+
|
|
3
|
+
type TruncateOptions = {
|
|
4
|
+
ellipsis?: string;
|
|
5
|
+
ellipsisWidth?: number;
|
|
6
|
+
position?: "end" | "middle" | "start";
|
|
7
|
+
preferTruncationOnSpace?: boolean;
|
|
8
|
+
width?: Omit<StringTruncatedWidthOptions, "ellipsis" | "ellipsisWidth" | "limit">;
|
|
9
|
+
};
|
|
10
|
+
declare const truncate: (input: string, limit: number, options?: TruncateOptions) => string;
|
|
11
|
+
|
|
12
|
+
export { type TruncateOptions, truncate };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { getStringTruncatedWidth } from './get-string-truncated-width.mjs';
|
|
2
|
+
import { slice } from './slice.mjs';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
const DEFAULT_ELLIPSIS = "…";
|
|
7
|
+
const MAX_SPACE_SEARCH_DISTANCE = 3;
|
|
8
|
+
const findNearestSpace = /* @__PURE__ */ __name((string_, startIndex, searchRight = false) => {
|
|
9
|
+
if (string_.charAt(startIndex) === " ") {
|
|
10
|
+
return startIndex;
|
|
11
|
+
}
|
|
12
|
+
const direction = searchRight ? 1 : -1;
|
|
13
|
+
const limit = Math.min(MAX_SPACE_SEARCH_DISTANCE, searchRight ? string_.length - startIndex : startIndex);
|
|
14
|
+
for (let offset = 1; offset <= limit; offset++) {
|
|
15
|
+
const index = startIndex + offset * direction;
|
|
16
|
+
if (string_.charAt(index) === " ") {
|
|
17
|
+
return index;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return startIndex;
|
|
21
|
+
}, "findNearestSpace");
|
|
22
|
+
const truncate = /* @__PURE__ */ __name((input, limit, options = {}) => {
|
|
23
|
+
if (typeof input !== "string") {
|
|
24
|
+
throw new TypeError(`Expected \`input\` to be a string, got ${typeof input}`);
|
|
25
|
+
}
|
|
26
|
+
if (typeof limit !== "number") {
|
|
27
|
+
throw new TypeError(`Expected \`limit\` to be a number, got ${typeof limit}`);
|
|
28
|
+
}
|
|
29
|
+
if (input === "" || limit <= 0) {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
const { ellipsis = DEFAULT_ELLIPSIS, position = "end", preferTruncationOnSpace = false } = options;
|
|
33
|
+
let ellipsisWidth = options.ellipsisWidth ?? ellipsis === DEFAULT_ELLIPSIS ? 2 : void 0;
|
|
34
|
+
if (ellipsisWidth === void 0) {
|
|
35
|
+
ellipsisWidth = getStringTruncatedWidth(ellipsis, {
|
|
36
|
+
...options.width,
|
|
37
|
+
ellipsis: "",
|
|
38
|
+
ellipsisWidth: 0,
|
|
39
|
+
limit: Number.POSITIVE_INFINITY
|
|
40
|
+
}).width;
|
|
41
|
+
}
|
|
42
|
+
if (limit === 1 && ellipsisWidth === 1) {
|
|
43
|
+
return ellipsis;
|
|
44
|
+
}
|
|
45
|
+
if (limit === 1) {
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
const { width } = getStringTruncatedWidth(input, {
|
|
49
|
+
...options.width,
|
|
50
|
+
ellipsis,
|
|
51
|
+
ellipsisWidth
|
|
52
|
+
});
|
|
53
|
+
if (width <= limit) {
|
|
54
|
+
return input;
|
|
55
|
+
}
|
|
56
|
+
switch (position) {
|
|
57
|
+
case "start": {
|
|
58
|
+
if (preferTruncationOnSpace) {
|
|
59
|
+
const nearestSpace = findNearestSpace(input, width - limit + 1, true);
|
|
60
|
+
return ellipsis + slice(input, nearestSpace, width).trim();
|
|
61
|
+
}
|
|
62
|
+
return ellipsis + slice(input, width - limit + ellipsisWidth, width);
|
|
63
|
+
}
|
|
64
|
+
case "middle": {
|
|
65
|
+
const half = Math.floor(limit / 2);
|
|
66
|
+
if (preferTruncationOnSpace) {
|
|
67
|
+
const firstBreak = findNearestSpace(input, half);
|
|
68
|
+
const secondBreak = findNearestSpace(input, width - (limit - half) + 1, true);
|
|
69
|
+
return slice(input, 0, firstBreak) + ellipsis + slice(input, secondBreak, width).trim();
|
|
70
|
+
}
|
|
71
|
+
return slice(input, 0, half) + ellipsis + slice(input, width - (limit - half) + ellipsisWidth, width);
|
|
72
|
+
}
|
|
73
|
+
case "end": {
|
|
74
|
+
if (preferTruncationOnSpace) {
|
|
75
|
+
const nearestSpace = findNearestSpace(input, limit - 1);
|
|
76
|
+
return slice(input, 0, nearestSpace) + ellipsis;
|
|
77
|
+
}
|
|
78
|
+
return slice(input, 0, limit - ellipsisWidth) + ellipsis;
|
|
79
|
+
}
|
|
80
|
+
default: {
|
|
81
|
+
throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${position}'`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, "truncate");
|
|
85
|
+
|
|
86
|
+
export { truncate };
|
package/dist/utils.cjs
ADDED
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class LRUCache<K, V> {
|
|
2
|
+
private readonly capacity;
|
|
3
|
+
private readonly cache;
|
|
4
|
+
private keyOrder;
|
|
5
|
+
constructor(capacity: number);
|
|
6
|
+
get(key: K): V | undefined;
|
|
7
|
+
has(key: K): boolean;
|
|
8
|
+
set(key: K, value: V): void;
|
|
9
|
+
delete(key: K): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
size(): number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { LRUCache };
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class LRUCache<K, V> {
|
|
2
|
+
private readonly capacity;
|
|
3
|
+
private readonly cache;
|
|
4
|
+
private keyOrder;
|
|
5
|
+
constructor(capacity: number);
|
|
6
|
+
get(key: K): V | undefined;
|
|
7
|
+
has(key: K): boolean;
|
|
8
|
+
set(key: K, value: V): void;
|
|
9
|
+
delete(key: K): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
size(): number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { LRUCache };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class LRUCache<K, V> {
|
|
2
|
+
private readonly capacity;
|
|
3
|
+
private readonly cache;
|
|
4
|
+
private keyOrder;
|
|
5
|
+
constructor(capacity: number);
|
|
6
|
+
get(key: K): V | undefined;
|
|
7
|
+
has(key: K): boolean;
|
|
8
|
+
set(key: K, value: V): void;
|
|
9
|
+
delete(key: K): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
size(): number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { LRUCache };
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as LRUCache } from './packem_shared/LRUCache-udNErhWw.mjs';
|