mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 21:10:23 +00:00
[quick-lru] introduce typings (#18730)
This commit is contained in:
committed by
Mohamed Hegazy
parent
a0d20a1314
commit
86e4c7565c
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for quick-lru 1.1
|
||||
// Project: https://github.com/sindresorhus/quick-lru#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = QuickLRU;
|
||||
|
||||
declare class QuickLRU<K, V> implements Iterable<[K, V]> {
|
||||
readonly size: number;
|
||||
constructor(options?: QuickLRU.Options);
|
||||
[Symbol.iterator](): Iterator<[K, V]>;
|
||||
set(key: K, value: V): this;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
peek(key: K): V | undefined;
|
||||
delete(key: K): void;
|
||||
clear(): void;
|
||||
keys(): Iterable<K>;
|
||||
values(): Iterable<V>;
|
||||
}
|
||||
|
||||
declare namespace QuickLRU {
|
||||
interface Options {
|
||||
maxSize: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import QuickLRU = require('quick-lru');
|
||||
|
||||
let num: number;
|
||||
let numu: number | undefined;
|
||||
let str: string;
|
||||
let bool: boolean;
|
||||
|
||||
const lru = new QuickLRU<string, number>({maxSize: 1000});
|
||||
|
||||
lru.set('🦄', 1).set('🌈', 2);
|
||||
numu = lru.get('🦄');
|
||||
bool = lru.has('🦄');
|
||||
numu = lru.peek('🦄');
|
||||
lru.delete('🦄');
|
||||
lru.clear();
|
||||
num = lru.size;
|
||||
|
||||
for (const [key, value] of lru) {
|
||||
str = key;
|
||||
num = value;
|
||||
}
|
||||
|
||||
for (const key of lru.keys()) {
|
||||
str = key;
|
||||
}
|
||||
|
||||
for (const value of lru.values()) {
|
||||
num = value;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2015",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"quick-lru-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user