mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-20 21:14:45 +00:00
.
This commit is contained in:
parent
a004f0ae58
commit
fc725ba36b
7280 changed files with 19 additions and 1796407 deletions
20
node_modules/map-age-cleaner/dist/index.d.ts
generated
vendored
20
node_modules/map-age-cleaner/dist/index.d.ts
generated
vendored
|
@ -1,20 +0,0 @@
|
|||
interface Entry {
|
||||
[key: string]: any;
|
||||
}
|
||||
interface MaxAgeEntry extends Entry {
|
||||
maxAge: number;
|
||||
}
|
||||
/**
|
||||
* Automatically cleanup the items in the provided `map`. The property of the expiration timestamp should be named `maxAge`.
|
||||
*
|
||||
* @param map - Map instance which should be cleaned up.
|
||||
*/
|
||||
export default function mapAgeCleaner<K = any, V extends MaxAgeEntry = MaxAgeEntry>(map: Map<K, V>): any;
|
||||
/**
|
||||
* Automatically cleanup the items in the provided `map`.
|
||||
*
|
||||
* @param map - Map instance which should be cleaned up.
|
||||
* @param property - Name of the property which olds the expiry timestamp.
|
||||
*/
|
||||
export default function mapAgeCleaner<K = any, V = Entry>(map: Map<K, V>, property: string): any;
|
||||
export {};
|
92
node_modules/map-age-cleaner/dist/index.js
generated
vendored
92
node_modules/map-age-cleaner/dist/index.js
generated
vendored
|
@ -1,92 +0,0 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const p_defer_1 = __importDefault(require("p-defer"));
|
||||
function mapAgeCleaner(map, property = 'maxAge') {
|
||||
let processingKey;
|
||||
let processingTimer;
|
||||
let processingDeferred;
|
||||
const cleanup = () => __awaiter(this, void 0, void 0, function* () {
|
||||
if (processingKey !== undefined) {
|
||||
// If we are already processing an item, we can safely exit
|
||||
return;
|
||||
}
|
||||
const setupTimer = (item) => __awaiter(this, void 0, void 0, function* () {
|
||||
processingDeferred = p_defer_1.default();
|
||||
const delay = item[1][property] - Date.now();
|
||||
if (delay <= 0) {
|
||||
// Remove the item immediately if the delay is equal to or below 0
|
||||
map.delete(item[0]);
|
||||
processingDeferred.resolve();
|
||||
return;
|
||||
}
|
||||
// Keep track of the current processed key
|
||||
processingKey = item[0];
|
||||
processingTimer = setTimeout(() => {
|
||||
// Remove the item when the timeout fires
|
||||
map.delete(item[0]);
|
||||
if (processingDeferred) {
|
||||
processingDeferred.resolve();
|
||||
}
|
||||
}, delay);
|
||||
// tslint:disable-next-line:strict-type-predicates
|
||||
if (typeof processingTimer.unref === 'function') {
|
||||
// Don't hold up the process from exiting
|
||||
processingTimer.unref();
|
||||
}
|
||||
return processingDeferred.promise;
|
||||
});
|
||||
try {
|
||||
for (const entry of map) {
|
||||
yield setupTimer(entry);
|
||||
}
|
||||
}
|
||||
catch (_a) {
|
||||
// Do nothing if an error occurs, this means the timer was cleaned up and we should stop processing
|
||||
}
|
||||
processingKey = undefined;
|
||||
});
|
||||
const reset = () => {
|
||||
processingKey = undefined;
|
||||
if (processingTimer !== undefined) {
|
||||
clearTimeout(processingTimer);
|
||||
processingTimer = undefined;
|
||||
}
|
||||
if (processingDeferred !== undefined) { // tslint:disable-line:early-exit
|
||||
processingDeferred.reject(undefined);
|
||||
processingDeferred = undefined;
|
||||
}
|
||||
};
|
||||
const originalSet = map.set.bind(map);
|
||||
map.set = (key, value) => {
|
||||
if (map.has(key)) {
|
||||
// If the key already exist, remove it so we can add it back at the end of the map.
|
||||
map.delete(key);
|
||||
}
|
||||
// Call the original `map.set`
|
||||
const result = originalSet(key, value);
|
||||
// If we are already processing a key and the key added is the current processed key, stop processing it
|
||||
if (processingKey && processingKey === key) {
|
||||
reset();
|
||||
}
|
||||
// Always run the cleanup method in case it wasn't started yet
|
||||
cleanup(); // tslint:disable-line:no-floating-promises
|
||||
return result;
|
||||
};
|
||||
cleanup(); // tslint:disable-line:no-floating-promises
|
||||
return map;
|
||||
}
|
||||
exports.default = mapAgeCleaner;
|
||||
// Add support for CJS
|
||||
module.exports = mapAgeCleaner;
|
||||
module.exports.default = mapAgeCleaner;
|
9
node_modules/map-age-cleaner/license
generated
vendored
9
node_modules/map-age-cleaner/license
generated
vendored
|
@ -1,9 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sam Verschueren <sam.verschueren@gmail.com> (github.com/SamVerschueren)
|
||||
|
||||
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.
|
95
node_modules/map-age-cleaner/package.json
generated
vendored
95
node_modules/map-age-cleaner/package.json
generated
vendored
|
@ -1,95 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"map-age-cleaner@0.1.3",
|
||||
"/Users/eric/repos/actions/setup-node"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "map-age-cleaner@0.1.3",
|
||||
"_id": "map-age-cleaner@0.1.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==",
|
||||
"_location": "/map-age-cleaner",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "map-age-cleaner@0.1.3",
|
||||
"name": "map-age-cleaner",
|
||||
"escapedName": "map-age-cleaner",
|
||||
"rawSpec": "0.1.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.1.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mem"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz",
|
||||
"_spec": "0.1.3",
|
||||
"_where": "/Users/eric/repos/actions/setup-node",
|
||||
"author": {
|
||||
"name": "Sam Verschueren",
|
||||
"email": "sam.verschueren@gmail.com",
|
||||
"url": "github.com/SamVerschueren"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/SamVerschueren/map-age-cleaner/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"p-defer": "^1.0.0"
|
||||
},
|
||||
"description": "Automatically cleanup expired items in a Map",
|
||||
"devDependencies": {
|
||||
"@types/delay": "^2.0.1",
|
||||
"@types/node": "^10.7.1",
|
||||
"ava": "^0.25.0",
|
||||
"codecov": "^3.0.0",
|
||||
"del-cli": "^1.1.0",
|
||||
"delay": "^3.0.0",
|
||||
"nyc": "^12.0.0",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-xo": "^0.9.0",
|
||||
"typescript": "^3.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"dist/index.js",
|
||||
"dist/index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/SamVerschueren/map-age-cleaner#readme",
|
||||
"keywords": [
|
||||
"map",
|
||||
"age",
|
||||
"cleaner",
|
||||
"maxage",
|
||||
"expire",
|
||||
"expiration",
|
||||
"expiring"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"name": "map-age-cleaner",
|
||||
"nyc": {
|
||||
"exclude": [
|
||||
"dist/test.js"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/SamVerschueren/map-age-cleaner.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run clean && tsc",
|
||||
"clean": "del-cli dist",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"prepublishOnly": "npm run build",
|
||||
"pretest": "npm run build -- --sourceMap",
|
||||
"test": "npm run lint && nyc ava dist/test.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"typings": "dist/index.d.ts",
|
||||
"version": "0.1.3"
|
||||
}
|
67
node_modules/map-age-cleaner/readme.md
generated
vendored
67
node_modules/map-age-cleaner/readme.md
generated
vendored
|
@ -1,67 +0,0 @@
|
|||
# map-age-cleaner
|
||||
|
||||
[](https://travis-ci.org/SamVerschueren/map-age-cleaner) [](https://codecov.io/gh/SamVerschueren/map-age-cleaner?branch=master)
|
||||
|
||||
> Automatically cleanup expired items in a Map
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install map-age-cleaner
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import mapAgeCleaner from 'map-age-cleaner';
|
||||
|
||||
const map = new Map([
|
||||
['unicorn', {data: '🦄', maxAge: Date.now() + 1000}]
|
||||
]);
|
||||
|
||||
mapAgeCleaner(map);
|
||||
|
||||
map.has('unicorn');
|
||||
//=> true
|
||||
|
||||
// Wait for 1 second...
|
||||
|
||||
map.has('unicorn');
|
||||
//=> false
|
||||
```
|
||||
|
||||
> **Note**: Items have to be ordered ascending based on the expiry property. This means that the item which will be expired first, should be in the first position of the `Map`.
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### mapAgeCleaner(map, [property])
|
||||
|
||||
Returns the `Map` instance.
|
||||
|
||||
#### map
|
||||
|
||||
Type: `Map`
|
||||
|
||||
Map instance which should be cleaned up.
|
||||
|
||||
#### property
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `maxAge`
|
||||
|
||||
Name of the property which olds the expiry timestamp.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [expiry-map](https://github.com/SamVerschueren/expiry-map) - A `Map` implementation with expirable items
|
||||
- [expiry-set](https://github.com/SamVerschueren/expiry-set) - A `Set` implementation with expirable keys
|
||||
- [mem](https://github.com/sindresorhus/mem) - Memoize functions
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sam Verschueren](https://github.com/SamVerschueren)
|
Loading…
Add table
Add a link
Reference in a new issue