Latest repo

This commit is contained in:
Marc
2025-06-02 16:41:32 +00:00
parent 8224c1d15e
commit 2fc2a42f71
1591 changed files with 151333 additions and 1 deletions

1
node_modules/node-cache/.nvmrc generated vendored Normal file
View File

@@ -0,0 +1 @@
10.16

7
node_modules/node-cache/.nycrc.yaml generated vendored Normal file
View File

@@ -0,0 +1,7 @@
all: true
exclude:
- "_src/test/**/*"
- "**/*.js"
- "Gruntfile.coffee"
extension:
- ".coffee"

21
node_modules/node-cache/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2019 mpneuried
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.

497
node_modules/node-cache/README.md generated vendored Normal file
View File

@@ -0,0 +1,497 @@
![Logo](./logo/logo.png)
[![Node.js CI](https://github.com/node-cache/node-cache/workflows/Node.js%20CI/badge.svg?branch=master)](https://github.com/node-cache/node-cache/actions?query=workflow%3A%22Node.js+CI%22+branch%3A%22master%22)
![Dependency status](https://img.shields.io/david/node-cache/node-cache)
[![NPM package version](https://img.shields.io/npm/v/node-cache?label=npm%20package)](https://www.npmjs.com/package/node-cache)
[![NPM monthly downloads](https://img.shields.io/npm/dm/node-cache)](https://www.npmjs.com/package/node-cache)
[![GitHub issues](https://img.shields.io/github/issues/node-cache/node-cache)](https://github.com/node-cache/node-cache/issues)
[![Coveralls Coverage](https://img.shields.io/coveralls/node-cache/node-cache.svg)](https://coveralls.io/github/node-cache/node-cache)
# Simple and fast NodeJS internal caching.
A simple caching module that has `set`, `get` and `delete` methods and works a little bit like memcached.
Keys can have a timeout (`ttl`) after which they expire and are deleted from the cache.
All keys are stored in a single object so the practical limit is at around 1m keys.
## BREAKING MAJOR RELEASE v5.x
The recent 5.x release:
* dropped support for node versions before 8.x!
* removed the callback-based api from all methods (you can re-enable them with the option `enableLegacyCallbacks`)
## BREAKING MAJOR RELEASE v6.x UPCOMING
Although not breaking per definition, our typescript rewrite will change internal functions and their names.
Please get in contact with us, if you are using some parts of node-cache's internal api so we can work something out!
# Install
```bash
npm install node-cache --save
```
Or just require the `node_cache.js` file to get the superclass
# Examples:
## Initialize (INIT):
```js
const NodeCache = require( "node-cache" );
const myCache = new NodeCache();
```
### Options
- `stdTTL`: *(default: `0`)* the standard ttl as number in seconds for every generated cache element.
`0` = unlimited
- `checkperiod`: *(default: `600`)* The period in seconds, as a number, used for the automatic delete check interval.
`0` = no periodic check.
- `useClones`: *(default: `true`)* en/disable cloning of variables. If `true` you'll get a copy of the cached variable. If `false` you'll save and get just the reference.
**Note:**
- `true` is recommended if you want **simplicity**, because it'll behave like a server-based cache (it caches copies of plain data).
- `false` is recommended if you want to achieve **performance** or save mutable objects or other complex types with mutability involved and wanted, because it'll only store references of your data.
- _Here's a [simple code example](https://runkit.com/mpneuried/useclones-example-83) showing the different behavior_
- `deleteOnExpire`: *(default: `true`)* whether variables will be deleted automatically when they expire.
If `true` the variable will be deleted. If `false` the variable will remain. You are encouraged to handle the variable upon the event `expired` by yourself.
- `enableLegacyCallbacks`: *(default: `false`)* re-enables the usage of callbacks instead of sync functions. Adds an additional `cb` argument to each function which resolves to `(err, result)`. will be removed in node-cache v6.x.
- `maxKeys`: *(default: `-1`)* specifies a maximum amount of keys that can be stored in the cache. If a new item is set and the cache is full, an error is thrown and the key will not be saved in the cache. -1 disables the key limit.
```js
const NodeCache = require( "node-cache" );
const myCache = new NodeCache( { stdTTL: 100, checkperiod: 120 } );
```
**Since `4.1.0`**:
*Key-validation*: The keys can be given as either `string` or `number`, but are casted to a `string` internally anyway.
All other types will throw an error.
## Store a key (SET):
`myCache.set( key, val, [ ttl ] )`
Sets a `key` `value` pair. It is possible to define a `ttl` (in seconds).
Returns `true` on success.
```js
obj = { my: "Special", variable: 42 };
success = myCache.set( "myKey", obj, 10000 );
// true
```
> Note: If the key expires based on it's `ttl` it will be deleted entirely from the internal data object.
## Store multiple keys (MSET):
`myCache.mset(Array<{key, val, ttl?}>)`
Sets multiple `key` `val` pairs. It is possible to define a `ttl` (seconds).
Returns `true` on success.
```js
const obj = { my: "Special", variable: 42 };
const obj2 = { my: "other special", variable: 1337 };
const success = myCache.mset([
{key: "myKey", val: obj, ttl: 10000},
{key: "myKey2", val: obj2},
])
```
## Retrieve a key (GET):
`myCache.get( key )`
Gets a saved value from the cache.
Returns a `undefined` if not found or expired.
If the value was found it returns the `value`.
```js
value = myCache.get( "myKey" );
if ( value == undefined ){
// handle miss!
}
// { my: "Special", variable: 42 }
```
**Since `2.0.0`**:
The return format changed to a simple value and a `ENOTFOUND` error if not found *( as result instance of `Error` )
**Since `2.1.0`**:
The return format changed to a simple value, but a due to discussion in #11 a miss shouldn't return an error.
So after 2.1.0 a miss returns `undefined`.
## Take a key (TAKE):
`myCache.take( key )`
get the cached value and remove the key from the cache.
Equivalent to calling `get(key)` + `del(key)`.
Useful for implementing `single use` mechanism such as OTP, where once a value is read it will become obsolete.
```js
myCache.set( "myKey", "myValue" )
myCache.has( "myKey" ) // returns true because the key is cached right now
value = myCache.take( "myKey" ) // value === "myValue"; this also deletes the key
myCache.has( "myKey" ) // returns false because the key has been deleted
```
## Get multiple keys (MGET):
`myCache.mget( [ key1, key2, ..., keyn ] )`
Gets multiple saved values from the cache.
Returns an empty object `{}` if not found or expired.
If the value was found it returns an object with the `key` `value` pair.
```js
value = myCache.mget( [ "myKeyA", "myKeyB" ] );
/*
{
"myKeyA": { my: "Special", variable: 123 },
"myKeyB": { the: "Glory", answer: 42 }
}
*/
```
**Since `2.0.0`**:
The method for mget changed from `.get( [ "a", "b" ] )` to `.mget( [ "a", "b" ] )`
## Delete a key (DEL):
`myCache.del( key )`
Delete a key. Returns the number of deleted entries. A delete will never fail.
```js
value = myCache.del( "A" );
// 1
```
## Delete multiple keys (MDEL):
`myCache.del( [ key1, key2, ..., keyn ] )`
Delete multiple keys. Returns the number of deleted entries. A delete will never fail.
```js
value = myCache.del( "A" );
// 1
value = myCache.del( [ "B", "C" ] );
// 2
value = myCache.del( [ "A", "B", "C", "D" ] );
// 1 - because A, B and C not exists
```
## Change TTL (TTL):
`myCache.ttl( key, ttl )`
Redefine the ttl of a key. Returns true if the key has been found and changed. Otherwise returns false.
If the ttl-argument isn't passed the default-TTL will be used.
The key will be deleted when passing in a `ttl < 0`.
```js
myCache = new NodeCache( { stdTTL: 100 } )
changed = myCache.ttl( "existentKey", 100 )
// true
changed2 = myCache.ttl( "missingKey", 100 )
// false
changed3 = myCache.ttl( "existentKey" )
// true
```
## Get TTL (getTTL):
`myCache.getTtl( key )`
Receive the ttl of a key.
You will get:
- `undefined` if the key does not exist
- `0` if this key has no ttl
- a timestamp in ms representing the time at which the key will expire
```js
myCache = new NodeCache( { stdTTL: 100 } )
// Date.now() = 1456000500000
myCache.set( "ttlKey", "MyExpireData" )
myCache.set( "noTtlKey", "NonExpireData", 0 )
ts = myCache.getTtl( "ttlKey" )
// ts wil be approximately 1456000600000
ts = myCache.getTtl( "ttlKey" )
// ts wil be approximately 1456000600000
ts = myCache.getTtl( "noTtlKey" )
// ts = 0
ts = myCache.getTtl( "unknownKey" )
// ts = undefined
```
## List keys (KEYS)
`myCache.keys()`
Returns an array of all existing keys.
```js
mykeys = myCache.keys();
console.log( mykeys );
// [ "all", "my", "keys", "foo", "bar" ]
```
## Has key (HAS)
`myCache.has( key )`
Returns boolean indicating if the key is cached.
```js
exists = myCache.has( 'myKey' );
console.log( exists );
```
## Statistics (STATS):
`myCache.getStats()`
Returns the statistics.
```js
myCache.getStats();
/*
{
keys: 0, // global key count
hits: 0, // global hit count
misses: 0, // global miss count
ksize: 0, // global key size count in approximately bytes
vsize: 0 // global value size count in approximately bytes
}
*/
```
## Flush all data (FLUSH):
`myCache.flushAll()`
Flush all data.
```js
myCache.flushAll();
myCache.getStats();
/*
{
keys: 0, // global key count
hits: 0, // global hit count
misses: 0, // global miss count
ksize: 0, // global key size count in approximately bytes
vsize: 0 // global value size count in approximately bytes
}
*/
```
## Flush the stats (FLUSH STATS):
`myCache.flushStats()`
Flush the stats.
```js
myCache.flushStats();
myCache.getStats();
/*
{
keys: 0, // global key count
hits: 0, // global hit count
misses: 0, // global miss count
ksize: 0, // global key size count in approximately bytes
vsize: 0 // global value size count in approximately bytes
}
*/
```
## Close the cache:
`myCache.close()`
This will clear the interval timeout which is set on check period option.
```js
myCache.close();
```
# Events
## set
Fired when a key has been added or changed.
You will get the `key` and the `value` as callback argument.
```js
myCache.on( "set", function( key, value ){
// ... do something ...
});
```
## del
Fired when a key has been removed manually or due to expiry.
You will get the `key` and the deleted `value` as callback arguments.
```js
myCache.on( "del", function( key, value ){
// ... do something ...
});
```
## expired
Fired when a key expires.
You will get the `key` and `value` as callback argument.
```js
myCache.on( "expired", function( key, value ){
// ... do something ...
});
```
## flush
Fired when the cache has been flushed.
```js
myCache.on( "flush", function(){
// ... do something ...
});
```
## flush_stats
Fired when the cache stats has been flushed.
```js
myCache.on( "flush_stats", function(){
// ... do something ...
});
```
## Breaking changes
### version `2.x`
Due to the [Issue #11](https://github.com/mpneuried/nodecache/issues/11) the return format of the `.get()` method has been changed!
Instead of returning an object with the key `{ "myKey": "myValue" }` it returns the value itself `"myValue"`.
### version `3.x`
Due to the [Issue #30](https://github.com/mpneuried/nodecache/issues/30) and [Issue #27](https://github.com/mpneuried/nodecache/issues/27) variables will now be cloned.
This could break your code, because for some variable types ( e.g. Promise ) its not possible to clone them.
You can disable the cloning by setting the option `useClones: false`. In this case it's compatible with version `2.x`.
### version `5.x`
Callbacks are deprecated in this version. They are still useable when enabling the `enableLegacyCallbacks` option when initializing the cache. Callbacks will be completely removed in `6.x`.
## Compatibility
Node-Cache supports all node versions >= 8
## Release History
|Version|Date|Description|
|:--:|:--:|:--|
|5.1.1|2020-06-06|[#184], [#183] thanks [Jonah Werre](https://github.com/jwerre) for reporting [#181]!, [#180], Thanks [Titus](https://github.com/tstone) for [#169]!, Thanks [Ianfeather](https://github.com/Ianfeather) for [#168]!, Thanks [Adam Haglund](https://github.com/BeeeQueue) for [#176]|
|5.1.0|2019-12-08|Add .take() from PR [#160] and .flushStats from PR [#161]. Thanks to [Sujesh Thekkepatt](https://github.com/sujeshthekkepatt) and [Gopalakrishna Palem](https://github.com/KrishnaPG)!|
|5.0.2|2019-11-17|Fixed bug where expired values were deleted even though `deleteOnExpire` was set to `false`. Thanks to [fielding-wilson](https://github.com/fielding-wilson)!|
|5.0.1|2019-10-31|Fixed bug where users could not set null values. Thanks to [StefanoSega](https://github.com/StefanoSega), [jwest23](https://github.com/jwest23) and [marudor](https://github.com/marudor)!|
|5.0.0|2019-10-23|Remove lodash dependency, add .has(key) and .mset([{key,val,ttl}]) methods to the cache. Thanks to [Regev Brody](https://github.com/regevbr) for PR [#132] and [Sujesh Thekkepatt](https://github.com/sujeshthekkepatt) for PR [#142]! Also thank you, to all other contributors that remain unnamed here!|
|4.2.1|2019-07-22|Upgrade lodash to version 4.17.15 to suppress messages about unrelated security vulnerability|
|4.2.0|2018-02-01|Add options.promiseValueSize for promise value. Thanks to [Ryan Roemer](https://github.com/ryan-roemer) for the pull [#84]; Added option `deleteOnExpire`; Added DefinitelyTyped Typescript definitions. Thanks to [Ulf Seltmann](https://github.com/useltmann) for the pulls [#90] and [#92]; Thanks to [Daniel Jin](https://github.com/danieljin) for the readme fix in pull [#93]; Optimized test and ci configs.|
|4.1.1|2016-12-21|fix internal check interval for node < 0.10.25, thats the default node for ubuntu 14.04. Thanks to [Jimmy Hwang](https://github.com/JimmyHwang) for the pull [#78](https://github.com/mpneuried/nodecache/pull/78); added more docker tests|
|4.1.0|2016-09-23|Added tests for different key types; Added key validation (must be `string` or `number`); Fixed `.del` bug where trying to delete a `number` key resulted in no deletion at all.|
|4.0.0|2016-09-20|Updated tests to mocha; Fixed `.ttl` bug to not delete key on `.ttl( key, 0 )`. This is also relevant if `stdTTL=0`. *This causes the breaking change to `4.0.0`.*|
|3.2.1|2016-03-21|Updated lodash to 4.x.; optimized grunt |
|3.2.0|2016-01-29|Added method `getTtl` to get the time when a key expires. See [#49](https://github.com/mpneuried/nodecache/issues/49)|
|3.1.0|2016-01-29|Added option `errorOnMissing` to throw/callback an error o a miss during a `.get( "key" )`. Thanks to [David Godfrey](https://github.com/david-byng) for the pull [#45](https://github.com/mpneuried/nodecache/pull/45). Added docker files and a script to run test on different node versions locally|
|3.0.1|2016-01-13|Added `.unref()` to the checkTimeout so until node `0.10` it's not necessary to call `.close()` when your script is done. Thanks to [Doug Moscrop](https://github.com/dougmoscrop) for the pull [#44](https://github.com/mpneuried/nodecache/pull/44).|
|3.0.0|2015-05-29|Return a cloned version of the cached element and save a cloned version of a variable. This can be disabled by setting the option `useClones:false`. (Thanks for #27 to [cheshirecatalyst](https://github.com/cheshirecatalyst) and for #30 to [Matthieu Sieben](https://github.com/matthieusieben))|
|~~2.2.0~~|~~2015-05-27~~|REVOKED VERSION, because of conficts. See [Issue #30](https://github.com/mpneuried/nodecache/issues/30). So `2.2.0` is now `3.0.0`|
|2.1.1|2015-04-17|Passed old value to the `del` event. Thanks to [Qix](https://github.com/qix) for the pull.|
|2.1.0|2015-04-17|Changed get miss to return `undefined` instead of an error. Thanks to all [#11](https://github.com/mpneuried/nodecache/issues/11) contributors |
|2.0.1|2015-04-17|Added close function (Thanks to [ownagedj](https://github.com/ownagedj)). Changed the development environment to use grunt.|
|2.0.0|2015-01-05|changed return format of `.get()` with a error return on a miss and added the `.mget()` method. *Side effect: Performance of .get() up to 330 times faster!*|
|1.1.0|2015-01-05|added `.keys()` method to list all existing keys|
|1.0.3|2014-11-07|fix for setting numeric values. Thanks to [kaspars](https://github.com/kaspars) + optimized key ckeck.|
|1.0.2|2014-09-17|Small change for better ttl handling|
|1.0.1|2014-05-22|Readme typos. Thanks to [mjschranz](https://github.com/mjschranz)|
|1.0.0|2014-04-09|Made `callback`s optional. So it's now possible to use a syncron syntax. The old syntax should also work well. Push : Bugfix for the value `0`|
|0.4.1|2013-10-02|Added the value to `expired` event|
|0.4.0|2013-10-02|Added nodecache events|
|0.3.2|2012-05-31|Added Travis tests|
[![NPM](https://nodei.co/npm-dl/node-cache.png?months=6)](https://nodei.co/npm/node-cache/)
## Other projects
|Name|Description|
|:--|:--|
|[**rsmq**](https://github.com/smrchy/rsmq)|A really simple message queue based on redis|
|[**redis-heartbeat**](https://github.com/mpneuried/redis-heartbeat)|Pulse a heartbeat to redis. This can be used to detach or attach servers to nginx or similar problems.|
|[**systemhealth**](https://github.com/mpneuried/systemhealth)|Node module to run simple custom checks for your machine or it's connections. It will use [redis-heartbeat](https://github.com/mpneuried/redis-heartbeat) to send the current state to redis.|
|[**rsmq-cli**](https://github.com/mpneuried/rsmq-cli)|a terminal client for rsmq|
|[**rest-rsmq**](https://github.com/smrchy/rest-rsmq)|REST interface for.|
|[**redis-sessions**](https://github.com/smrchy/redis-sessions)|An advanced session store for NodeJS and Redis|
|[**connect-redis-sessions**](https://github.com/mpneuried/connect-redis-sessions)|A connect or express middleware to simply use the [redis sessions](https://github.com/smrchy/redis-sessions). With [redis sessions](https://github.com/smrchy/redis-sessions) you can handle multiple sessions per user_id.|
|[**redis-notifications**](https://github.com/mpneuried/redis-notifications)|A redis based notification engine. It implements the rsmq-worker to safely create notifications and recurring reports.|
|[**nsq-logger**](https://github.com/mpneuried/nsq-logger)|Nsq service to read messages from all topics listed within a list of nsqlookupd services.|
|[**nsq-topics**](https://github.com/mpneuried/nsq-topics)|Nsq helper to poll a nsqlookupd service for all it's topics and mirror it locally.|
|[**nsq-nodes**](https://github.com/mpneuried/nsq-nodes)|Nsq helper to poll a nsqlookupd service for all it's nodes and mirror it locally.|
|[**nsq-watch**](https://github.com/mpneuried/nsq-watch)|Watch one or many topics for unprocessed messages.|
|[**hyperrequest**](https://github.com/mpneuried/hyperrequest)|A wrapper around [hyperquest](https://github.com/substack/hyperquest) to handle the results|
|[**task-queue-worker**](https://github.com/smrchy/task-queue-worker)|A powerful tool for background processing of tasks that are run by making standard http requests
|[**soyer**](https://github.com/mpneuried/soyer)|Soyer is small lib for server side use of Google Closure Templates with node.js.|
|[**grunt-soy-compile**](https://github.com/mpneuried/grunt-soy-compile)|Compile Goggle Closure Templates ( SOY ) templates including the handling of XLIFF language files.|
|[**backlunr**](https://github.com/mpneuried/backlunr)|A solution to bring Backbone Collections together with the browser fulltext search engine Lunr.js|
|[**domel**](https://github.com/mpneuried/domel)|A simple dom helper if you want to get rid of jQuery|
|[**obj-schema**](https://github.com/mpneuried/obj-schema)|Simple module to validate an object by a predefined schema|
# The MIT License (MIT)
Copyright © 2019 Mathias Peter and the node-cache maintainers, https://github.com/node-cache/node-cache
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.

View File

@@ -0,0 +1,108 @@
import NodeCache = require("../../");
import Options = NodeCache.Options;
import Stats = NodeCache.Stats;
import Callback = NodeCache.Callback;
interface TypeSample {
a: number;
b: string;
c: boolean;
}
{
let options: Options;
let cache: NodeCache;
cache = new NodeCache();
cache = new NodeCache(options);
}
{
let cache: NodeCache;
let key: string;
let result: TypeSample | undefined;
result = cache.get<TypeSample>(key);
result = cache.get<TypeSample>(key);
}
{
let cache: NodeCache;
let keys: string[];
let result: { [key: string]: TypeSample };
result = cache.mget<TypeSample>(keys);
result = cache.mget<TypeSample>(keys);
}
{
let cache: NodeCache;
let key: string;
let value: TypeSample;
let ttl: number | string;
let result: boolean;
result = cache.set<TypeSample>(key, value);
result = cache.set<TypeSample>(key, value, ttl);
result = cache.set<TypeSample>(key, value, ttl);
result = cache.set<TypeSample>(key, value);
}
{
let cache: NodeCache;
let keys: string | string[];
let result: number;
result = cache.del(keys);
result = cache.del(keys);
}
{
let cache: NodeCache;
let key: string;
let ttl: number;
let result: boolean;
result = cache.ttl(key);
result = cache.ttl(key, ttl);
result = cache.ttl(key, ttl);
result = cache.ttl(key);
}
{
let cache: NodeCache;
let result: string[];
result = cache.keys();
result = cache.keys();
}
{
let cache: NodeCache;
let key: string | number;
let result: boolean;
result = cache.has(key);
result = cache.has(key);
}
{
let cache: NodeCache;
let result: Stats;
result = cache.getStats();
}
{
let cache: NodeCache;
let key: string;
let number: number;
let result1: number | undefined;
result1 = cache.getTtl(key);
}
/* tslint:disable void-return no-void-expression */
{
let cache: NodeCache;
let result: void;
result = cache.flushAll();
}
{
let cache: NodeCache;
let result: void;
result = cache.close();
}
/* tslint:enable void-return */

380
node_modules/node-cache/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,380 @@
// Type definitions for node-cache 5
// Project: https://github.com/tcs-de/nodecache
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
// Daniel Thunell <https://github.com/dthunell>
// Ulf Seltmann <https://github.com/useltmann>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare namespace NodeCache {
interface NodeCacheLegacyCallbacks {
/** container for cached data */
data: Data;
/** module options */
options: Options;
/** statistics container */
stats: Stats;
/**
* get a cached key and change the stats
*
* @param key cache key or an array of keys
* @param cb Callback function
*/
get<T>(
key: Key,
cb?: Callback<T>
): T | undefined;
/**
* get multiple cached keys at once and change the stats
*
* @param keys an array of keys
* @param cb Callback function
*/
mget<T>(
keys: Key[],
cb?: Callback<{ [key: string]: T }>
): { [key: string]: T };
/**
* set a cached key and change the stats
*
* @param key cache key
* @param value A element to cache. If the option `option.forceString` is `true` the module trys to translate
* it to a serialized JSON
* @param ttl The time to live in seconds.
* @param cb Callback function
*/
set<T>(
key: Key,
value: T,
ttl: number | string,
cb?: Callback<boolean>
): boolean;
set<T>(
key: Key,
value: T,
cb?: Callback<boolean>
): boolean;
/**
* set multiple cached keys at once and change the stats
*
* @param keyValueSet an array of object which includes key,value and ttl
*/
mset<T>(
keyValueSet: ValueSetItem<T>[],
): boolean;
/**
* remove keys
* @param keys cache key to delete or a array of cache keys
* @param cb Callback function
* @returns Number of deleted keys
*/
del(
keys: Key | Key[],
cb?: Callback<number>
): number;
/**
* reset or redefine the ttl of a key. If `ttl` is not passed or set to 0 it's similar to `.del()`
*/
ttl(
key: Key,
ttl: number,
cb?: Callback<boolean>
): boolean;
ttl(
key: Key,
cb?: Callback<boolean>
): boolean;
getTtl(
key: Key,
): number|undefined;
getTtl(
key: Key,
cb?: Callback<boolean>
): boolean;
/**
* list all keys within this cache
* @param cb Callback function
* @returns An array of all keys
*/
keys(cb?: Callback<string[]>): string[];
/**
* get the stats
*
* @returns Stats data
*/
getStats(): Stats;
/**
* flush the whole data and reset the stats
*/
flushAll(): void;
/**
* This will clear the interval timeout which is set on checkperiod option.
*/
close(): void;
}
/**
* Since 4.1.0: Key-validation: The keys can be given as either string or number,
* but are casted to a string internally anyway.
*/
type Key = string | number;
type ValueSetItem<T = any> = {
key: Key;
val: T;
ttl?: number;
}
interface Data {
[key: string]: WrappedValue<any>;
}
interface Options {
/**
* If enabled, all values will be stringified during the set operation
*
* @type {boolean}
* @memberof Options
*/
forceString?: boolean;
objectValueSize?: number;
promiseValueSize?: number;
arrayValueSize?: number;
/**
* standard time to live in seconds. 0 = infinity
*
* @type {number}
* @memberof Options
*/
stdTTL?: number;
/**
* time in seconds to check all data and delete expired keys
*
* @type {number}
* @memberof Options
*/
checkperiod?: number;
/**
* en/disable cloning of variables.
* disabling this is strongly encouraged when aiming for performance!
*
* If `true`: set operations store a clone of the value and get operations will create a fresh clone of the cached value
* If `false` you'll just store a reference to your value
*
* @type {boolean}
* @memberof Options
*/
useClones?: boolean;
errorOnMissing?: boolean;
deleteOnExpire?: boolean;
/**
* enable legacy callbacks.
* legacy callback support will drop in v6.x!
*
* @type {boolean}
* @memberof Options
*/
enableLegacyCallbacks?: boolean;
/**
* max amount of keys that are being stored.
* set operations will throw an error when the cache is full
*
* @type {number}
* @memberof Options
*/
maxKeys?: number;
}
interface Stats {
hits: number;
misses: number;
keys: number;
ksize: number;
vsize: number;
}
interface WrappedValue<T> {
// ttl
t: number;
// value
v: T;
}
type Callback<T> = (err: any, data: T | undefined) => void;
}
import events = require("events");
import Data = NodeCache.Data;
import Key = NodeCache.Key;
import Options = NodeCache.Options;
import Stats = NodeCache.Stats;
import Callback = NodeCache.Callback;
import ValueSetItem = NodeCache.ValueSetItem;
import NodeCacheLegacyCallbacks = NodeCache.NodeCacheLegacyCallbacks;
declare class NodeCache extends events.EventEmitter {
/** container for cached data */
data: Data;
/** module options */
options: Options;
/** statistics container */
stats: Stats;
/** constructor */
constructor(options?: Options);
/**
* get a cached key and change the stats
*
* @param key cache key
* @returns The value stored in the key
*/
get<T>(
key: Key
): T | undefined;
/**
* get multiple cached keys at once and change the stats
*
* @param keys an array of keys
* @returns an object containing the values stored in the matching keys
*/
mget<T>(
keys: Key[]
): { [key: string]: T };
/**
* set a cached key and change the stats
*
* @param key cache key
* @param value A element to cache. If the option `option.forceString` is `true` the module trys to translate
* it to a serialized JSON
* @param ttl The time to live in seconds.
*/
set<T>(
key: Key,
value: T,
ttl: number | string
): boolean;
set<T>(
key: Key,
value: T
): boolean;
/**
* set multiple cached keys at once and change the stats
*
* @param keyValueSet an array of object which includes key,value and ttl
*/
mset<T>(
keyValueSet: ValueSetItem<T>[]
): boolean;
/**
* remove keys
* @param keys cache key to delete or a array of cache keys
* @param cb Callback function
* @returns Number of deleted keys
*/
del(
keys: Key | Key[]
): number;
/**
* get a cached key and remove it from the cache.
* Equivalent to calling `get(key)` + `del(key)`.
* Useful for implementing `single use` mechanism such as OTP, where once a value is read it will become obsolete.
*
* @param key cache key
* @returns The value stored in the key
*/
take<T>(
key: Key
): T | undefined;
/**
* reset or redefine the ttl of a key. If `ttl` is not passed or set to 0 it's similar to `.del()`
*/
ttl(
key: Key,
ttl: number
): boolean;
ttl(
key: Key
): boolean;
getTtl(
key: Key,
): number|undefined;
getTtl(
key: Key
): boolean;
/**
* list all keys within this cache
* @returns An array of all keys
*/
keys(): string[];
/**
* get the stats
*
* @returns Stats data
*/
getStats(): Stats;
/**
* Check if a key is cached
* @param key cache key to check
* @returns Boolean indicating if the key is cached or not
*/
has(key: Key): boolean;
/**
* flush the whole data and reset the stats
*/
flushAll(): void;
/**
* This will clear the interval timeout which is set on checkperiod option.
*/
close(): void;
/**
* flush the stats and reset all counters to 0
*/
flushStats(): void;
}
export = NodeCache;

17
node_modules/node-cache/index.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
/*
* node-cache 5.1.2 ( 2020-07-01 )
* https://github.com/node-cache/node-cache
*
* Released under the MIT license
* https://github.com/node-cache/node-cache/blob/master/LICENSE
*
* Maintained by ( )
*/
(function() {
var exports;
exports = module.exports = require('./lib/node_cache');
exports.version = '5.1.2';
}).call(this);

802
node_modules/node-cache/lib/node_cache.js generated vendored Normal file
View File

@@ -0,0 +1,802 @@
/*
* node-cache 5.1.2 ( 2020-07-01 )
* https://github.com/node-cache/node-cache
*
* Released under the MIT license
* https://github.com/node-cache/node-cache/blob/master/LICENSE
*
* Maintained by ( )
*/
(function() {
var EventEmitter, NodeCache, clone,
splice = [].splice,
boundMethodCheck = function(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new Error('Bound instance method accessed before binding'); } },
indexOf = [].indexOf;
clone = require("clone");
EventEmitter = require('events').EventEmitter;
// generate superclass
module.exports = NodeCache = (function() {
class NodeCache extends EventEmitter {
constructor(options = {}) {
super();
// ## get
// get a cached key and change the stats
// **Parameters:**
// * `key` ( String | Number ): cache key
// **Example:**
// myCache.get "myKey", ( err, val )
this.get = this.get.bind(this);
// ## mget
// get multiple cached keys at once and change the stats
// **Parameters:**
// * `keys` ( String|Number[] ): an array of keys
// **Example:**
// myCache.mget [ "foo", "bar" ]
this.mget = this.mget.bind(this);
// ## set
// set a cached key and change the stats
// **Parameters:**
// * `key` ( String | Number ): cache key
// * `value` ( Any ): A element to cache. If the option `option.forceString` is `true` the module trys to translate it to a serialized JSON
// * `[ ttl ]` ( Number | String ): ( optional ) The time to live in seconds.
// **Example:**
// myCache.set "myKey", "my_String Value"
// myCache.set "myKey", "my_String Value", 10
this.set = this.set.bind(this);
// ## mset
// set multiple keys at once
// **Parameters:**
// * `keyValueSet` ( Object[] ): an array of object which includes key,value and ttl
// **Example:**
// myCache.mset(
// [
// {
// key: "myKey",
// val: "myValue",
// ttl: [ttl in seconds]
// }
// ])
this.mset = this.mset.bind(this);
// ## del
// remove keys
// **Parameters:**
// * `keys` ( String | Number | String|Number[] ): cache key to delete or a array of cache keys
// **Return**
// ( Number ): Number of deleted keys
// **Example:**
// myCache.del( "myKey" )
this.del = this.del.bind(this);
// ## take
// get the cached value and remove the key from the cache.
// Equivalent to calling `get(key)` + `del(key)`.
// Useful for implementing `single use` mechanism such as OTP, where once a value is read it will become obsolete.
// **Parameters:**
// * `key` ( String | Number ): cache key
// **Example:**
// myCache.take "myKey", ( err, val )
this.take = this.take.bind(this);
// ## ttl
// reset or redefine the ttl of a key. `ttl` = 0 means infinite lifetime.
// If `ttl` is not passed the default ttl is used.
// If `ttl` < 0 the key will be deleted.
// **Parameters:**
// * `key` ( String | Number ): cache key to reset the ttl value
// * `ttl` ( Number ): ( optional -> options.stdTTL || 0 ) The time to live in seconds
// **Return**
// ( Boolen ): key found and ttl set
// **Example:**
// myCache.ttl( "myKey" ) // will set ttl to default ttl
// myCache.ttl( "myKey", 1000 )
this.ttl = this.ttl.bind(this);
// ## getTtl
// receive the ttl of a key.
// **Parameters:**
// * `key` ( String | Number ): cache key to check the ttl value
// **Return**
// ( Number|undefined ): The timestamp in ms when the key will expire, 0 if it will never expire or undefined if it not exists
// **Example:**
// myCache.getTtl( "myKey" )
this.getTtl = this.getTtl.bind(this);
// ## keys
// list all keys within this cache
// **Return**
// ( Array ): An array of all keys
// **Example:**
// _keys = myCache.keys()
// # [ "foo", "bar", "fizz", "buzz", "anotherKeys" ]
this.keys = this.keys.bind(this);
// ## has
// Check if a key is cached
// **Parameters:**
// * `key` ( String | Number ): cache key to check the ttl value
// **Return**
// ( Boolean ): A boolean that indicates if the key is cached
// **Example:**
// _exists = myCache.has('myKey')
// # true
this.has = this.has.bind(this);
// ## getStats
// get the stats
// **Parameters:**
// -
// **Return**
// ( Object ): Stats data
// **Example:**
// myCache.getStats()
// # {
// # hits: 0,
// # misses: 0,
// # keys: 0,
// # ksize: 0,
// # vsize: 0
// # }
this.getStats = this.getStats.bind(this);
// ## flushAll
// flush the whole data and reset the stats
// **Example:**
// myCache.flushAll()
// myCache.getStats()
// # {
// # hits: 0,
// # misses: 0,
// # keys: 0,
// # ksize: 0,
// # vsize: 0
// # }
this.flushAll = this.flushAll.bind(this);
// ## flushStats
// flush the stats and reset all counters to 0
// **Example:**
// myCache.flushStats()
// myCache.getStats()
// # {
// # hits: 0,
// # misses: 0,
// # keys: 0,
// # ksize: 0,
// # vsize: 0
// # }
this.flushStats = this.flushStats.bind(this);
// ## close
// This will clear the interval timeout which is set on checkperiod option.
// **Example:**
// myCache.close()
this.close = this.close.bind(this);
// ## _checkData
// internal housekeeping method.
// Check all the cached data and delete the invalid values
this._checkData = this._checkData.bind(this);
// ## _check
// internal method the check the value. If it's not valid any more delete it
this._check = this._check.bind(this);
// ## _isInvalidKey
// internal method to check if the type of a key is either `number` or `string`
this._isInvalidKey = this._isInvalidKey.bind(this);
// ## _wrap
// internal method to wrap a value in an object with some metadata
this._wrap = this._wrap.bind(this);
// ## _getValLength
// internal method to calculate the value length
this._getValLength = this._getValLength.bind(this);
// ## _error
// internal method to handle an error message
this._error = this._error.bind(this);
// ## _initErrors
// internal method to generate error message templates
this._initErrors = this._initErrors.bind(this);
this.options = options;
this._initErrors();
// container for cached data
this.data = {};
// module options
this.options = Object.assign({
// convert all elements to string
forceString: false,
// used standard size for calculating value size
objectValueSize: 80,
promiseValueSize: 80,
arrayValueSize: 40,
// standard time to live in seconds. 0 = infinity;
stdTTL: 0,
// time in seconds to check all data and delete expired keys
checkperiod: 600,
// en/disable cloning of variables. If `true` you'll get a copy of the cached variable. If `false` you'll save and get just the reference
useClones: true,
// whether values should be deleted automatically at expiration
deleteOnExpire: true,
// enable legacy callbacks
enableLegacyCallbacks: false,
// max amount of keys that are being stored
maxKeys: -1
}, this.options);
// generate functions with callbacks (legacy)
if (this.options.enableLegacyCallbacks) {
console.warn("WARNING! node-cache legacy callback support will drop in v6.x");
["get", "mget", "set", "del", "ttl", "getTtl", "keys", "has"].forEach((methodKey) => {
var oldMethod;
// reference real function
oldMethod = this[methodKey];
this[methodKey] = function(...args) {
var cb, err, ref, res;
ref = args, [...args] = ref, [cb] = splice.call(args, -1);
// return a callback if cb is defined and a function
if (typeof cb === "function") {
try {
res = oldMethod(...args);
cb(null, res);
} catch (error1) {
err = error1;
cb(err);
}
} else {
return oldMethod(...args, cb);
}
};
});
}
// statistics container
this.stats = {
hits: 0,
misses: 0,
keys: 0,
ksize: 0,
vsize: 0
};
// pre allocate valid keytypes array
this.validKeyTypes = ["string", "number"];
// initalize checking period
this._checkData();
return;
}
get(key) {
var _ret, err;
boundMethodCheck(this, NodeCache);
// handle invalid key types
if ((err = this._isInvalidKey(key)) != null) {
throw err;
}
// get data and incremet stats
if ((this.data[key] != null) && this._check(key, this.data[key])) {
this.stats.hits++;
_ret = this._unwrap(this.data[key]);
// return data
return _ret;
} else {
// if not found return undefined
this.stats.misses++;
return void 0;
}
}
mget(keys) {
var _err, err, i, key, len, oRet;
boundMethodCheck(this, NodeCache);
// convert a string to an array of one key
if (!Array.isArray(keys)) {
_err = this._error("EKEYSTYPE");
throw _err;
}
// define return
oRet = {};
for (i = 0, len = keys.length; i < len; i++) {
key = keys[i];
// handle invalid key types
if ((err = this._isInvalidKey(key)) != null) {
throw err;
}
// get data and increment stats
if ((this.data[key] != null) && this._check(key, this.data[key])) {
this.stats.hits++;
oRet[key] = this._unwrap(this.data[key]);
} else {
// if not found return a error
this.stats.misses++;
}
}
// return all found keys
return oRet;
}
set(key, value, ttl) {
var _err, err, existent;
boundMethodCheck(this, NodeCache);
// check if cache is overflowing
if (this.options.maxKeys > -1 && this.stats.keys >= this.options.maxKeys) {
_err = this._error("ECACHEFULL");
throw _err;
}
// force the data to string
if (this.options.forceString && !typeof value === "string") {
value = JSON.stringify(value);
}
// set default ttl if not passed
if (ttl == null) {
ttl = this.options.stdTTL;
}
// handle invalid key types
if ((err = this._isInvalidKey(key)) != null) {
throw err;
}
// internal helper variables
existent = false;
// remove existing data from stats
if (this.data[key]) {
existent = true;
this.stats.vsize -= this._getValLength(this._unwrap(this.data[key], false));
}
// set the value
this.data[key] = this._wrap(value, ttl);
this.stats.vsize += this._getValLength(value);
// only add the keys and key-size if the key is new
if (!existent) {
this.stats.ksize += this._getKeyLength(key);
this.stats.keys++;
}
this.emit("set", key, value);
// return true
return true;
}
mset(keyValueSet) {
var _err, err, i, j, key, keyValuePair, len, len1, ttl, val;
boundMethodCheck(this, NodeCache);
// check if cache is overflowing
if (this.options.maxKeys > -1 && this.stats.keys + keyValueSet.length >= this.options.maxKeys) {
_err = this._error("ECACHEFULL");
throw _err;
}
// loop over keyValueSet to validate key and ttl
for (i = 0, len = keyValueSet.length; i < len; i++) {
keyValuePair = keyValueSet[i];
({key, val, ttl} = keyValuePair);
// check if there is ttl and it's a number
if (ttl && typeof ttl !== "number") {
_err = this._error("ETTLTYPE");
throw _err;
}
// handle invalid key types
if ((err = this._isInvalidKey(key)) != null) {
throw err;
}
}
for (j = 0, len1 = keyValueSet.length; j < len1; j++) {
keyValuePair = keyValueSet[j];
({key, val, ttl} = keyValuePair);
this.set(key, val, ttl);
}
return true;
}
del(keys) {
var delCount, err, i, key, len, oldVal;
boundMethodCheck(this, NodeCache);
// convert keys to an array of itself
if (!Array.isArray(keys)) {
keys = [keys];
}
delCount = 0;
for (i = 0, len = keys.length; i < len; i++) {
key = keys[i];
// handle invalid key types
if ((err = this._isInvalidKey(key)) != null) {
throw err;
}
// only delete if existent
if (this.data[key] != null) {
// calc the stats
this.stats.vsize -= this._getValLength(this._unwrap(this.data[key], false));
this.stats.ksize -= this._getKeyLength(key);
this.stats.keys--;
delCount++;
// delete the value
oldVal = this.data[key];
delete this.data[key];
// return true
this.emit("del", key, oldVal.v);
}
}
return delCount;
}
take(key) {
var _ret;
boundMethodCheck(this, NodeCache);
_ret = this.get(key);
if ((_ret != null)) {
this.del(key);
}
return _ret;
}
ttl(key, ttl) {
var err;
boundMethodCheck(this, NodeCache);
ttl || (ttl = this.options.stdTTL);
if (!key) {
return false;
}
// handle invalid key types
if ((err = this._isInvalidKey(key)) != null) {
throw err;
}
// check for existent data and update the ttl value
if ((this.data[key] != null) && this._check(key, this.data[key])) {
// if ttl < 0 delete the key. otherwise reset the value
if (ttl >= 0) {
this.data[key] = this._wrap(this.data[key].v, ttl, false);
} else {
this.del(key);
}
return true;
} else {
// return false if key has not been found
return false;
}
}
getTtl(key) {
var _ttl, err;
boundMethodCheck(this, NodeCache);
if (!key) {
return void 0;
}
// handle invalid key types
if ((err = this._isInvalidKey(key)) != null) {
throw err;
}
// check for existant data and update the ttl value
if ((this.data[key] != null) && this._check(key, this.data[key])) {
_ttl = this.data[key].t;
return _ttl;
} else {
// return undefined if key has not been found
return void 0;
}
}
keys() {
var _keys;
boundMethodCheck(this, NodeCache);
_keys = Object.keys(this.data);
return _keys;
}
has(key) {
var _exists;
boundMethodCheck(this, NodeCache);
_exists = (this.data[key] != null) && this._check(key, this.data[key]);
return _exists;
}
getStats() {
boundMethodCheck(this, NodeCache);
return this.stats;
}
flushAll(_startPeriod = true) {
boundMethodCheck(this, NodeCache);
// parameter just for testing
// set data empty
this.data = {};
// reset stats
this.stats = {
hits: 0,
misses: 0,
keys: 0,
ksize: 0,
vsize: 0
};
// reset check period
this._killCheckPeriod();
this._checkData(_startPeriod);
this.emit("flush");
}
flushStats() {
boundMethodCheck(this, NodeCache);
// reset stats
this.stats = {
hits: 0,
misses: 0,
keys: 0,
ksize: 0,
vsize: 0
};
this.emit("flush_stats");
}
close() {
boundMethodCheck(this, NodeCache);
this._killCheckPeriod();
}
_checkData(startPeriod = true) {
var key, ref, value;
boundMethodCheck(this, NodeCache);
ref = this.data;
// run the housekeeping method
for (key in ref) {
value = ref[key];
this._check(key, value);
}
if (startPeriod && this.options.checkperiod > 0) {
this.checkTimeout = setTimeout(this._checkData, this.options.checkperiod * 1000, startPeriod);
if ((this.checkTimeout != null) && (this.checkTimeout.unref != null)) {
this.checkTimeout.unref();
}
}
}
// ## _killCheckPeriod
// stop the checkdata period. Only needed to abort the script in testing mode.
_killCheckPeriod() {
if (this.checkTimeout != null) {
return clearTimeout(this.checkTimeout);
}
}
_check(key, data) {
var _retval;
boundMethodCheck(this, NodeCache);
_retval = true;
// data is invalid if the ttl is too old and is not 0
// console.log data.t < Date.now(), data.t, Date.now()
if (data.t !== 0 && data.t < Date.now()) {
if (this.options.deleteOnExpire) {
_retval = false;
this.del(key);
}
this.emit("expired", key, this._unwrap(data));
}
return _retval;
}
_isInvalidKey(key) {
var ref;
boundMethodCheck(this, NodeCache);
if (ref = typeof key, indexOf.call(this.validKeyTypes, ref) < 0) {
return this._error("EKEYTYPE", {
type: typeof key
});
}
}
_wrap(value, ttl, asClone = true) {
var livetime, now, oReturn, ttlMultiplicator;
boundMethodCheck(this, NodeCache);
if (!this.options.useClones) {
asClone = false;
}
// define the time to live
now = Date.now();
livetime = 0;
ttlMultiplicator = 1000;
// use given ttl
if (ttl === 0) {
livetime = 0;
} else if (ttl) {
livetime = now + (ttl * ttlMultiplicator);
} else {
// use standard ttl
if (this.options.stdTTL === 0) {
livetime = this.options.stdTTL;
} else {
livetime = now + (this.options.stdTTL * ttlMultiplicator);
}
}
// return the wrapped value
return oReturn = {
t: livetime,
v: asClone ? clone(value) : value
};
}
// ## _unwrap
// internal method to extract get the value out of the wrapped value
_unwrap(value, asClone = true) {
if (!this.options.useClones) {
asClone = false;
}
if (value.v != null) {
if (asClone) {
return clone(value.v);
} else {
return value.v;
}
}
return null;
}
// ## _getKeyLength
// internal method the calculate the key length
_getKeyLength(key) {
return key.toString().length;
}
_getValLength(value) {
boundMethodCheck(this, NodeCache);
if (typeof value === "string") {
// if the value is a String get the real length
return value.length;
} else if (this.options.forceString) {
// force string if it's defined and not passed
return JSON.stringify(value).length;
} else if (Array.isArray(value)) {
// if the data is an Array multiply each element with a defined default length
return this.options.arrayValueSize * value.length;
} else if (typeof value === "number") {
return 8;
} else if (typeof (value != null ? value.then : void 0) === "function") {
// if the data is a Promise, use defined default
// (can't calculate actual/resolved value size synchronously)
return this.options.promiseValueSize;
} else if (typeof Buffer !== "undefined" && Buffer !== null ? Buffer.isBuffer(value) : void 0) {
return value.length;
} else if ((value != null) && typeof value === "object") {
// if the data is an Object multiply each element with a defined default length
return this.options.objectValueSize * Object.keys(value).length;
} else if (typeof value === "boolean") {
return 8;
} else {
// default fallback
return 0;
}
}
_error(type, data = {}) {
var error;
boundMethodCheck(this, NodeCache);
// generate the error object
error = new Error();
error.name = type;
error.errorcode = type;
error.message = this.ERRORS[type] != null ? this.ERRORS[type](data) : "-";
error.data = data;
// return the error object
return error;
}
_initErrors() {
var _errMsg, _errT, ref;
boundMethodCheck(this, NodeCache);
this.ERRORS = {};
ref = this._ERRORS;
for (_errT in ref) {
_errMsg = ref[_errT];
this.ERRORS[_errT] = this.createErrorMessage(_errMsg);
}
}
createErrorMessage(errMsg) {
return function(args) {
return errMsg.replace("__key", args.type);
};
}
};
NodeCache.prototype._ERRORS = {
"ENOTFOUND": "Key `__key` not found",
"ECACHEFULL": "Cache max keys amount exceeded",
"EKEYTYPE": "The key argument has to be of type `string` or `number`. Found: `__key`",
"EKEYSTYPE": "The keys argument has to be an array.",
"ETTLTYPE": "The ttl argument has to be a number."
};
return NodeCache;
}).call(this);
}).call(this);

80
node_modules/node-cache/package.json generated vendored Normal file
View File

@@ -0,0 +1,80 @@
{
"name": "node-cache",
"description": "Simple and fast NodeJS internal caching. Node internal in memory cache like memcached.",
"keywords": [
"cache",
"caching",
"local",
"variable",
"multi",
"memory",
"internal",
"node",
"memcached",
"object"
],
"tags": [
"cache",
"caching",
"local",
"variable",
"multi",
"memory",
"internal",
"node",
"memcached",
"object"
],
"version": "5.1.2",
"author": "mpneuried <mp@tcs.de>",
"maintainers": [
{
"name": "M. Peter",
"email": "mp@tcs.de",
"url": "https://github.com/mpneuried"
},
{
"name": "Joshy",
"email": "erdiicodes@gmail.com",
"url": "https://erdii.engineering/"
}
],
"main": "./index.js",
"types": "./index.d.ts",
"homepage": "https://github.com/node-cache/node-cache",
"repository": {
"type": "git",
"url": "git://github.com/node-cache/node-cache.git"
},
"license": "MIT",
"engines": {
"node": ">= 8.0.0"
},
"scripts": {
"test": "nyc --require coffee-script/register mocha _src/test/mocha_test.coffee -R spec && tsc",
"build": "grunt build",
"export-coverage": "nyc report --reporter=text-lcov > lcov.info"
},
"dependencies": {
"clone": "2.x"
},
"devDependencies": {
"@types/node": "^8.9.4",
"coffee-coverage": "^3.0.1",
"coffee-script": "1.x",
"coveralls": "^3.0.3",
"grunt": "^1.0.4",
"grunt-banner": "0.6.x",
"grunt-cli": "^1.2.0",
"grunt-contrib-clean": "1.0.x",
"grunt-contrib-coffee": "^2.1.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-include-replace": "3.2.x",
"grunt-mocha-cli": "^6.0.0",
"grunt-run": "^0.8.1",
"mocha": "^7.2.0",
"nyc": "^15.1.0",
"should": "11.x",
"typescript": "^2.6.1"
}
}

8
node_modules/node-cache/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,8 @@
{
"compilerOptions": {
"outDir": "./test"
},
"include": [
"./_src/**/*"
]
}