@quenty/lrucache 1.9.0 → 1.10.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 CHANGED
@@ -3,152 +3,88 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # [1.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.8.0...@quenty/lrucache@1.9.0) (2026-04-23)
7
-
8
- **Note:** Version bump only for package @quenty/lrucache
6
+ # [1.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.9.0...@quenty/lrucache@1.10.0) (2026-07-14)
9
7
 
8
+ ### Features
10
9
 
10
+ - **lrucache:** convert package to --!strict ([ddb8f7b](https://github.com/Quenty/NevermoreEngine/commit/ddb8f7b54b4f1f5913b1fb8fe45d655086d8a190))
11
11
 
12
+ # [1.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.8.0...@quenty/lrucache@1.9.0) (2026-04-23)
12
13
 
14
+ **Note:** Version bump only for package @quenty/lrucache
13
15
 
14
16
  # [1.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.7.3...@quenty/lrucache@1.8.0) (2026-02-17)
15
17
 
16
-
17
18
  ### Features
18
19
 
19
- * Add CI/CD batch unit testing ([016a366](https://github.com/Quenty/NevermoreEngine/commit/016a3663509c8fffa518b07cfc49ebecba2a1fa6))
20
-
21
-
22
-
23
-
20
+ - Add CI/CD batch unit testing ([016a366](https://github.com/Quenty/NevermoreEngine/commit/016a3663509c8fffa518b07cfc49ebecba2a1fa6))
24
21
 
25
22
  ## [1.7.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.7.2...@quenty/lrucache@1.7.3) (2026-01-12)
26
23
 
27
-
28
24
  ### Bug Fixes
29
25
 
30
- * Fix dependency installation process for pnpm ([9651b09](https://github.com/Quenty/NevermoreEngine/commit/9651b09af34f252ef3f9c7c539793cc878dd8cba))
31
-
32
-
33
-
34
-
26
+ - Fix dependency installation process for pnpm ([9651b09](https://github.com/Quenty/NevermoreEngine/commit/9651b09af34f252ef3f9c7c539793cc878dd8cba))
35
27
 
36
28
  ## [1.7.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.7.1...@quenty/lrucache@1.7.2) (2026-01-10)
37
29
 
38
30
  **Note:** Version bump only for package @quenty/lrucache
39
31
 
40
-
41
-
42
-
43
-
44
32
  ## [1.7.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.7.0...@quenty/lrucache@1.7.1) (2026-01-03)
45
33
 
46
34
  **Note:** Version bump only for package @quenty/lrucache
47
35
 
48
-
49
-
50
-
51
-
52
36
  # [1.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.6.3...@quenty/lrucache@1.7.0) (2025-05-10)
53
37
 
54
-
55
38
  ### Bug Fixes
56
39
 
57
- * Additional type checking updates ([05ba29a](https://github.com/Quenty/NevermoreEngine/commit/05ba29a03efc9f3feed74b34f1d9dfb237496214))
58
-
59
-
60
-
61
-
40
+ - Additional type checking updates ([05ba29a](https://github.com/Quenty/NevermoreEngine/commit/05ba29a03efc9f3feed74b34f1d9dfb237496214))
62
41
 
63
42
  ## [1.6.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.6.2...@quenty/lrucache@1.6.3) (2025-04-10)
64
43
 
65
44
  **Note:** Version bump only for package @quenty/lrucache
66
45
 
67
-
68
-
69
-
70
-
71
46
  ## [1.6.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.6.0...@quenty/lrucache@1.6.2) (2025-04-07)
72
47
 
73
-
74
48
  ### Bug Fixes
75
49
 
76
- * Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
77
- * Bump package versions for republishing ([ba47c62](https://github.com/Quenty/NevermoreEngine/commit/ba47c62e32170bf74377b0c658c60b84306dc294))
78
-
79
-
80
-
81
-
50
+ - Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
51
+ - Bump package versions for republishing ([ba47c62](https://github.com/Quenty/NevermoreEngine/commit/ba47c62e32170bf74377b0c658c60b84306dc294))
82
52
 
83
53
  ## [1.6.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.6.0...@quenty/lrucache@1.6.1) (2025-04-07)
84
54
 
85
-
86
55
  ### Bug Fixes
87
56
 
88
- * Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
89
-
90
-
91
-
92
-
57
+ - Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
93
58
 
94
59
  # [1.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.5.1...@quenty/lrucache@1.6.0) (2025-02-18)
95
60
 
96
61
  **Note:** Version bump only for package @quenty/lrucache
97
62
 
98
-
99
-
100
-
101
-
102
63
  ## [1.5.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.5.0...@quenty/lrucache@1.5.1) (2024-11-04)
103
64
 
104
65
  **Note:** Version bump only for package @quenty/lrucache
105
66
 
106
-
107
-
108
-
109
-
110
67
  # [1.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.4.0...@quenty/lrucache@1.5.0) (2024-10-06)
111
68
 
112
69
  **Note:** Version bump only for package @quenty/lrucache
113
70
 
114
-
115
-
116
-
117
-
118
71
  # [1.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.3.0...@quenty/lrucache@1.4.0) (2024-10-04)
119
72
 
120
73
  **Note:** Version bump only for package @quenty/lrucache
121
74
 
122
-
123
-
124
-
125
-
126
75
  # [1.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.2.0...@quenty/lrucache@1.3.0) (2024-09-25)
127
76
 
128
77
  **Note:** Version bump only for package @quenty/lrucache
129
78
 
130
-
131
-
132
-
133
-
134
79
  # [1.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/lrucache@1.1.0...@quenty/lrucache@1.2.0) (2024-09-12)
135
80
 
136
81
  **Note:** Version bump only for package @quenty/lrucache
137
82
 
138
-
139
-
140
-
141
-
142
83
  # 1.1.0 (2024-05-09)
143
84
 
144
-
145
85
  ### Features
146
86
 
147
- * Add LRUCache package ([f5ded94](https://github.com/Quenty/NevermoreEngine/commit/f5ded9480dc991105dfdb3c36d9152329a18882a))
148
-
149
-
150
-
151
-
87
+ - Add LRUCache package ([f5ded94](https://github.com/Quenty/NevermoreEngine/commit/f5ded9480dc991105dfdb3c36d9152329a18882a))
152
88
 
153
89
  # v1.1.0 (Thu May 09 2024)
154
90
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/lrucache",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "LRUCache library",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "9413391da8b6f9026762285b601fd1d37d385a54"
36
+ "gitHead": "13f0162f4971a77378e55e9b7236aea94f0dd3a8"
37
37
  }
@@ -1,4 +1,4 @@
1
- --!nonstrict
1
+ --!strict
2
2
  -- lua-lru, LRU cache in Lua
3
3
  -- Copyright (c) 2015 Boris Nagaev
4
4
  --[[
@@ -29,7 +29,19 @@ SOFTWARE.
29
29
  local LRUCache = {}
30
30
  LRUCache.ClassName = "LRUCache"
31
31
 
32
- function LRUCache.new(maxSize: number, maxBytes: number?)
32
+ export type LRUCache = typeof(setmetatable(
33
+ {} :: {},
34
+ {} :: {
35
+ __index: {
36
+ get: (LRUCache, key: any) -> any,
37
+ set: (LRUCache, key: any, value: any, bytes: number?) -> (),
38
+ delete: (LRUCache, key: any) -> (),
39
+ pairs: (LRUCache) -> ((any, any?) -> (any, any), any, any),
40
+ },
41
+ }
42
+ ))
43
+
44
+ function LRUCache.new(maxSize: number, maxBytes: number?): LRUCache
33
45
  assert(maxSize >= 1, "maxSize must be >= 1")
34
46
  assert(not maxBytes or maxBytes >= 1, "maxBytes must be >= 1")
35
47
 
@@ -40,7 +52,7 @@ function LRUCache.new(maxSize: number, maxBytes: number?)
40
52
  -- map is a hash map from keys to tuples
41
53
  -- tuple: value, prev, next, key
42
54
  -- prev and next are pointers to tuples
43
- local map = {}
55
+ local map: { [any]: { any } } = {}
44
56
 
45
57
  -- indices of tuple
46
58
  local VALUE = 1
@@ -50,13 +62,13 @@ function LRUCache.new(maxSize: number, maxBytes: number?)
50
62
  local BYTES = 5
51
63
 
52
64
  -- newest and oldest are ends of double-linked list
53
- local newest = nil -- first
54
- local oldest = nil -- last
65
+ local newest: { any }? = nil -- first
66
+ local oldest: { any }? = nil -- last
55
67
 
56
- local removed_tuple -- created in del(), removed in set()
68
+ local removed_tuple: { any }? -- created in del(), removed in set()
57
69
 
58
70
  -- remove a tuple from linked list
59
- local function cut(tuple)
71
+ local function cut(tuple: { any })
60
72
  local tuple_prev = tuple[PREV]
61
73
  local tuple_next = tuple[NEXT]
62
74
  tuple[PREV] = nil
@@ -80,7 +92,7 @@ function LRUCache.new(maxSize: number, maxBytes: number?)
80
92
  end
81
93
 
82
94
  -- insert a tuple to the newest end
83
- local function setNewest(tuple)
95
+ local function setNewest(tuple: { any })
84
96
  if not newest then
85
97
  newest = tuple
86
98
  oldest = tuple
@@ -91,7 +103,7 @@ function LRUCache.new(maxSize: number, maxBytes: number?)
91
103
  end
92
104
  end
93
105
 
94
- local function del(key, tuple)
106
+ local function del(key: any, tuple: { any }): ()
95
107
  map[key] = nil
96
108
  cut(tuple)
97
109
  size = size - 1
@@ -101,14 +113,14 @@ function LRUCache.new(maxSize: number, maxBytes: number?)
101
113
 
102
114
  -- removes elemenets to provide enough memory
103
115
  -- returns last removed element or nil
104
- local function makeFreeSpace(bytes)
116
+ local function makeFreeSpace(bytes: number): ()
105
117
  while size + 1 > maxSize or (maxBytes and bytesUsed + bytes > maxBytes) do
106
118
  assert(oldest, "not enough storage for cache")
107
119
  del(oldest[KEY], oldest)
108
120
  end
109
121
  end
110
122
 
111
- local function get(_, key)
123
+ local function get(_: any, key: any): any
112
124
  local tuple = map[key]
113
125
  if not tuple then
114
126
  return nil
@@ -118,22 +130,22 @@ function LRUCache.new(maxSize: number, maxBytes: number?)
118
130
  return tuple[VALUE]
119
131
  end
120
132
 
121
- local function set(_, key, value, bytes)
133
+ local function set(_: any, key: any, value: any, bytes: number?): ()
122
134
  local tuple = map[key]
123
135
  if tuple then
124
136
  del(key, tuple)
125
137
  end
126
138
  if value ~= nil then
127
139
  -- the value is not removed
128
- bytes = maxBytes and (bytes or #value) or 0
129
- makeFreeSpace(bytes)
140
+ local computedBytes = maxBytes and (bytes or #value) or 0
141
+ makeFreeSpace(computedBytes)
130
142
  local tuple1 = removed_tuple or {}
131
143
  map[key] = tuple1
132
144
  tuple1[VALUE] = value
133
145
  tuple1[KEY] = key
134
- tuple1[BYTES] = maxBytes and bytes
146
+ tuple1[BYTES] = maxBytes and computedBytes
135
147
  size = size + 1
136
- bytesUsed = bytesUsed + bytes
148
+ bytesUsed = bytesUsed + computedBytes
137
149
  setNewest(tuple1)
138
150
  else
139
151
  assert(key ~= nil, "Key may not be nil")
@@ -141,11 +153,11 @@ function LRUCache.new(maxSize: number, maxBytes: number?)
141
153
  removed_tuple = nil
142
154
  end
143
155
 
144
- local function delete(_, key)
156
+ local function delete(_: any, key: any): ()
145
157
  return set(nil, key, nil)
146
158
  end
147
159
 
148
- local function mynext(_, prev_key)
160
+ local function mynext(_: any, prev_key: any): (any, any)
149
161
  local tuple
150
162
  if prev_key then
151
163
  tuple = map[prev_key][NEXT]
@@ -174,7 +186,7 @@ function LRUCache.new(maxSize: number, maxBytes: number?)
174
186
  __pairs = lru_pairs,
175
187
  }
176
188
 
177
- return setmetatable({}, mt)
189
+ return setmetatable({}, mt) :: any
178
190
  end
179
191
 
180
192
  return LRUCache