summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/quick-lru
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
committerRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
commit83354b2b88218090988dd6e526b0a2505b57e0f1 (patch)
treee3c73c38a122a78bb7e66fbb99056407edd9d4b9 /includes/external/addressbook/node_modules/quick-lru
parent47b8f2299a483024c4a6a8876af825a010954caa (diff)
downloadpluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.gz
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.bz2
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.zip
Updated 5 files and added 1110 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/quick-lru')
-rw-r--r--includes/external/addressbook/node_modules/quick-lru/index.d.ts97
-rw-r--r--includes/external/addressbook/node_modules/quick-lru/index.js123
-rw-r--r--includes/external/addressbook/node_modules/quick-lru/license9
-rw-r--r--includes/external/addressbook/node_modules/quick-lru/package.json43
-rw-r--r--includes/external/addressbook/node_modules/quick-lru/readme.md111
5 files changed, 383 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/quick-lru/index.d.ts b/includes/external/addressbook/node_modules/quick-lru/index.d.ts
new file mode 100644
index 0000000..fa58889
--- /dev/null
+++ b/includes/external/addressbook/node_modules/quick-lru/index.d.ts
@@ -0,0 +1,97 @@
+declare namespace QuickLRU {
+ interface Options<KeyType, ValueType> {
+ /**
+ The maximum number of items before evicting the least recently used items.
+ */
+ readonly maxSize: number;
+
+ /**
+ Called right before an item is evicted from the cache.
+
+ Useful for side effects or for items like object URLs that need explicit cleanup (`revokeObjectURL`).
+ */
+ onEviction?: (key: KeyType, value: ValueType) => void;
+ }
+}
+
+declare class QuickLRU<KeyType, ValueType>
+ implements Iterable<[KeyType, ValueType]> {
+ /**
+ The stored item count.
+ */
+ readonly size: number;
+
+ /**
+ Simple ["Least Recently Used" (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.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.
+
+ @example
+ ```
+ import QuickLRU = require('quick-lru');
+
+ const lru = new QuickLRU({maxSize: 1000});
+
+ lru.set('🦄', '🌈');
+
+ lru.has('🦄');
+ //=> true
+
+ lru.get('🦄');
+ //=> '🌈'
+ ```
+ */
+ constructor(options: QuickLRU.Options<KeyType, ValueType>);
+
+ [Symbol.iterator](): IterableIterator<[KeyType, ValueType]>;
+
+ /**
+ Set an item.
+
+ @returns The list instance.
+ */
+ set(key: KeyType, value: ValueType): this;
+
+ /**
+ Get an item.
+
+ @returns The stored item or `undefined`.
+ */
+ get(key: KeyType): ValueType | undefined;
+
+ /**
+ Check if an item exists.
+ */
+ has(key: KeyType): boolean;
+
+ /**
+ Get an item without marking it as recently used.
+
+ @returns The stored item or `undefined`.
+ */
+ peek(key: KeyType): ValueType | undefined;
+
+ /**
+ Delete an item.
+
+ @returns `true` if the item is removed or `false` if the item doesn't exist.
+ */
+ delete(key: KeyType): boolean;
+
+ /**
+ Delete all items.
+ */
+ clear(): void;
+
+ /**
+ Iterable for all the keys.
+ */
+ keys(): IterableIterator<KeyType>;
+
+ /**
+ Iterable for all the values.
+ */
+ values(): IterableIterator<ValueType>;
+}
+
+export = QuickLRU;
diff --git a/includes/external/addressbook/node_modules/quick-lru/index.js b/includes/external/addressbook/node_modules/quick-lru/index.js
new file mode 100644
index 0000000..7d7032e
--- /dev/null
+++ b/includes/external/addressbook/node_modules/quick-lru/index.js
@@ -0,0 +1,123 @@
+'use strict';
+
+class QuickLRU {
+ constructor(options = {}) {
+ if (!(options.maxSize && options.maxSize > 0)) {
+ throw new TypeError('`maxSize` must be a number greater than 0');
+ }
+
+ this.maxSize = options.maxSize;
+ this.onEviction = options.onEviction;
+ this.cache = new Map();
+ this.oldCache = new Map();
+ this._size = 0;
+ }
+
+ _set(key, value) {
+ this.cache.set(key, value);
+ this._size++;
+
+ if (this._size >= this.maxSize) {
+ this._size = 0;
+
+ if (typeof this.onEviction === 'function') {
+ for (const [key, value] of this.oldCache.entries()) {
+ this.onEviction(key, value);
+ }
+ }
+
+ this.oldCache = this.cache;
+ this.cache = new Map();
+ }
+ }
+
+ get(key) {
+ if (this.cache.has(key)) {
+ return this.cache.get(key);
+ }
+
+ if (this.oldCache.has(key)) {
+ const value = this.oldCache.get(key);
+ this.oldCache.delete(key);
+ this._set(key, value);
+ return value;
+ }
+ }
+
+ set(key, value) {
+ if (this.cache.has(key)) {
+ this.cache.set(key, value);
+ } else {
+ this._set(key, value);
+ }
+
+ return this;
+ }
+
+ has(key) {
+ return this.cache.has(key) || this.oldCache.has(key);
+ }
+
+ peek(key) {
+ if (this.cache.has(key)) {
+ return this.cache.get(key);
+ }
+
+ if (this.oldCache.has(key)) {
+ return this.oldCache.get(key);
+ }
+ }
+
+ delete(key) {
+ const deleted = this.cache.delete(key);
+ if (deleted) {
+ this._size--;
+ }
+
+ return this.oldCache.delete(key) || deleted;
+ }
+
+ clear() {
+ this.cache.clear();
+ this.oldCache.clear();
+ this._size = 0;
+ }
+
+ * keys() {
+ for (const [key] of this) {
+ yield key;
+ }
+ }
+
+ * values() {
+ for (const [, value] of this) {
+ yield value;
+ }
+ }
+
+ * [Symbol.iterator]() {
+ for (const item of this.cache) {
+ yield item;
+ }
+
+ for (const item of this.oldCache) {
+ const [key] = item;
+ if (!this.cache.has(key)) {
+ yield item;
+ }
+ }
+ }
+
+ get size() {
+ let oldCacheSize = 0;
+ for (const key of this.oldCache.keys()) {
+ if (!this.cache.has(key)) {
+ oldCacheSize++;
+ }
+ }
+
+ return Math.min(this._size + oldCacheSize, this.maxSize);
+ }
+}
+
+module.exports = QuickLRU;
diff --git a/includes/external/addressbook/node_modules/quick-lru/license b/includes/external/addressbook/node_modules/quick-lru/license
new file mode 100644
index 0000000..e7af2f7
--- /dev/null
+++ b/includes/external/addressbook/node_modules/quick-lru/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/includes/external/addressbook/node_modules/quick-lru/package.json b/includes/external/addressbook/node_modules/quick-lru/package.json
new file mode 100644
index 0000000..ff0dd9a
--- /dev/null
+++ b/includes/external/addressbook/node_modules/quick-lru/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "quick-lru",
+ "version": "5.1.1",
+ "description": "Simple “Least Recently Used” (LRU) cache",
+ "license": "MIT",
+ "repository": "sindresorhus/quick-lru",
+ "funding": "https://github.com/sponsors/sindresorhus",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "https://sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "scripts": {
+ "test": "xo && nyc ava && tsd"
+ },
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "keywords": [
+ "lru",
+ "quick",
+ "cache",
+ "caching",
+ "least",
+ "recently",
+ "used",
+ "fast",
+ "map",
+ "hash",
+ "buffer"
+ ],
+ "devDependencies": {
+ "ava": "^2.0.0",
+ "coveralls": "^3.0.3",
+ "nyc": "^15.0.0",
+ "tsd": "^0.11.0",
+ "xo": "^0.26.0"
+ }
+}
diff --git a/includes/external/addressbook/node_modules/quick-lru/readme.md b/includes/external/addressbook/node_modules/quick-lru/readme.md
new file mode 100644
index 0000000..234294a
--- /dev/null
+++ b/includes/external/addressbook/node_modules/quick-lru/readme.md
@@ -0,0 +1,111 @@
+# 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)
+
+> Simple [“Least Recently Used” (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29)
+
+Useful when you need to cache something and limit memory usage.
+
+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`.
+
+## Install
+
+```
+$ npm install quick-lru
+```
+
+## Usage
+
+```js
+const QuickLRU = require('quick-lru');
+
+const lru = new QuickLRU({maxSize: 1000});
+
+lru.set('🦄', '🌈');
+
+lru.has('🦄');
+//=> true
+
+lru.get('🦄');
+//=> '🌈'
+```
+
+## API
+
+### new QuickLRU(options?)
+
+Returns a new instance.
+
+### options
+
+Type: `object`
+
+#### maxSize
+
+*Required*\
+Type: `number`
+
+The maximum number of items before evicting the least recently used items.
+
+#### onEviction
+
+*Optional*\
+Type: `(key, value) => void`
+
+Called right before an item is evicted from the cache.
+
+Useful for side effects or for items like object URLs that need explicit cleanup (`revokeObjectURL`).
+
+### Instance
+
+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.
+
+Both `key` and `value` can be of any type.
+
+#### .set(key, value)
+
+Set an item. Returns the instance.
+
+#### .get(key)
+
+Get an item.
+
+#### .has(key)
+
+Check if an item exists.
+
+#### .peek(key)
+
+Get an item without marking it as recently used.
+
+#### .delete(key)
+
+Delete an item.
+
+Returns `true` if the item is removed or `false` if the item doesn't exist.
+
+#### .clear()
+
+Delete all items.
+
+#### .keys()
+
+Iterable for all the keys.
+
+#### .values()
+
+Iterable for all the values.
+
+#### .size
+
+The stored item count.
+
+---
+
+<div align="center">
+ <b>
+ <a href="https://tidelift.com/subscription/pkg/npm-quick-lru?utm_source=npm-quick-lru&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
+ </b>
+ <br>
+ <sub>
+ Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
+ </sub>
+</div>