petty-cache 3.5.0 → 3.7.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 +8 -0
- package/LICENSE +21 -201
- package/README.md +58 -15
- package/eslint.config.js +1 -15
- package/index.js +475 -245
- package/package.json +32 -34
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [3.7.0] - 2026-03-12
|
|
10
|
+
### Changed
|
|
11
|
+
- Added the ability for `pettyCache.bulkGet`, `pettyCache.bulkSet`, and `pettyCache.bulkFetch` functions to support callbacks and promises.
|
|
12
|
+
|
|
13
|
+
## [3.6.0] - 2026-02-12
|
|
14
|
+
### Changed
|
|
15
|
+
- Added the ability for `pettyCache.get`, `pettyCache.set`, and `pettyCache.patch` functions to support callbacks and promises.
|
|
16
|
+
|
|
9
17
|
## [3.5.0] - 2025-05-01
|
|
10
18
|
### Changed
|
|
11
19
|
- Added the ability for `pettyCache.del` functions to support callbacks and promises.
|
package/LICENSE
CHANGED
|
@@ -1,201 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright {yyyy} {name of copyright owner}
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stores.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# petty-cache
|
|
2
2
|
|
|
3
|
-
[](https://github.com/stores-com/petty-cache/actions?query=workflow%3Abuild+branch%3Amain)
|
|
4
|
+
[](https://coveralls.io/github/stores-com/petty-cache?branch=main)
|
|
5
|
+
[](https://www.npmjs.com/package/petty-cache)
|
|
6
|
+
[](LICENSE)
|
|
5
7
|
|
|
6
8
|
A cache module for Node.js that uses a two-level cache (in-memory cache for recently accessed data plus Redis for distributed caching) with automatic serialization plus some extra features to avoid cache stampedes and thundering herds.
|
|
7
9
|
|
|
@@ -28,8 +30,8 @@ Provides a pool of distributed locks with the ability to release a slot back to
|
|
|
28
30
|
|
|
29
31
|
```javascript
|
|
30
32
|
// Setup petty-cache
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const PettyCache = require('petty-cache');
|
|
34
|
+
const pettyCache = new PettyCache();
|
|
33
35
|
|
|
34
36
|
// Fetch some data
|
|
35
37
|
pettyCache.fetch('key', function(callback) {
|
|
@@ -71,7 +73,7 @@ Attempts to retrieve the values of the keys specified in the `keys` array. Any k
|
|
|
71
73
|
```javascript
|
|
72
74
|
// Let's assume a and b are already cached as 1 and 2
|
|
73
75
|
pettyCache.bulkFetch(['a', 'b', 'c', 'd'], function(keys, callback) {
|
|
74
|
-
|
|
76
|
+
const results = {};
|
|
75
77
|
|
|
76
78
|
keys.forEach(function(key) {
|
|
77
79
|
results[key] = key.toUpperCase();
|
|
@@ -145,6 +147,24 @@ pettyCache.set({ key1: 'one', key2: 2, key3: 'three' }, function(err) {
|
|
|
145
147
|
}
|
|
146
148
|
```
|
|
147
149
|
|
|
150
|
+
### pettyCache.del(key, [callback])
|
|
151
|
+
|
|
152
|
+
Deletes a value from both the in-memory cache and Redis. Supports both callbacks and promises.
|
|
153
|
+
|
|
154
|
+
**Example**
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
pettyCache.del('key', function(err) {
|
|
158
|
+
if (err) {
|
|
159
|
+
// Handle redis error
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
await pettyCache.del('key');
|
|
166
|
+
```
|
|
167
|
+
|
|
148
168
|
### pettyCache.fetch(key, cacheMissFunction, [options,] callback)
|
|
149
169
|
|
|
150
170
|
Attempts to retrieve the value from cache at the specified key. If it doesn't exist, it executes the specified cacheMissFunction that takes two parameters: an error and a value. `cacheMissFunction` should retrieve the expected value for the key from another source and pass it to the given callback. Either way, the resulting error or value is passed to `callback`.
|
|
@@ -222,9 +242,9 @@ pettyCache.fetchAndRefresh('key', function(callback) {
|
|
|
222
242
|
}
|
|
223
243
|
```
|
|
224
244
|
|
|
225
|
-
### pettyCache.get(key, callback)
|
|
245
|
+
### pettyCache.get(key, [callback])
|
|
226
246
|
|
|
227
|
-
Attempts to retrieve the value from cache at the specified key. Returns `null` if the key doesn't exist.
|
|
247
|
+
Attempts to retrieve the value from cache at the specified key. Returns `null` if the key doesn't exist. Supports both callbacks and promises.
|
|
228
248
|
|
|
229
249
|
**Example**
|
|
230
250
|
|
|
@@ -235,14 +255,18 @@ pettyCache.get('key', function(err, value) {
|
|
|
235
255
|
});
|
|
236
256
|
```
|
|
237
257
|
|
|
238
|
-
|
|
258
|
+
```javascript
|
|
259
|
+
const value = await pettyCache.get('key');
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### pettyCache.patch(key, value, [options, [callback]])
|
|
239
263
|
|
|
240
|
-
Updates an object at the given key with the property values provided. Sends an error to the callback if the key does not exist.
|
|
264
|
+
Updates an object at the given key with the property values provided. Sends an error to the callback if the key does not exist. Supports both callbacks and promises.
|
|
241
265
|
|
|
242
266
|
**Example**
|
|
243
267
|
|
|
244
268
|
```javascript
|
|
245
|
-
pettyCache.patch('key', { a: 1 }, function(
|
|
269
|
+
pettyCache.patch('key', { a: 1 }, function(err) {
|
|
246
270
|
if (err) {
|
|
247
271
|
// Handle redis or key not found error
|
|
248
272
|
}
|
|
@@ -251,6 +275,10 @@ pettyCache.patch('key', { a: 1 }, function(callback) {
|
|
|
251
275
|
});
|
|
252
276
|
```
|
|
253
277
|
|
|
278
|
+
```javascript
|
|
279
|
+
await pettyCache.patch('key', { a: 1 });
|
|
280
|
+
```
|
|
281
|
+
|
|
254
282
|
**Options**
|
|
255
283
|
|
|
256
284
|
```
|
|
@@ -269,9 +297,9 @@ pettyCache.patch('key', { a: 1 }, function(callback) {
|
|
|
269
297
|
}
|
|
270
298
|
```
|
|
271
299
|
|
|
272
|
-
### pettyCache.set(key, value, [options,
|
|
300
|
+
### pettyCache.set(key, value, [options, [callback]])
|
|
273
301
|
|
|
274
|
-
Unconditionally sets a value for a given key.
|
|
302
|
+
Unconditionally sets a value for a given key. Supports both callbacks and promises.
|
|
275
303
|
|
|
276
304
|
**Example**
|
|
277
305
|
|
|
@@ -283,6 +311,10 @@ pettyCache.set('key', { a: 'b' }, function(err) {
|
|
|
283
311
|
});
|
|
284
312
|
```
|
|
285
313
|
|
|
314
|
+
```javascript
|
|
315
|
+
await pettyCache.set('key', { a: 'b' });
|
|
316
|
+
```
|
|
317
|
+
|
|
286
318
|
**Options**
|
|
287
319
|
|
|
288
320
|
```
|
|
@@ -305,7 +337,7 @@ pettyCache.set('key', { a: 'b' }, function(err) {
|
|
|
305
337
|
|
|
306
338
|
### pettyCache.mutex.lock(key, [options, [callback]])
|
|
307
339
|
|
|
308
|
-
Attempts to acquire a distributed lock for the specified key. Optionally retries a specified number of times by waiting a specified amount of time between attempts.
|
|
340
|
+
Attempts to acquire a distributed lock for the specified key. Optionally retries a specified number of times by waiting a specified amount of time between attempts. Supports both callbacks and promises.
|
|
309
341
|
|
|
310
342
|
```javascript
|
|
311
343
|
pettyCache.mutex.lock('key', { retry: { interval: 100, times: 5 }, ttl: 1000 }, function(err) {
|
|
@@ -318,6 +350,13 @@ pettyCache.mutex.lock('key', { retry: { interval: 100, times: 5 }, ttl: 1000 },
|
|
|
318
350
|
});
|
|
319
351
|
```
|
|
320
352
|
|
|
353
|
+
```javascript
|
|
354
|
+
await pettyCache.mutex.lock('key', { retry: { interval: 100, times: 5 }, ttl: 1000 });
|
|
355
|
+
|
|
356
|
+
// We were able to acquire the lock. Do work and then unlock.
|
|
357
|
+
await pettyCache.mutex.unlock('key');
|
|
358
|
+
```
|
|
359
|
+
|
|
321
360
|
**Options**
|
|
322
361
|
|
|
323
362
|
```javascript
|
|
@@ -332,7 +371,7 @@ pettyCache.mutex.lock('key', { retry: { interval: 100, times: 5 }, ttl: 1000 },
|
|
|
332
371
|
|
|
333
372
|
### pettyCache.mutex.unlock(key, [callback])
|
|
334
373
|
|
|
335
|
-
Releases the distributed lock for the specified key.
|
|
374
|
+
Releases the distributed lock for the specified key. Supports both callbacks and promises.
|
|
336
375
|
|
|
337
376
|
```javascript
|
|
338
377
|
pettyCache.mutex.unlock('key', function(err) {
|
|
@@ -342,6 +381,10 @@ pettyCache.mutex.unlock('key', function(err) {
|
|
|
342
381
|
});
|
|
343
382
|
```
|
|
344
383
|
|
|
384
|
+
```javascript
|
|
385
|
+
await pettyCache.mutex.unlock('key');
|
|
386
|
+
```
|
|
387
|
+
|
|
345
388
|
## Semaphore
|
|
346
389
|
|
|
347
390
|
Provides a pool of distributed locks. Once a consumer acquires a lock they have the ability to release the lock back to the pool or mark the lock as "consumed" so that it's not used again.
|
|
@@ -471,6 +514,6 @@ pettyCache.semaphore.retrieveOrCreate('key', { size: 10 }, function(err) {
|
|
|
471
514
|
|
|
472
515
|
```javascript
|
|
473
516
|
{
|
|
474
|
-
size: 1 || function() {
|
|
517
|
+
size: 1 || function() { const x = 1 + 1; callback(null, x); } // The number of locks to create in the semaphore's pool. Optionally, size can be a `callback(err, size)` function.
|
|
475
518
|
}
|
|
476
519
|
```
|
package/eslint.config.js
CHANGED
|
@@ -4,30 +4,16 @@ const js = require('@eslint/js');
|
|
|
4
4
|
module.exports = [
|
|
5
5
|
js.configs.recommended,
|
|
6
6
|
{
|
|
7
|
-
ignores: ['node_modules/*'],
|
|
8
7
|
languageOptions: {
|
|
9
|
-
ecmaVersion: 2020,
|
|
10
|
-
sourceType: 'module',
|
|
11
|
-
parserOptions: {
|
|
12
|
-
ecmaFeatures: {
|
|
13
|
-
jsx: true
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
8
|
globals: {
|
|
17
|
-
...globals.
|
|
18
|
-
...globals.mocha,
|
|
19
|
-
...globals.node,
|
|
20
|
-
//added for 'fetch()' access
|
|
21
|
-
...globals.serviceworker
|
|
9
|
+
...globals.node
|
|
22
10
|
}
|
|
23
11
|
},
|
|
24
12
|
rules: {
|
|
25
13
|
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
|
26
14
|
'comma-dangle': ['error', 'never'],
|
|
27
15
|
'dot-notation': 'error',
|
|
28
|
-
'no-array-constructor': 'error',
|
|
29
16
|
'no-console': 'error',
|
|
30
|
-
'no-fallthrough': 'off',
|
|
31
17
|
'no-inline-comments': 'warn',
|
|
32
18
|
'no-trailing-spaces': 'error',
|
|
33
19
|
'no-unused-vars': ['error', { caughtErrors: 'none' }],
|