eht
expirable-hash-table
npm i expirable-hash-table
eht

expirable-hash-table

Expirable HashTable to enable timeout-based item removal from HashTable.

by Kenneth Auchenberg

1.0.1 (see all)License:MITTypeScript:Not FoundCategories:Vanilla JavaScript Hash Table
npm i expirable-hash-table
Readme

expirable-hash-table

Expirable HashTable to enable timeout-based item removal from HashTable.

js-standard-style Build status

Install

npm install expirable-hash-table

Use

var ExpirableHashTable = require('expirable-hash-table')

var myTable = new ExpirableHashTable(1000) // default timeout in miliseconds

myTable.set('key', 'value', 3000) // optional timeout in miliseconds

myTable.get('key') // -> value
myTable.remove('key') // -> ExpirableHashTable
myTable.has('key') // -> true/false
myTable.purge() // -> ExpirableHashTable
myTable.toArray() // -> Array
myTable.size() // -> Integer

myTable.on('change', function() {
  // A change event is emitted ever time an item is added, updated or removed
})

myTable.once('<key>:expired', function() {
   // A expired event is emitted when a given item expires. Useful if a specific item wants to be monitored. 
})

License

MIT

Downloads/wk

7

GitHub Stars

4

LAST COMMIT

6yrs ago

MAINTAINERS

1

CONTRIBUTORS

1

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
1.0.1
latest
6yrs ago
No tutorials found
Add a tutorial