initial commit of actions

This commit is contained in:
2026-01-31 18:56:04 +01:00
commit 949ece5785
44660 changed files with 12034344 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
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;
}
export 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 from '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 from 'mem';
import serializeJavascript from '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 from 'mem';
let index = 0;
const counter = () => ++index;
const memoized = mem(counter);
memoized('foo');
//=> 1
// Cached as it's the same argument
memoized('foo');
//=> 1
// Not cached anymore as the arguments changed
memoized('bar');
//=> 2
memoized('bar');
//=> 2
```
*/
export default function 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 {memDecorator} from 'mem';
class Example {
index = 0
@memDecorator()
counter() {
return ++this.index;
}
}
class ExampleWithOptions {
index = 0
@memDecorator({maxAge: 1000})
counter() {
return ++this.index;
}
}
```
*/
export declare function memDecorator<FunctionToMemoize extends AnyFunction, CacheKeyType>(options?: Options<FunctionToMemoize, CacheKeyType>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
/**
Clear all cached data of a memoized function.
@param fn - Memoized function.
*/
export declare function memClear(fn: AnyFunction): void;
export {};

114
github/codeql-action-v2/node_modules/mem/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,114 @@
import mimicFn from 'mimic-fn';
import mapAgeCleaner from 'map-age-cleaner';
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 from 'mem';
let index = 0;
const counter = () => ++index;
const memoized = mem(counter);
memoized('foo');
//=> 1
// Cached as it's the same argument
memoized('foo');
//=> 1
// Not cached anymore as the arguments changed
memoized('bar');
//=> 2
memoized('bar');
//=> 2
```
*/
export default function mem(fn, { cacheKey, cache = new Map(), maxAge, } = {}) {
if (typeof maxAge === 'number') {
mapAgeCleaner(cache);
}
const memoized = function (...arguments_) {
const key = cacheKey ? cacheKey(arguments_) : arguments_[0];
const cacheItem = cache.get(key);
if (cacheItem) {
return cacheItem.data; // eslint-disable-line @typescript-eslint/no-unsafe-return
}
const result = fn.apply(this, arguments_);
cache.set(key, {
data: result,
maxAge: maxAge ? Date.now() + maxAge : Number.POSITIVE_INFINITY,
});
return result; // eslint-disable-line @typescript-eslint/no-unsafe-return
};
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 {memDecorator} from 'mem';
class Example {
index = 0
@memDecorator()
counter() {
return ++this.index;
}
}
class ExampleWithOptions {
index = 0
@memDecorator({maxAge: 1000})
counter() {
return ++this.index;
}
}
```
*/
export function memDecorator(options = {}) {
const instanceMap = new WeakMap();
return (target, propertyKey, descriptor) => {
const input = target[propertyKey]; // eslint-disable-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
if (typeof input !== 'function') {
throw new TypeError('The decorated value must be a function');
}
delete descriptor.value;
delete descriptor.writable;
descriptor.get = function () {
if (!instanceMap.has(this)) {
const value = mem(input, options);
instanceMap.set(this, value);
return value;
}
return instanceMap.get(this);
};
};
}
/**
Clear all cached data of a memoized function.
@param fn - Memoized function.
*/
export function memClear(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();
}

9
github/codeql-action-v2/node_modules/mem/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
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:
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.

76
github/codeql-action-v2/node_modules/mem/package.json generated vendored Normal file
View File

@@ -0,0 +1,76 @@
{
"name": "mem",
"version": "9.0.2",
"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": "https://sindresorhus.com"
},
"type": "module",
"exports": "./dist/index.js",
"engines": {
"node": ">=12.20"
},
"scripts": {
"test": "xo && ava && npm run build && tsd",
"build": "del-cli dist && tsc",
"prepack": "npm run build"
},
"types": "dist/index.d.ts",
"files": [
"dist"
],
"keywords": [
"memoize",
"function",
"mem",
"memoization",
"cache",
"caching",
"optimize",
"performance",
"ttl",
"expire",
"promise"
],
"dependencies": {
"map-age-cleaner": "^0.1.3",
"mimic-fn": "^4.0.0"
},
"devDependencies": {
"@ava/typescript": "^1.1.1",
"@sindresorhus/tsconfig": "^1.0.2",
"@types/serialize-javascript": "^4.0.0",
"ava": "^3.15.0",
"del-cli": "^3.0.1",
"delay": "^4.4.0",
"serialize-javascript": "^5.0.1",
"ts-node": "^10.1.0",
"tsd": "^0.13.1",
"typescript": "^4.3.5",
"xo": "^0.41.0"
},
"ava": {
"timeout": "1m",
"extensions": {
"ts": "module"
},
"nonSemVerExperiments": {
"configurableModuleFormat": true
},
"nodeArguments": [
"--loader=ts-node/esm"
]
},
"xo": {
"rules": {
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
}

287
github/codeql-action-v2/node_modules/mem/readme.md generated vendored Normal file
View File

@@ -0,0 +1,287 @@
# 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
Memory is automatically released when an item expires or the cache is cleared.
<!-- Please keep this section in sync with https://github.com/sindresorhus/p-memoize/blob/main/readme.md -->
By default, **only the memoized function's first argument is considered** via strict equality comparison. If you need to cache multiple arguments or cache `object`s *by value*, have a look at alternative [caching strategies](#caching-strategy) below.
If you want to memoize Promise-returning functions (like `async` functions), you might be better served by [p-memoize](https://github.com/sindresorhus/p-memoize).
## Install
```
$ npm install mem
```
## Usage
```js
import mem from 'mem';
let index = 0;
const counter = () => ++index;
const memoized = mem(counter);
memoized('foo');
//=> 1
// Cached as it's the same argument
memoized('foo');
//=> 1
// Not cached anymore as the argument changed
memoized('bar');
//=> 2
memoized('bar');
//=> 2
// Only the first argument is considered by default
memoized('bar', 'foo');
//=> 2
```
##### Works well with Promise-returning functions
But you might want to use [p-memoize](https://github.com/sindresorhus/p-memoize) for more Promise-specific behaviors.
```js
import mem from 'mem';
let index = 0;
const counter = async () => ++index;
const memoized = mem(counter);
console.log(await memoized());
//=> 1
// The return value didn't increase as it's cached
console.log(await memoized());
//=> 1
```
```js
import mem from 'mem';
import got from 'got';
import delay from 'delay';
const memGot = mem(got, {maxAge: 1000});
await memGot('https://sindresorhus.com');
// This call is cached
await memGot('https://sindresorhus.com');
await delay(2000);
// This call is not cached as the cache has expired
await memGot('https://sindresorhus.com');
```
### Caching strategy
By default, only the first argument is compared via exact equality (`===`) to determine whether a call is identical.
```js
const power = mem((a, b) => Math.power(a, b));
power(2, 2); // => 4, stored in cache with the key 2 (number)
power(2, 3); // => 4, retrieved from cache at key 2 (number), it's wrong
```
You will have to use the `cache` and `cacheKey` options appropriate to your function. In this specific case, the following could work:
```js
const power = mem((a, b) => Math.power(a, b), {
cacheKey: arguments_ => arguments_.join(',')
});
power(2, 2); // => 4, stored in cache with the key '2,2' (both arguments as one string)
power(2, 3); // => 8, stored in cache with the key '2,3'
```
More advanced examples follow.
#### Example: Options-like argument
If your function accepts an object, it won't be memoized out of the box:
```js
const heavyMemoizedOperation = mem(heavyOperation);
heavyMemoizedOperation({full: true}); // Stored in cache with the object as key
heavyMemoizedOperation({full: true}); // Stored in cache with the object as key, again
// The objects look the same but for JS they're two different objects
```
You might want to serialize or hash them, for example using `JSON.stringify` or something like [serialize-javascript](https://github.com/yahoo/serialize-javascript), which can also serialize `RegExp`, `Date` and so on.
```js
const heavyMemoizedOperation = mem(heavyOperation, {cacheKey: JSON.stringify});
heavyMemoizedOperation({full: true}); // Stored in cache with the key '[{"full":true}]' (string)
heavyMemoizedOperation({full: true}); // Retrieved from cache
```
The same solution also works if it accepts multiple serializable objects:
```js
const heavyMemoizedOperation = mem(heavyOperation, {cacheKey: JSON.stringify});
heavyMemoizedOperation('hello', {full: true}); // Stored in cache with the key '["hello",{"full":true}]' (string)
heavyMemoizedOperation('hello', {full: true}); // Retrieved from cache
```
#### Example: Multiple non-serializable arguments
If your function accepts multiple arguments that aren't supported by `JSON.stringify` (e.g. DOM elements and functions), you can instead extend the initial exact equality (`===`) to work on multiple arguments using [`many-keys-map`](https://github.com/fregante/many-keys-map):
```js
import ManyKeysMap from 'many-keys-map';
const addListener = (emitter, eventName, listener) => emitter.on(eventName, listener);
const addOneListener = mem(addListener, {
cacheKey: arguments_ => arguments_, // Use *all* the arguments as key
cache: new ManyKeysMap() // Correctly handles all the arguments for exact equality
});
addOneListener(header, 'click', console.log); // `addListener` is run, and it's cached with the `arguments` array as key
addOneListener(header, 'click', console.log); // `addListener` is not run again
addOneListener(mainContent, 'load', console.log); // `addListener` is run, and it's cached with the `arguments` array as key
```
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?)
#### fn
Type: `Function`
Function to be memoized.
#### options
Type: `object`
##### maxAge
Type: `number`\
Default: `Infinity`
Milliseconds until the cache expires.
##### cacheKey
Type: `Function`\
Default: `arguments_ => arguments_[0]`\
Example: `arguments_ => JSON.stringify(arguments_)`
Determines the cache key for storing the result based on the function arguments. By default, **only the first argument is considered**.
A `cacheKey` function can return any type supported by `Map` (or whatever structure you use in the `cache` option).
Refer to the [caching strategies](#caching-strategy) section for more information.
##### cache
Type: `object`\
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 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.
### memDecorator(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 {memDecorator} from 'mem';
class Example {
index = 0
@memDecorator()
counter() {
return ++this.index;
}
}
class ExampleWithOptions {
index = 0
@memDecorator({maxAge: 1000})
counter() {
return ++this.index;
}
}
```
### memClear(fn)
Clear all cached data of a memoized function.
#### fn
Type: `Function`
Memoized function.
## Tips
### Cache statistics
If you want to know how many times your cache had a hit or a miss, you can make use of [stats-map](https://github.com/SamVerschueren/stats-map) as a replacement for the default cache.
#### Example
```js
import mem from 'mem';
import StatsMap from 'stats-map';
import got from 'got';
const cache = new StatsMap();
const memGot = mem(got, {cache});
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">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-mem?utm_source=npm-mem&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>