@simba.fs/pool

Data management, auto remove item after specified time. Just add it to a pool.

Usage no npm install needed!

<script type="module">
  import simbaFsPool from 'https://cdn.skypack.dev/@simba.fs/pool';
</script>

README

pool

Data management, auto remove item after specified time. Just add it to a pool.

Intall

npm i @simba.fs/pool

Usage

const Pool = require('@simba.fs/pool');
const user = new Pool(String);

user.add('Simba');
user.add('Peter');

console.log([...user]);
// [ 'Simba', 'Kenny' ]

user.clear();

console.log([...user]);
// []

API

The Pool inherit from Set
All the methods in Pool except add are the same with those in Set
The new #add check if the type of the item is the same with #type
You can access the old add method by #_add

Notice

const user = new Pool(String);
user.add(new String('Simba'));
// This won't work, the reason is as follows
console.log(typeof (new String('Simba')), user.type);
// object [Function: String]
// Ok, they are not ths same