Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

wopjs/weak-cache

Repository files navigation

@wopjs/weak-cache

Docs Build Status npm-version Coverage Status minified-size

WeakCache is like WeakMap but extends support to primitive keys, and with both object keys and object values being weakly referenced.

Install

npm add @wopjs/weak-cache

Usage

import { WeakCache } from "@wopjs/weak-cache";
const cache = new WeakCache();
cache.set("key", { value: "value" });
const objectKey = { key: "key" };
cache.set(key, { value: "value" });
console.log(cache.size); // 2
console.log(cache.get("key")); // { value: "value" }
console.log(cache.get(objectKey)); // { value: "value" }
// ...
// gc()
console.log(cache.size); // 0

Publish New Version

You can use npm version to bump version.

npm version patch

Push the tag to remote and CI will publish the new version to npm.

git push --follow-tags

CI Publish

If you want to publish the package in CI, you need to set the NPM_TOKEN secrets in GitHub repository settings. See how to create a NPM access token.

About

WeakCache is like WeakMap but extends support to primitive keys, and with both object keys and object values being weakly referenced.

Resources

License

Stars

Watchers

Forks

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /