Update to v13 and add queue and completely change code

This commit is contained in:
a 2021-12-06 16:34:00 +01:00
parent dcef23d0ed
commit 55a38726a3
6706 changed files with 424137 additions and 61608 deletions

11
node_modules/lru-queue/.lint generated vendored Normal file
View file

@ -0,0 +1,11 @@
@root
module
tabs
indent 2
maxlen 100
ass
nomen
plusplus

4
node_modules/lru-queue/.npmignore generated vendored Normal file
View file

@ -0,0 +1,4 @@
.DS_Store
/node_modules
/npm-debug.log
/.lintcache

9
node_modules/lru-queue/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,9 @@
language: node_js
node_js:
- 0.8
- 0.10
- 0.11
notifications:
email:
- medikoo+lru-queue@medikoo.com

3
node_modules/lru-queue/CHANGES generated vendored Normal file
View file

@ -0,0 +1,3 @@
v0.1.0 -- 2013.04.26
Initial (derived from memoizee)

19
node_modules/lru-queue/LICENCE generated vendored Normal file
View file

@ -0,0 +1,19 @@
Copyright (C) 2014 Mariusz Nowak (www.medikoo.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.

65
node_modules/lru-queue/README.md generated vendored Normal file
View file

@ -0,0 +1,65 @@
# lru-queue
## Size limited queue based on [LRU](http://en.wikipedia.org/wiki/Least_Recently_Used#LRU) algorithm
_Originally derived from [memoizee](https://github.com/medikoo/memoize) package._
It's low-level utility meant to be used internally within cache algorithms. It backs up [`max`](https://github.com/medikoo/memoize#limiting-cache-size) functionality in [memoizee](https://github.com/medikoo/memoize) project.
### Installation
$ npm install lru-queue
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)
### Usage
Create queue, and provide a limit
```javascript
var lruQueue = require('lru-queue');
var queue = lruQueue(3); // limit size to 3
```
Each queue exposes three methods:
#### queue.hit(id)
Registers hit for given _id_ (must be plain string).
```javascript
queue.hit('raz'); // size: 1
```
If hit doesn't remove any old item from list it returns `undefined`, otherwise it returns removed _id_.
```javascript
queue.hit('dwa'); // undefined, size: 2
queue.hit('trzy'); // undefined, size: 3 (at max)
queue.hit('raz'); // undefined, size: 3 (at max)
queue.hit('dwa'); // undefined, size: 3 (at max)
queue.hit('cztery'); // 'trzy', size: 3 (at max)
```
#### queue.delete(id);
_id's_ can be cleared from queue externally
```javascript
queue.delete('raz'); // size: 2
queue.delete('cztery'); // size: 1
```
#### queue.clear();
Resets queue
```javascript
queue.clear(); // size: 0
```
### Tests [![Build Status](https://travis-ci.org/medikoo/lru-queue.png)](https://travis-ci.org/medikoo/lru-queue)
$ npm test

48
node_modules/lru-queue/index.js generated vendored Normal file
View file

@ -0,0 +1,48 @@
'use strict';
var toPosInt = require('es5-ext/number/to-pos-integer')
, create = Object.create, hasOwnProperty = Object.prototype.hasOwnProperty;
module.exports = function (limit) {
var size = 0, base = 1, queue = create(null), map = create(null), index = 0, del;
limit = toPosInt(limit);
return {
hit: function (id) {
var oldIndex = map[id], nuIndex = ++index;
queue[nuIndex] = id;
map[id] = nuIndex;
if (!oldIndex) {
++size;
if (size <= limit) return;
id = queue[base];
del(id);
return id;
}
delete queue[oldIndex];
if (base !== oldIndex) return;
while (!hasOwnProperty.call(queue, ++base)) continue; //jslint: skip
},
delete: del = function (id) {
var oldIndex = map[id];
if (!oldIndex) return;
delete queue[oldIndex];
delete map[id];
--size;
if (base !== oldIndex) return;
if (!size) {
index = 0;
base = 1;
return;
}
while (!hasOwnProperty.call(queue, ++base)) continue; //jslint: skip
},
clear: function () {
size = 0;
base = 1;
queue = create(null);
map = create(null);
index = 0;
}
};
};

25
node_modules/lru-queue/package.json generated vendored Normal file
View file

@ -0,0 +1,25 @@
{
"name": "lru-queue",
"version": "0.1.0",
"description": "LRU Queue",
"author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)",
"repository": {
"type": "git",
"url": "git://github.com/medikoo/lru-queue.git"
},
"keywords": [
"lru",
"cache",
"queue"
],
"dependencies": {
"es5-ext": "~0.10.2"
},
"devDependencies": {
"tad": "~0.1.21"
},
"scripts": {
"test": "node node_modules/tad/bin/tad"
},
"license": "MIT"
}

29
node_modules/lru-queue/test/index.js generated vendored Normal file
View file

@ -0,0 +1,29 @@
'use strict';
module.exports = function (t, a) {
var queue = t(3);
a(queue.hit('raz'), undefined, "Hit #1");
a(queue.hit('raz'), undefined, "Hit #2");
a(queue.hit('dwa'), undefined, "Hit #3");
a(queue.hit('raz'), undefined, "Hit #4");
a(queue.hit('dwa'), undefined, "Hit #5");
a(queue.hit('trzy'), undefined, "Hit #6");
a(queue.hit('raz'), undefined, "Hit #7");
a(queue.hit('dwa'), undefined, "Hit #8");
a(queue.hit('cztery'), 'trzy', "Overflow #1");
a(queue.hit('dwa'), undefined, "Hit #9");
a(queue.hit('trzy'), 'raz', "Overflow #2");
a(queue.hit('raz'), 'cztery', "Overflow #3");
a(queue.hit('cztery'), 'dwa', "Overflow #4");
a(queue.hit('trzy'), undefined, "Hit #10");
a(queue.hit('dwa'), 'raz', "Overflow #4");
a(queue.hit('cztery'), undefined, "Hit #11");
queue.delete('cztery');
a(queue.hit('cztery'), undefined, "Hit #12");
};