Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

lib0

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lib0 - npm Package Compare versions

Comparing version 0.2.44 to 0.2.45

3

cache.d.ts

@@ -23,3 +23,4 @@ /**

export function getAsync<K, V>(cache: Cache<K, V>, key: K): V | Promise<V> | undefined;
export function setIfUndefined<K, V>(cache: Cache<K, V>, key: K, init: () => Promise<V>): V | Promise<V>;
export function remove<K, V>(cache: Cache<K, V>, key: K): V | undefined;
export function setIfUndefined<K, V>(cache: Cache<K, V>, key: K, init: () => Promise<V>, removeNull?: boolean): V | Promise<V>;
export function create(timeout: number): Cache<any, any>;

@@ -26,0 +27,0 @@ import * as list from "./list.js";

@@ -7,3 +7,3 @@

*
* @module cached-map
* @module cache
*/

@@ -150,6 +150,22 @@

* @param {K} key
*/
export const remove = (cache, key) => {
const n = cache._map.get(key)
if (n) {
list.removeNode(cache._q, n)
cache._map.delete(key)
return n.val && !(n.val instanceof Promise) ? n.val : undefined
}
}
/**
* @template K, V
*
* @param {Cache<K, V>} cache
* @param {K} key
* @param {function():Promise<V>} init
* @param {boolean} removeNull Optional argument that automatically removes values that resolve to null/undefined from the cache.
* @return {Promise<V> | V}
*/
export const setIfUndefined = (cache, key, init) => {
export const setIfUndefined = (cache, key, init, removeNull = false) => {
const now = removeStale(cache)

@@ -172,2 +188,5 @@ const q = cache._q

}
if (removeNull && v == null) {
remove(cache, key)
}
})

@@ -174,0 +193,0 @@ return p

@@ -23,3 +23,4 @@ /**

export function getAsync<K, V>(cache: Cache<K, V>, key: K): V | Promise<V> | undefined;
export function setIfUndefined<K, V>(cache: Cache<K, V>, key: K, init: () => Promise<V>): V | Promise<V>;
export function remove<K, V>(cache: Cache<K, V>, key: K): V | undefined;
export function setIfUndefined<K, V>(cache: Cache<K, V>, key: K, init: () => Promise<V>, removeNull?: boolean): V | Promise<V>;
export function create(timeout: number): Cache<any, any>;

@@ -26,0 +27,0 @@ import * as list from "./list.js";

{
"name": "lib0",
"version": "0.2.44",
"version": "0.2.45",
"description": "",

@@ -5,0 +5,0 @@ "sideEffects": false,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc