https://github.com/0k/cache
Kids cache typescript implementation
https://github.com/0k/cache
Last synced: 10 months ago
JSON representation
Kids cache typescript implementation
- Host: GitHub
- URL: https://github.com/0k/cache
- Owner: 0k
- License: bsd-2-clause
- Created: 2025-08-03T12:42:47.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-08-03T12:44:18.000Z (11 months ago)
- Last Synced: 2025-08-03T12:51:35.444Z (11 months ago)
- Language: TypeScript
- Size: 0 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
# -*- ispell-local-dictionary: "english" -*-
#+TITLE: Typescript cache decorator
This packages holds a cache decorator implementation. It draws its
inspiration on [[https://pypi.python.org/pypi/kids.cache/][kids.cache]] a python simple yet powerful cache
decorator.
This implementation leverage decorator in typescript to reach same goals:
- no dependencies
- cache clearing support
Its still in infancy and lacks:
- support for normal function (only methods are cachable)
- cache stats
- 100% coverage
- doc
However, straying from [[https://pypi.python.org/pypi/kids.cache/][kids.cache]]:
- it leverages =Proxy= javascript niceties to provide a default
caching mechanism that records exactly what the function to be
cached used in the input arguments. This allows to have precise and
minimal footprints when looking for cache hits.
- as a consequence this part of the code is a little more ambitious
(bigger) than its counterpart.
* Adding =@0k/cache= to your project
From the root of your project:
#+begin_src sh
npm install --save @0k/cache
#+end_src
Or better, as =@0k/cache= is still in early release,
#+begin_src sh
npm install --save @0k/cache#master
#+end_src
To be sure to get the latest version, relaunch this last command
whenever you want to update.
* Contributing to =@0k/cache=
This package is using ~npm~ to track dependendies, so you can install them
with:
#+begin_src sh
npm install
#+end_src
As this package is written in =typescript=. You can transpile to
=javascript= and transpile on file change with:
#+begin_src sh
## Compile and watch
npx tspc -w
#+end_src
Tests are managed through =vitest=
#+begin_src sh
## Run test once
npm run test
#+end_src
Note that you can also use ~npx vitest~ command to launch tests in
watch mode.