Fix dependabot issues

This commit is contained in:
Andrew Eisenberg 2021-10-21 15:24:20 -07:00
parent c89d9bd8b0
commit 531c6ba7c8
705 changed files with 53406 additions and 20466 deletions

118
node_modules/mem/dist/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,118 @@
declare type AnyFunction = (...arguments_: any) => any;
interface CacheStorageContent<ValueType> {
data: ValueType;
maxAge: number;
}
interface CacheStorage<KeyType, ValueType> {
has: (key: KeyType) => boolean;
get: (key: KeyType) => CacheStorageContent<ValueType> | undefined;
set: (key: KeyType, value: CacheStorageContent<ValueType>) => void;
delete: (key: KeyType) => void;
clear?: () => void;
}
interface Options<FunctionToMemoize extends AnyFunction, CacheKeyType> {
/**
Milliseconds until the cache expires.
@default Infinity
*/
readonly maxAge?: number;
/**
Determines the cache key for storing the result based on the function arguments. By default, __only the first argument is considered__ and it only works with [primitives](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
A `cacheKey` function can return any type supported by `Map` (or whatever structure you use in the `cache` option).
You can have it cache **all** the arguments by value with `JSON.stringify`, if they are compatible:
```
import mem = require('mem');
mem(function_, {cacheKey: JSON.stringify});
```
Or you can use a more full-featured serializer like [serialize-javascript](https://github.com/yahoo/serialize-javascript) to add support for `RegExp`, `Date` and so on.
```
import mem = require('mem');
import serializeJavascript = require('serialize-javascript');
mem(function_, {cacheKey: serializeJavascript});
```
@default arguments_ => arguments_[0]
@example arguments_ => JSON.stringify(arguments_)
*/
readonly cacheKey?: (arguments_: Parameters<FunctionToMemoize>) => CacheKeyType;
/**
Use a different cache storage. Must implement the following methods: `.has(key)`, `.get(key)`, `.set(key, value)`, `.delete(key)`, and optionally `.clear()`. You could for example use a `WeakMap` instead or [`quick-lru`](https://github.com/sindresorhus/quick-lru) for a LRU cache.
@default new Map()
@example new WeakMap()
*/
readonly cache?: CacheStorage<CacheKeyType, ReturnType<FunctionToMemoize>>;
}
/**
[Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input.
@param fn - Function to be memoized.
@example
```
import mem = require('mem');
let i = 0;
const counter = () => ++i;
const memoized = mem(counter);
memoized('foo');
//=> 1
// Cached as it's the same arguments
memoized('foo');
//=> 1
// Not cached anymore as the arguments changed
memoized('bar');
//=> 2
memoized('bar');
//=> 2
```
*/
declare const mem: {
<FunctionToMemoize extends AnyFunction, CacheKeyType>(fn: FunctionToMemoize, { cacheKey, cache, maxAge }?: Options<FunctionToMemoize, CacheKeyType>): FunctionToMemoize;
/**
@returns A [decorator](https://github.com/tc39/proposal-decorators) to memoize class methods or static class methods.
@example
```
import mem = require('mem');
class Example {
index = 0
@mem.decorator()
counter() {
return ++this.index;
}
}
class ExampleWithOptions {
index = 0
@mem.decorator({maxAge: 1000})
counter() {
return ++this.index;
}
}
```
*/
decorator<FunctionToMemoize_1 extends AnyFunction, CacheKeyType_1>(options?: Options<FunctionToMemoize_1, CacheKeyType_1>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
/**
Clear all cached data of a memoized function.
@param fn - Memoized function.
*/
clear(fn: AnyFunction): void;
};
export = mem;

116
node_modules/mem/dist/index.js generated vendored Normal file
View file

@ -0,0 +1,116 @@
'use strict';
const mimicFn = require("mimic-fn");
const mapAgeCleaner = require("map-age-cleaner");
const decoratorInstanceMap = new WeakMap();
const cacheStore = new WeakMap();
/**
[Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input.
@param fn - Function to be memoized.
@example
```
import mem = require('mem');
let i = 0;
const counter = () => ++i;
const memoized = mem(counter);
memoized('foo');
//=> 1
// Cached as it's the same arguments
memoized('foo');
//=> 1
// Not cached anymore as the arguments changed
memoized('bar');
//=> 2
memoized('bar');
//=> 2
```
*/
const mem = (fn, { cacheKey, cache = new Map(), maxAge } = {}) => {
if (typeof maxAge === 'number') {
// TODO: Drop after https://github.com/SamVerschueren/map-age-cleaner/issues/5
// @ts-expect-error
mapAgeCleaner(cache);
}
const memoized = function (...arguments_) {
const key = cacheKey ? cacheKey(arguments_) : arguments_[0];
const cacheItem = cache.get(key);
if (cacheItem) {
return cacheItem.data;
}
const result = fn.apply(this, arguments_);
cache.set(key, {
data: result,
maxAge: maxAge ? Date.now() + maxAge : Number.POSITIVE_INFINITY
});
return result;
};
mimicFn(memoized, fn, {
ignoreNonConfigurable: true
});
cacheStore.set(memoized, cache);
return memoized;
};
/**
@returns A [decorator](https://github.com/tc39/proposal-decorators) to memoize class methods or static class methods.
@example
```
import mem = require('mem');
class Example {
index = 0
@mem.decorator()
counter() {
return ++this.index;
}
}
class ExampleWithOptions {
index = 0
@mem.decorator({maxAge: 1000})
counter() {
return ++this.index;
}
}
```
*/
mem.decorator = (options = {}) => (target, propertyKey, descriptor) => {
const input = target[propertyKey];
if (typeof input !== 'function') {
throw new TypeError('The decorated value must be a function');
}
delete descriptor.value;
delete descriptor.writable;
descriptor.get = function () {
if (!decoratorInstanceMap.has(this)) {
const value = mem(input, options);
decoratorInstanceMap.set(this, value);
return value;
}
return decoratorInstanceMap.get(this);
};
};
/**
Clear all cached data of a memoized function.
@param fn - Memoized function.
*/
mem.clear = (fn) => {
const cache = cacheStore.get(fn);
if (!cache) {
throw new TypeError('Can\'t clear a function that was not memoized!');
}
if (typeof cache.clear !== 'function') {
throw new TypeError('The cache Map can\'t be cleared!');
}
cache.clear();
};
module.exports = mem;

108
node_modules/mem/index.d.ts generated vendored
View file

@ -1,108 +0,0 @@
declare namespace mem {
interface CacheStorage<KeyType, ValueType> {
has(key: KeyType): boolean;
get(key: KeyType): ValueType | undefined;
set(key: KeyType, value: ValueType): void;
delete(key: KeyType): void;
clear?: () => void;
}
interface Options<
ArgumentsType extends unknown[],
CacheKeyType,
ReturnType
> {
/**
Milliseconds until the cache expires.
@default Infinity
*/
readonly maxAge?: number;
/**
Determines the cache key for storing the result based on the function arguments. By default, __only the first argument is considered__ and it only works with [primitives](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
A `cacheKey` function can return any type supported by `Map` (or whatever structure you use in the `cache` option).
You can have it cache **all** the arguments by value with `JSON.stringify`, if they are compatible:
```
import mem = require('mem');
mem(function_, {cacheKey: JSON.stringify});
```
Or you can use a more full-featured serializer like [serialize-javascript](https://github.com/yahoo/serialize-javascript) to add support for `RegExp`, `Date` and so on.
```
import mem = require('mem');
import serializeJavascript = require('serialize-javascript');
mem(function_, {cacheKey: serializeJavascript});
```
@default arguments_ => arguments_[0]
@example arguments_ => JSON.stringify(arguments_)
*/
readonly cacheKey?: (arguments: ArgumentsType) => CacheKeyType;
/**
Use a different cache storage. Must implement the following methods: `.has(key)`, `.get(key)`, `.set(key, value)`, `.delete(key)`, and optionally `.clear()`. You could for example use a `WeakMap` instead or [`quick-lru`](https://github.com/sindresorhus/quick-lru) for a LRU cache.
@default new Map()
@example new WeakMap()
*/
readonly cache?: CacheStorage<CacheKeyType, {data: ReturnType; maxAge: number}>;
}
}
declare const mem: {
/**
[Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input.
@param fn - Function to be memoized.
@example
```
import mem = require('mem');
let i = 0;
const counter = () => ++i;
const memoized = mem(counter);
memoized('foo');
//=> 1
// Cached as it's the same arguments
memoized('foo');
//=> 1
// Not cached anymore as the arguments changed
memoized('bar');
//=> 2
memoized('bar');
//=> 2
```
*/
<
ArgumentsType extends unknown[],
ReturnType,
CacheKeyType,
FunctionToMemoize = (...arguments: ArgumentsType) => ReturnType
>(
fn: FunctionToMemoize,
options?: mem.Options<ArgumentsType, CacheKeyType, ReturnType>
): FunctionToMemoize;
/**
Clear all cached data of a memoized function.
@param fn - Memoized function.
*/
clear<ArgumentsType extends unknown[], ReturnType>(
fn: (...arguments: ArgumentsType) => ReturnType
): void;
};
export = mem;

64
node_modules/mem/index.js generated vendored
View file

@ -1,64 +0,0 @@
'use strict';
const mimicFn = require('mimic-fn');
const mapAgeCleaner = require('map-age-cleaner');
const cacheStore = new WeakMap();
const mem = (fn, options = {}) => {
// Automatically use WeakMap unless the user provided their own cache
const weakCache = options.cache || new WeakMap();
const {
cacheKey = ([firstArgument]) => firstArgument,
cache = new Map(),
maxAge
} = options;
if (typeof maxAge === 'number') {
mapAgeCleaner(cache);
}
const memoized = function (...arguments_) {
const key = cacheKey(arguments_);
// Prefer WeakMap if the key allows it
const bestCache = key && (typeof key === 'object' || typeof key === 'function') ?
weakCache :
cache;
if (bestCache.has(key)) {
return bestCache.get(key).data;
}
const cacheItem = fn.apply(this, arguments_);
bestCache.set(key, {
data: cacheItem,
maxAge: maxAge ? Date.now() + maxAge : Infinity
});
return cacheItem;
};
try {
// The below call will throw in some host environments
// See https://github.com/sindresorhus/mimic-fn/issues/10
mimicFn(memoized, fn);
} catch (_) {}
cacheStore.set(memoized, cache);
return memoized;
};
module.exports = mem;
module.exports.clear = fn => {
if (!cacheStore.has(fn)) {
throw new Error('Can\'t clear a function that was not memoized!');
}
const cache = cacheStore.get(fn);
if (typeof cache.clear === 'function') {
cache.clear();
}
};

2
node_modules/mem/license generated vendored
View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://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:

View file

@ -7,6 +7,11 @@ const copyProperty = (to, from, property, ignoreNonConfigurable) => {
return;
}
// `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
if (property === 'arguments' || property === 'caller') {
return;
}
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);

View file

@ -1,6 +1,6 @@
{
"name": "mimic-fn",
"version": "3.0.0",
"version": "3.1.0",
"description": "Make a function mimic another one",
"license": "MIT",
"repository": "sindresorhus/mimic-fn",

52
node_modules/mem/package.json generated vendored
View file

@ -1,23 +1,28 @@
{
"name": "mem",
"version": "6.1.0",
"version": "8.1.1",
"description": "Memoize functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input",
"license": "MIT",
"repository": "sindresorhus/mem",
"funding": "https://github.com/sindresorhus/mem?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=8"
"node": ">=10"
},
"scripts": {
"test": "xo && ava && tsd"
"test": "xo && npm run build && tsd && ava",
"build": "del-cli dist && tsc",
"prepack": "npm run build"
},
"main": "dist",
"types": "dist/index.d.ts",
"files": [
"index.js",
"index.d.ts"
"dist/index.js",
"dist/index.d.ts"
],
"keywords": [
"memoize",
@ -34,13 +39,36 @@
],
"dependencies": {
"map-age-cleaner": "^0.1.3",
"mimic-fn": "^3.0.0"
"mimic-fn": "^3.1.0"
},
"devDependencies": {
"ava": "^2.4.0",
"delay": "^4.1.0",
"serialize-javascript": "^2.1.0",
"tsd": "^0.11.0",
"xo": "^0.25.3"
"@ava/typescript": "^1.1.1",
"@sindresorhus/tsconfig": "^0.7.0",
"@types/serialize-javascript": "^4.0.0",
"ava": "^3.15.0",
"del-cli": "^3.0.1",
"delay": "^4.4.0",
"serialize-javascript": "^5.0.1",
"tsd": "^0.13.1",
"typescript": "^4.0.3",
"xo": "^0.38.2"
},
"ava": {
"files": [
"test.ts"
],
"timeout": "1m",
"typescript": {
"rewritePaths": {
"./": "dist/"
}
}
},
"xo": {
"rules": {
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
}

62
node_modules/mem/readme.md generated vendored
View file

@ -1,4 +1,4 @@
# mem [![Build Status](https://travis-ci.org/sindresorhus/mem.svg?branch=master)](https://travis-ci.org/sindresorhus/mem)
# mem
> [Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input
@ -6,14 +6,12 @@ Memory is automatically released when an item expires or the cache is cleared.
By default, **only the first argument is considered** and it only works with [primitives](https://developer.mozilla.org/en-US/docs/Glossary/Primitive). If you need to cache multiple arguments or cache `object`s *by value*, have a look at alternative [caching strategies](#caching-strategy) below.
## Install
```
$ npm install mem
```
## Usage
```js
@ -69,15 +67,15 @@ const delay = require('delay');
const memGot = mem(got, {maxAge: 1000});
(async () => {
await memGot('sindresorhus.com');
await memGot('https://sindresorhus.com');
// This call is cached
await memGot('sindresorhus.com');
await memGot('https://sindresorhus.com');
await delay(2000);
// This call is not cached as the cache has expired
await memGot('sindresorhus.com');
await memGot('https://sindresorhus.com');
})();
```
@ -156,7 +154,6 @@ addOneListener(mainContent, 'load', console.log); // `addListener` is run, and i
Better yet, if your functions arguments are compatible with `WeakMap`, you should use [`deep-weak-map`](https://github.com/futpib/deep-weak-map) instead of `many-keys-map`. This will help avoid memory leaks.
## API
### mem(fn, options?)
@ -193,12 +190,50 @@ Refer to the [caching strategies](#caching-strategy) section for more informatio
##### cache
Type: `object`\
Default: `new Map()`, but it also intelligently uses `new WeakMap()` whenevever possible
Default: `new Map()`
Use a different cache storage. Must implement the following methods: `.has(key)`, `.get(key)`, `.set(key, value)`, `.delete(key)`, and optionally `.clear()`. You could for example use [`quick-lru`](https://github.com/sindresorhus/quick-lru) for a LRU cache.
Use a different cache storage. Must implement the following methods: `.has(key)`, `.get(key)`, `.set(key, value)`, `.delete(key)`, and optionally `.clear()`. You could for example use a `WeakMap` instead or [`quick-lru`](https://github.com/sindresorhus/quick-lru) for a LRU cache.
Refer to the [caching strategies](#caching-strategy) section for more information.
### mem.decorator(options)
Returns a [decorator](https://github.com/tc39/proposal-decorators) to memoize class methods or static class methods.
Notes:
- Only class methods and getters/setters can be memoized, not regular functions (they aren't part of the proposal);
- Only [TypeScripts decorators](https://www.typescriptlang.org/docs/handbook/decorators.html#parameter-decorators) are supported, not [Babels](https://babeljs.io/docs/en/babel-plugin-proposal-decorators), which use a different version of the proposal;
- Being an experimental feature, they need to be enabled with `--experimentalDecorators`; follow TypeScripts docs.
#### options
Type: `object`
Same as options for `mem()`.
```ts
import mem = require('mem');
class Example {
index = 0
@mem.decorator()
counter() {
return ++this.index;
}
}
class ExampleWithOptions {
index = 0
@mem.decorator({maxAge: 1000})
counter() {
return ++this.index;
}
}
```
### mem.clear(fn)
Clear all cached data of a memoized function.
@ -209,7 +244,6 @@ Type: `Function`
Memoized function.
## Tips
### Cache statistics
@ -227,21 +261,19 @@ const cache = new StatsMap();
const memGot = mem(got, {cache});
(async () => {
await memGot('sindresorhus.com');
await memGot('sindresorhus.com');
await memGot('sindresorhus.com');
await memGot('https://sindresorhus.com');
await memGot('https://sindresorhus.com');
await memGot('https://sindresorhus.com');
console.log(cache.stats);
//=> {hits: 2, misses: 1}
})();
```
## Related
- [p-memoize](https://github.com/sindresorhus/p-memoize) - Memoize promise-returning & async functions
---
<div align="center">