From 873c9012d2c4f370325291ceff94e38e87341e50 Mon Sep 17 00:00:00 2001 From: Samuel Kopp <62482066+unvented@users.noreply.github.com> Date: Fri, 29 Jul 2022 21:13:30 +0200 Subject: [PATCH] refactor!: last tweaks before next major version bump (#114) --- .changeset/warm-files-sneeze.md | 5 +++++ README.md | 26 ++++---------------------- jest.config.js => jest.config.ts | 0 package.json | 16 ++++------------ tsconfig.json | 10 +++------- types/index.d.ts | 21 +++++++++++++++++++++ 6 files changed, 37 insertions(+), 41 deletions(-) create mode 100644 .changeset/warm-files-sneeze.md rename jest.config.js => jest.config.ts (100%) create mode 100644 types/index.d.ts diff --git a/.changeset/warm-files-sneeze.md b/.changeset/warm-files-sneeze.md new file mode 100644 index 0000000..316cc9b --- /dev/null +++ b/.changeset/warm-files-sneeze.md @@ -0,0 +1,5 @@ +--- +"cachu": major +--- + +refactor!: last tweaks before next major version bump diff --git a/README.md b/README.md index 00a53c5..2be3cc8 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,12 @@ ```bash # Get the latest release. npm i cachu - -# Try the latest commit. -npm i cachu@dev ``` ## Usage > **Note** - Need an introduction to v6? [Here](https://gist.github.com/unvented/dab8d3e987cfdd79f68e715d29c1ee17) you go! -### Node.js - ```js import { useCache } from 'cachu' @@ -27,21 +22,6 @@ await cache.add('one', 'Hello World') const entry = await cache.get('one') // 'Hello World' ``` -### Deno - -```js -import { useCache } from 'https://deno.land/x/cachu@v6.0.0/mod.ts' -``` - -### Browser - -```js -import { useCache } from 'cachu/browser' - -// Alternatively, you might want to use a CDN. -import { useCache } from 'https://cdn.jsdelivr.net/npm/cachu@6' -``` - ## API * #### Configuration @@ -67,6 +47,8 @@ import { useCache } from 'https://cdn.jsdelivr.net/npm/cachu@6' * [`clear()`](https://github.com/azurydev/cachu/blob/dev/guide/guide/features/clear.md)
-

Chat with us

-Join our Discord :D +
+

Chat with us

+ Join our Discord +

diff --git a/jest.config.js b/jest.config.ts similarity index 100% rename from jest.config.js rename to jest.config.ts diff --git a/package.json b/package.json index bce3bf4..3e738eb 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,13 @@ { "name": "cachu", "version": "5.4.4", - "description": "A simple key-value cache for Node.js, Deno, and browsers.", + "description": "A simple key-value cache for Node.js.", "main": "./dist/index.js", - "browser": "./dist/browser.js", "types": "types/index.d.ts", - "exports": { - ".": "./dist/index.js", - "./browser": "./dist/browser.js" - }, + "exports": "./dist/index.js", "scripts": { - "build:node": "esbuild src/node.ts --bundle --minify --format=esm --legal-comments=none --outfile=dist/index.js", - "build:browser": "esbuild src/deno.ts --bundle --minify --format=esm --legal-comments=none --outfile=dist/browser.js", - "build": "rimraf dist && npm run build:node && npm run build:browser", - "test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js" + "build": "rimraf dist && esbuild src/node.ts --bundle --minify --format=esm --legal-comments=none --outfile=dist/index.js", + "test": "jest" }, "repository": { "type": "git", @@ -22,9 +16,7 @@ "keywords": [ "kv", "cache", - "production-ready", "asynchronous", - "modules", "simple" ], "author": "Samuel Kopp (https://azury.dev)", diff --git a/tsconfig.json b/tsconfig.json index cb8bad6..459bfdc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,11 +2,6 @@ "compilerOptions": { "target": "esnext", "module": "es2020", - "lib": [ - "esnext" - ], - "rootDir": "src", - "outDir": "types", "moduleResolution": "node", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, @@ -20,7 +15,8 @@ "skipLibCheck": true, "newLine": "crlf" }, - "exclude": [ - "test" + "include": [ + "src/**/*.ts", + "src/**/*.test.ts" ] } diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..a9941e0 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,21 @@ +export type InitializeCache = (config?: { + maxAge?: number | string + maxAmount?: number + autodelete?: boolean +}) => { + add: (key: any, value: any, maxAge?: number | string) => Promise + addMany: (...entries: ([any, any, number | string] | [any, any])[]) => Promise + get: (key: any) => Promise + getMany: (...keys: any[]) => Promise + update: (key: any, value: any) => Promise + updateMany: (...entries: [any, any][]) => Promise + remove: (key: any) => Promise + removeMany: (...keys: any[]) => Promise + has: (key: any) => Promise + size: () => Promise + keys: () => Promise + values: () => Promise + clear: () => Promise +} + +export const useCache: InitializeCache