
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
expiring-types
Advanced tools
A lightweight TypeScript library providing data structures with automatic expiration functionality.
npm install expiring-types
ExpiringMap - A Map-like data structure where entries expire after a specified timeExpiringSet - A Set-like data structure where elements expire after a specified timeimport { ExpiringMap } from 'expiring-types';
// Create a map with entries that expire after 5000ms (5 seconds)
const cache = new ExpiringMap<string, any>(5000);
// Add items to the map
cache.set('user1', { name: 'John', age: 30 });
cache.set('user2', { name: 'Jane', age: 25 });
// Get an item
const user = cache.get('user1'); // Returns the user object
// Check if an item exists
if (cache.has('user1')) {
console.log('User exists in cache');
}
// After 5 seconds, the entries will be automatically removed
setTimeout(() => {
console.log(cache.has('user1')); // false
console.log(cache.size); // 0
}, 6000);
// Manually delete an entry
cache.delete('user1');
// Clear all entries
cache.clear();
import { ExpiringSet } from 'expiring-types';
// Create a set with elements that expire after 10000ms (10 seconds)
const recentUsers = new ExpiringSet<string>(10000);
// Add items to the set
recentUsers.add('user123');
recentUsers.add('user456');
// Check if an element exists
if (recentUsers.has('user123')) {
console.log('User recently active');
}
// After 10 seconds, the elements will be automatically removed
setTimeout(() => {
console.log(recentUsers.has('user123')); // false
console.log(recentUsers.size); // 0
}, 11000);
// Iterate over the set
for (const user of recentUsers) {
console.log(user);
}
// Manually delete an element
recentUsers.delete('user123');
// Clear all elements
recentUsers.clear();
A Map-like collection where each entry expires after a specified time.
constructor(ttl: number) - Creates a new ExpiringMap with the specified time-to-live in millisecondsset(key: K, value: V): this - Adds or updates an entryget(key: K): V | undefined - Retrieves an entry's valuehas(key: K): boolean - Checks if an entry existsdelete(key: K): boolean - Removes an entryclear(): void - Removes all entrieskeys(): IterableIterator<K> - Returns an iterator of all keysvalues(): IterableIterator<V> - Returns an iterator of all valuesentries(): IterableIterator<[K, V]> - Returns an iterator of all [key, value] pairssize: number - The number of entries in the mapA Set-like collection where each element expires after a specified time.
constructor(ttl: number) - Creates a new ExpiringSet with the specified time-to-live in millisecondsadd(value: T): this - Adds an elementhas(value: T): boolean - Checks if an element existsdelete(value: T): boolean - Removes an elementclear(): void - Removes all elementsvalues(): IterableIterator<T> - Returns an iterator of all valueskeys(): IterableIterator<T> - Returns an iterator of all valuesentries(): IterableIterator<[T, T]> - Returns an iterator of all [value, value] pairssize: number - The number of elements in the setMIT
FAQs
Expiring map and expiring sets
We found that expiring-types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.