Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

readme.md 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # quick-lru [![Build Status](https://travis-ci.org/sindresorhus/quick-lru.svg?branch=master)](https://travis-ci.org/sindresorhus/quick-lru) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/quick-lru/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/quick-lru?branch=master)
  2. > Simple ["Least Recently Used" (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29)
  3. Useful when you need to cache something and limit memory usage.
  4. Inspired by the [`hashlru` algorithm](https://github.com/dominictarr/hashlru#algorithm), but instead uses [`Map`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map) to support keys of any type, not just strings, and values can be `undefined`.
  5. ## Install
  6. ```
  7. $ npm install quick-lru
  8. ```
  9. ## Usage
  10. ```js
  11. const QuickLRU = require('quick-lru');
  12. const lru = new QuickLRU({maxSize: 1000});
  13. lru.set('🦄', '🌈');
  14. lru.has('🦄');
  15. //=> true
  16. lru.get('🦄');
  17. //=> '🌈'
  18. ```
  19. ## API
  20. ### new QuickLRU(options?)
  21. Returns a new instance.
  22. ### options
  23. Type: `object`
  24. #### maxSize
  25. *Required*<br>
  26. Type: `number`
  27. The maximum number of items before evicting the least recently used items.
  28. ### Instance
  29. The instance is [`iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.
  30. Both `key` and `value` can be of any type.
  31. #### .set(key, value)
  32. Set an item. Returns the instance.
  33. #### .get(key)
  34. Get an item.
  35. #### .has(key)
  36. Check if an item exists.
  37. #### .peek(key)
  38. Get an item without marking it as recently used.
  39. #### .delete(key)
  40. Delete an item.
  41. Returns `true` if the item is removed or `false` if the item doesn't exist.
  42. #### .clear()
  43. Delete all items.
  44. #### .keys()
  45. Iterable for all the keys.
  46. #### .values()
  47. Iterable for all the values.
  48. #### .size
  49. The stored item count.