-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
12,350 additions
and
8,020 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
parser: 'vue-eslint-parser', | ||
parserOptions: { | ||
parser: '@typescript-eslint/parser', | ||
}, | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
extends: [ | ||
'../../.eslintrc.cjs', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:import/typescript', | ||
], | ||
rules: { | ||
// allow imports without file extensions | ||
'import/extensions': 'off', | ||
// allow `any` type | ||
'@typescript-eslint/no-explicit-any': ['off'], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "kv-analytics", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.cjs", | ||
"import": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsup src/*.ts --format cjs,esm --dts --clean", | ||
"lint": "eslint --ext .ts,.vue ./src", | ||
"test": "jest" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/kiva/kv-ui-elements.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/kiva/kv-ui-elements/issues" | ||
}, | ||
"homepage": "https://github.com/kiva/kv-ui-elements#readme", | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^6.13.1", | ||
"@typescript-eslint/parser": "^6.13.1", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"ts-jest": "^29.1.1", | ||
"tsup": "^6.7.0", | ||
"typescript": "^5.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Utility class to help with creating and managing a basic queue | ||
* - This implementation uses array properites and is meant for small queues of items | ||
*/ | ||
export default class SimpleQueue<T> { | ||
items: T[]; | ||
|
||
itemLimit: number; | ||
|
||
/** | ||
* Initialize a queue to hold items in an array | ||
*/ | ||
constructor(options?: { itemLimit?: number }) { | ||
this.items = []; | ||
this.itemLimit = options?.itemLimit ?? 200; | ||
} | ||
|
||
/** | ||
* Add an item to the queue | ||
*/ | ||
add(item: T) { | ||
// limit items added to queue | ||
if (this.items.length === this.itemLimit) { | ||
return false; | ||
} | ||
this.items.push(item); | ||
} | ||
|
||
/** | ||
* Remove an item from the queue | ||
*/ | ||
remove() { | ||
return this.items.shift(); | ||
} | ||
|
||
/** | ||
* Check for items in the queue | ||
*/ | ||
isEmpty() { | ||
return this.items.length === 0; | ||
} | ||
|
||
/** | ||
* Get the item at the front of the queue | ||
*/ | ||
peek() { | ||
return !this.isEmpty() ? this.items[0] : undefined; | ||
} | ||
|
||
/** | ||
* Remove all items from the queue | ||
*/ | ||
reset() { | ||
this.items.length = 0; | ||
} | ||
|
||
/** | ||
* Get the length of the queue | ||
*/ | ||
get length() { | ||
return this.items.length; | ||
} | ||
} |
Oops, something went wrong.