Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

refactor!: last tweaks before next major version bump #114

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-files-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cachu": major
---

refactor!: last tweaks before next major version bump
26 changes: 4 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
Expand All @@ -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)

<hr>
<h3>Chat with us</h3>
<a href='https://azury.dev/discord'><b>Join our Discord :D</b></a>
<div align='center'>
<h3>Chat with us</h3>
<a href='https://azury.dev/discord'><b>Join our Discord</b></a>
</div>
<hr>
File renamed without changes.
16 changes: 4 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -22,9 +16,7 @@
"keywords": [
"kv",
"cache",
"production-ready",
"asynchronous",
"modules",
"simple"
],
"author": "Samuel Kopp <opensource@azury.dev> (https://azury.dev)",
Expand Down
10 changes: 3 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
"compilerOptions": {
"target": "esnext",
"module": "es2020",
"lib": [
"esnext"
],
"rootDir": "src",
"outDir": "types",
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand All @@ -20,7 +15,8 @@
"skipLibCheck": true,
"newLine": "crlf"
},
"exclude": [
"test"
"include": [
"src/**/*.ts",
"src/**/*.test.ts"
]
}
21 changes: 21 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export type InitializeCache = (config?: {
maxAge?: number | string
maxAmount?: number
autodelete?: boolean
}) => {
add: (key: any, value: any, maxAge?: number | string) => Promise<void>
addMany: (...entries: ([any, any, number | string] | [any, any])[]) => Promise<void>
get: (key: any) => Promise<any>
getMany: (...keys: any[]) => Promise<any[]>
update: (key: any, value: any) => Promise<void>
updateMany: (...entries: [any, any][]) => Promise<void>
remove: (key: any) => Promise<void>
removeMany: (...keys: any[]) => Promise<void>
has: (key: any) => Promise<boolean>
size: () => Promise<number>
keys: () => Promise<any[]>
values: () => Promise<any[]>
clear: () => Promise<void>
}

export const useCache: InitializeCache