mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-17 15:53:38 -05:00
chore(package): re-init package with commitizen and standard-release
This commit is contained in:
114
node_modules/quick-lru/index.js
generated
vendored
Normal file
114
node_modules/quick-lru/index.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
'use strict';
|
||||
|
||||
class QuickLRU {
|
||||
constructor(opts) {
|
||||
opts = Object.assign({}, opts);
|
||||
|
||||
if (!(opts.maxSize && opts.maxSize > 0)) {
|
||||
throw new TypeError('`maxSize` must be a number greater than 0');
|
||||
}
|
||||
|
||||
this.maxSize = opts.maxSize;
|
||||
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;
|
||||
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._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) {
|
||||
if (this.cache.delete(key)) {
|
||||
this._size--;
|
||||
}
|
||||
|
||||
this.oldCache.delete(key);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.cache.clear();
|
||||
this.oldCache.clear();
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
* keys() {
|
||||
for (const el of this) {
|
||||
yield el[0];
|
||||
}
|
||||
}
|
||||
|
||||
* values() {
|
||||
for (const el of this) {
|
||||
yield el[1];
|
||||
}
|
||||
}
|
||||
|
||||
* [Symbol.iterator]() {
|
||||
for (const el of this.cache) {
|
||||
yield el;
|
||||
}
|
||||
|
||||
for (const el of this.oldCache) {
|
||||
if (!this.cache.has(el[0])) {
|
||||
yield el;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
let oldCacheSize = 0;
|
||||
for (const el of this.oldCache) {
|
||||
if (!this.cache.has(el[0])) {
|
||||
oldCacheSize++;
|
||||
}
|
||||
}
|
||||
|
||||
return this._size + oldCacheSize;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = QuickLRU;
|
||||
9
node_modules/quick-lru/license
generated
vendored
Normal file
9
node_modules/quick-lru/license
generated
vendored
Normal file
@@ -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.
|
||||
40
node_modules/quick-lru/package.json
generated
vendored
Normal file
40
node_modules/quick-lru/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "quick-lru",
|
||||
"version": "1.1.0",
|
||||
"description": "Simple \"Least Recently Used\" (LRU) cache",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/quick-lru",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"lru",
|
||||
"quick",
|
||||
"cache",
|
||||
"caching",
|
||||
"least",
|
||||
"recently",
|
||||
"used",
|
||||
"fast",
|
||||
"map",
|
||||
"hash",
|
||||
"buffer"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"coveralls": "^2.12.0",
|
||||
"nyc": "^11.0.3",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
96
node_modules/quick-lru/readme.md
generated
vendored
Normal file
96
node_modules/quick-lru/readme.md
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
# quick-lru [](https://travis-ci.org/sindresorhus/quick-lru) [](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 [`haslru` 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*<br>
|
||||
Type: `Object`
|
||||
|
||||
Maximum number of items before evicting the least recently used items.
|
||||
|
||||
### 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.
|
||||
|
||||
#### .clear()
|
||||
|
||||
Delete all items.
|
||||
|
||||
#### .keys()
|
||||
|
||||
Iterable for all the keys.
|
||||
|
||||
#### .values()
|
||||
|
||||
Iterable for all the values.
|
||||
|
||||
#### .size
|
||||
|
||||
Get the item count.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
Reference in New Issue
Block a user