Skip to content

Commit 5a1ad77

Browse files
committed
add interface
lint version bump
1 parent 15d0f4a commit 5a1ad77

17 files changed

Lines changed: 66 additions & 28 deletions

benchmark/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"@datastructures-js/queue": "4.2.3",
1313
"dsa.js": "2.7.6",
1414
"efficient-data-structures": "0.1.310",
15-
"markdown-table": "3.0.3",
16-
"mnemonist": "0.39.8",
17-
"shelljs": "^0.8.5"
15+
"markdown-table": "^3.0.4",
16+
"mnemonist": "^0.40.3",
17+
"shelljs": "^0.10.0"
1818
}
1919
}

benchmark/report-generator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ reportConfig.scenarios.forEach(scenario => {
1717
for (let i = 0; i < reportConfig.iterationsPerClass; i++) {
1818
commandObjects.push({
1919
scenarioName: scenario.name,
20-
scenario: scenario,
20+
scenario,
2121
className,
2222
command: `node ${path.join(__dirname, 'ramusage.js')} ${className} ${scenario.operations.join(' ')}`
2323
});
@@ -44,7 +44,7 @@ for (let i = 0; i < commandObjects.length; i++) {
4444
const resp = shell.exec(command, { silent: true });
4545
resultObjects.push({
4646
className: commandObject.className,
47-
scenarioName: scenarioName,
47+
scenarioName,
4848
scenario: commandObject.scenario,
4949
result: JSON.parse(resp.stdout)
5050
});
@@ -83,7 +83,7 @@ const stats = resultsByScenario.entries().map(([scenarioName, resultsByClassName
8383
const avgOpsPerSec = Math.trunc(avg(v.map(x => x.result.opsPerSec)));
8484
return {
8585
className: k,
86-
avgOpsPerSec: avgOpsPerSec,
86+
avgOpsPerSec,
8787
avgHeapUsed: Math.trunc(avg(v.map(x => x.result.heapUsed))),
8888
avgHeapUsedLog10: Math.trunc(100 * Math.log10(avg(v.map(x => x.result.heapUsed)))) / 100
8989
};

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lite-fifo",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"license": "MIT",
55
"main": "src/index.js",
66
"types": "types/index.d.ts",
@@ -13,10 +13,10 @@
1313
"homepage": "https://github.com/kleinron/lite-fifo.git#readme",
1414
"description": "Lightweight, optimized, and efficient implementations for FIFO (queue) data structure",
1515
"devDependencies": {
16-
"mocha": "10.1.0",
16+
"mocha": "^11.7.1",
1717
"seedrandom": "^3.0.5",
18-
"semistandard": "^16.0.1",
19-
"typescript": "^4.6.4"
18+
"semistandard": "^17.0.0",
19+
"typescript": "^5.9.2"
2020
},
2121
"scripts": {
2222
"lint": "semistandard",

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const { DynamicCyclicQueue } = require('./DynamicCyclicQueue');
55
const { LinkedQueue } = require('./LinkedQueue');
66

77
module.exports = {
8-
ChunkedQueue: ChunkedQueue,
9-
DynamicArrayQueue: DynamicArrayQueue,
10-
DynamicCyclicQueue: DynamicCyclicQueue,
11-
LinkedQueue: LinkedQueue,
12-
CyclicQueue: CyclicQueue
8+
ChunkedQueue,
9+
DynamicArrayQueue,
10+
DynamicCyclicQueue,
11+
LinkedQueue,
12+
CyclicQueue
1313
};

src/interfaces.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @fileoverview Interface definitions for queue implementations
3+
*/
4+
5+
/**
6+
* Common interface for all queue implementations
7+
* @typedef {Object} QueueInterface
8+
* @template T The type of items stored in the queue
9+
* @property {function(T): void} enqueue - Add an item to the queue
10+
* @property {function(): T} dequeue - Remove and return the oldest item from the queue
11+
* @property {function(): number} size - Return the current size of the queue
12+
* @property {function(): void} clear - Clear all items from the queue
13+
* @property {function(): T} peek - Return the oldest item without removing it
14+
* @property {function(): boolean} isEmpty - Check if the queue is empty
15+
* @property {function(): T[]} toArray - Convert queue to array
16+
* @property {function(): string} toJSON - Serialize queue to JSON
17+
* @property {function(T[], number=): void} copyTo - Copy queue items to an array
18+
*/
19+
20+
/**
21+
* Interface for bounded queues that have a maximum capacity
22+
* @typedef {QueueInterface<T> & {capacity: function(): number}} BoundedQueueInterface
23+
* @template T The type of items stored in the queue
24+
*/
25+
26+
module.exports = {};

types/ChunkedQueue.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class ChunkedQueue<T> {
88
/**
99
* @param {number} [chunkSize=1024] Size of each internal chunk
1010
*/
11-
constructor(chunkSize?: number | undefined);
11+
constructor(chunkSize?: number);
1212
/** @private */
1313
private _queue;
1414
/** @private */
@@ -87,7 +87,7 @@ export class ChunkedQueue<T> {
8787
* @param {number} [startIndex=0] Starting index in the array
8888
* @returns {void}
8989
*/
90-
copyTo(arr: T[], startIndex?: number | undefined): void;
90+
copyTo(arr: T[], startIndex?: number): void;
9191
/**
9292
* Create an array with the same size as the queue, populate it with the items in the queue, keeping the iteration order, and return it.
9393
* @returns {T[]} Array containing all queue items

types/ChunkedQueue.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/CyclicQueue.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class CyclicQueue<T> {
88
/**
99
* @param {number} [capacity=16] Maximum number of items the queue can hold
1010
*/
11-
constructor(capacity?: number | undefined);
11+
constructor(capacity?: number);
1212
/** @private */
1313
private _capacity;
1414
/**
@@ -105,7 +105,7 @@ export class CyclicQueue<T> {
105105
* @param {number} [startIndex=0] Starting index in the array
106106
* @returns {void}
107107
*/
108-
copyTo(arr: T[], startIndex?: number | undefined): void;
108+
copyTo(arr: T[], startIndex?: number): void;
109109
/**
110110
* Create an array with the same size as the queue, populate it with the items in the queue, keeping the iteration order, and return it.
111111
* @returns {T[]} Array containing all queue items

types/CyclicQueue.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/DynamicArrayQueue.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class DynamicArrayQueue<T> {
8282
* @param {number} [startIndex=0] Starting index in the array
8383
* @returns {void}
8484
*/
85-
copyTo(arr: T[], startIndex?: number | undefined): void;
85+
copyTo(arr: T[], startIndex?: number): void;
8686
/**
8787
* Create an array with the same size as the queue, populate it with the items in the queue, keeping the iteration order, and return it.
8888
* @returns {T[]} Array containing all queue items

0 commit comments

Comments
 (0)