Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.4 KiB

  1. # map-age-cleaner
  2. [![Build Status](https://travis-ci.org/SamVerschueren/map-age-cleaner.svg?branch=master)](https://travis-ci.org/SamVerschueren/map-age-cleaner) [![codecov](https://codecov.io/gh/SamVerschueren/map-age-cleaner/badge.svg?branch=master)](https://codecov.io/gh/SamVerschueren/map-age-cleaner?branch=master)
  3. > Automatically cleanup expired items in a Map
  4. ## Install
  5. ```
  6. $ npm install map-age-cleaner
  7. ```
  8. ## Usage
  9. ```js
  10. import mapAgeCleaner from 'map-age-cleaner';
  11. const map = new Map([
  12. ['unicorn', {data: '🦄', maxAge: Date.now() + 1000}]
  13. ]);
  14. mapAgeCleaner(map);
  15. map.has('unicorn');
  16. //=> true
  17. // Wait for 1 second...
  18. map.has('unicorn');
  19. //=> false
  20. ```
  21. > **Note**: Items have to be ordered ascending based on the expiry property. This means that the item which will be expired first, should be in the first position of the `Map`.
  22. ## API
  23. ### mapAgeCleaner(map, [property])
  24. Returns the `Map` instance.
  25. #### map
  26. Type: `Map`
  27. Map instance which should be cleaned up.
  28. #### property
  29. Type: `string`<br>
  30. Default: `maxAge`
  31. Name of the property which olds the expiry timestamp.
  32. ## Related
  33. - [expiry-map](https://github.com/SamVerschueren/expiry-map) - A `Map` implementation with expirable items
  34. - [expiry-set](https://github.com/SamVerschueren/expiry-set) - A `Set` implementation with expirable keys
  35. - [mem](https://github.com/sindresorhus/mem) - Memoize functions
  36. ## License
  37. MIT © [Sam Verschueren](https://github.com/SamVerschueren)