From 949dbf8a9961eaf49107055379b6869214007e17 Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Tue, 20 Sep 2022 22:15:49 -0400 Subject: [PATCH] Generating new `.d.ts` types file from `npm run types` script, updating `package.json` file paths --- dist/tiny-lru.esm.d.ts | 25 +++++++++++++++++++++++++ package-lock.json | 22 +++++++++++++++++++++- package.json | 15 ++++++++------- tiny-lru.d.ts | 20 -------------------- 4 files changed, 54 insertions(+), 28 deletions(-) create mode 100644 dist/tiny-lru.esm.d.ts delete mode 100644 tiny-lru.d.ts diff --git a/dist/tiny-lru.esm.d.ts b/dist/tiny-lru.esm.d.ts new file mode 100644 index 0000000..17e5c75 --- /dev/null +++ b/dist/tiny-lru.esm.d.ts @@ -0,0 +1,25 @@ +export function lru(max?: number, ttl?: number): LRU; +/** + * tiny-lru + * + * @copyright 2022 Jason Mulligan + * @license BSD-3-Clause + * @version 9.0.0 + */ +declare class LRU { + constructor(max?: number, ttl?: number); + first: any; + items: any; + last: any; + max: number; + size: number; + ttl: number; + has(key: any): boolean; + clear(): LRU; + delete(key: any): LRU; + evict(bypass?: boolean): LRU; + get(key: any): any; + keys(): string[]; + set(key: any, value: any, bypass?: boolean): LRU; +} +export {}; diff --git a/package-lock.json b/package-lock.json index 85cd106..25c110a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,8 @@ "mocha": "^10.0.0", "precise": "^2.0.0", "rollup": "^2.79.0", - "rollup-plugin-terser": "^7.0.2" + "rollup-plugin-terser": "^7.0.2", + "typescript": "^4.8.3" }, "engines": { "node": ">=6" @@ -2076,6 +2077,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", + "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/uglify-js": { "version": "3.17.1", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.1.tgz", @@ -3739,6 +3753,12 @@ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true }, + "typescript": { + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", + "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", + "dev": true + }, "uglify-js": { "version": "3.17.1", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.1.tgz", diff --git a/package.json b/package.json index 66a07cf..266ff2a 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,12 @@ ], "license": "BSD-3-Clause", "source": "src/lru.js", - "browser": "lib/tiny-lru.js", - "main": "lib/tiny-lru.cjs", - "module": "lib/tiny-lru.esm.js", + "browser": "dist/tiny-lru.js", + "main": "dist/tiny-lru.cjs", + "module": "dist/tiny-lru.esm.js", "type": "module", "sourceType": "module", - "types": "tiny-lru.d.ts", + "types": "dist/tiny-lru.esm.d.ts", "engines": { "node": ">=6" }, @@ -34,16 +34,17 @@ "lint": "eslint *.js src/*.js test/*.js", "mocha": "mocha test/*.js", "rollup": "rollup --config", - "test": "npm run lint && npm run mocha" + "test": "npm run lint && npm run mocha", + "types": "npx -p typescript tsc dist/tiny-lru.esm.js --declaration --allowJs --emitDeclarationOnly" }, - "dependencies": {}, "devDependencies": { "auto-changelog": "^2.4.0", "eslint": "^8.23.1", "mocha": "^10.0.0", "precise": "^2.0.0", "rollup": "^2.79.0", - "rollup-plugin-terser": "^7.0.2" + "rollup-plugin-terser": "^7.0.2", + "typescript": "^4.8.3" }, "keywords": [ "LRU", diff --git a/tiny-lru.d.ts b/tiny-lru.d.ts deleted file mode 100644 index 0bd5a39..0000000 --- a/tiny-lru.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -declare module "tiny-lru" { - class Lru { - constructor(max?: number, ttl?: number); - - public max: number; - public ttl: number; - public size: number; - public first: T | null; - public last: T | null; - - public has(key: string): boolean; - public get(key: string): T | undefined; - public set(key: string, value: T, bypass?: boolean): this; - public clear(): this; - public delete(key: string): this; - public evict(): this; - public keys(): string[]; - } - export default function factory(max?: number, ttl?: number): Lru; -}