Skip to content

Commit 72d7d45

Browse files
authored
Merge pull request #3 from adamjosefus/development
Add documentation
2 parents ed81ed4 + cc3fabc commit 72d7d45

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# Caching
1+
# **Allo Caching** for Deno 🦕
22

3-
## `Cache`
3+
Simple caching solution in Typescript.
4+
5+
6+
## `Cache<ValueType>`
47

58
```ts
69
const cache = new Cache<string>();
@@ -38,4 +41,14 @@ cache.save(cacheKey, 'Lorem ipsum');
3841
*/
3942
cache.has(cacheKey); // -> boolean
4043

41-
```
44+
```
45+
46+
47+
48+
## Documentation 📖
49+
50+
Description of all classes and methods with **examples** will found in the [documentation](https://doc.deno.land/https://deno.land/x/[email protected]/mod.ts).
51+
52+
---
53+
54+
Check out other [ours packages 📦](https://deno.land/x?query=allo_)!

Cache/Cache.ts renamed to libs/Cache.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
* @copyright Copyright (c) 2022 Adam Josefus
33
*/
44

5-
type GeneratorType<T> = () => T;
65

7-
type LoadOnlyEntryType<T> = [key: string];
6+
export type GeneratorType<T> = () => T;
7+
type LoadOnlyEntryType = [key: string];
88
type LoadAndGenerateEntryType<T> = [key: string, generator: GeneratorType<T>];
9-
type LoadEntryType<T> = LoadOnlyEntryType<T> | LoadAndGenerateEntryType<T>;
9+
type LoadEntryType<T> = LoadOnlyEntryType | LoadAndGenerateEntryType<T>;
1010

1111

1212
export class Cache<T> {
1313

1414
readonly #storage: Map<string, T> = new Map();
1515

16+
1617
load<E extends LoadEntryType<T>>(...args: E): E extends LoadAndGenerateEntryType<T> ? T : T | undefined {
1718
const [key, generator] = args;
1819

mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { Cache } from './Cache/Cache.ts';
1+
export * from './libs/Cache.ts';

0 commit comments

Comments
 (0)