This commit is contained in:
2026-03-03 15:23:00 +00:00
parent 5e3726de39
commit 8e223bfbec
3689 changed files with 955330 additions and 1011 deletions

10
node_modules/@hapi/teamwork/LICENSE.md generated vendored Executable file
View File

@@ -0,0 +1,10 @@
Copyright (c) 2015-2022, Project contributors
Copyright (c) 2015-2020, Sideway Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

16
node_modules/@hapi/teamwork/README.md generated vendored Executable file
View File

@@ -0,0 +1,16 @@
<a href="http://hapijs.com"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
# @hapi/teamwork
#### Wait for multiple callbacks
**teamwork** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) they work even better together.
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
## Useful resources
- [Version status](https://hapi.dev/resources/status/#teamwork) (builds, dependencies, node versions, licenses, eol)
- [Changelog](https://hapi.dev/family/teamwork/changelog/)
- [Project policies](https://hapi.dev/policies/)
- [Free and commercial support options](https://hapi.dev/support/)

95
node_modules/@hapi/teamwork/lib/index.d.ts generated vendored Executable file
View File

@@ -0,0 +1,95 @@
/**
* Team bridges between callbacks and promises. Used to convert callback-based
* interfaces to a promise-based result including support for collecting multiple
* callback events into a single promise.
*/
export class Team<Results extends any | any[] = void> {
/**
* Start a new team work.
*
* @param options Configuration of the team work.
*/
constructor(options?: Team.Options);
/**
* Resulting work when all the meetings are done.
*/
work: Promise<Results>;
/**
* Attend a single meeting.
*
* @param note An optional note that will be included in the work's results. If an error is provided, the work will be immediately rejected with that error.
*/
attend(note?: Error | Team.ElementOf<Results>): void;
/**
* Wait for the current work to be done and start another team work.
*
* @param options New configuration of the team work.
*
* @returns a promise that resolves when the current work is done.
*/
regroup(options?: Team.Options) : Promise<void>;
}
export namespace Team {
/**
* Configuration of the team work.
*/
export interface Options {
/**
* Number of meetings this team should attend before delivering work.
*
* @default 1
*/
readonly meetings?: number | undefined;
/**
* Throws when the team attends more than the expected number of `meetings`,
* or if scheduling an empty meeting.
*
* @default false
*/
readonly strict?: boolean | undefined;
}
type ElementOf<T> = T extends (infer E)[] ? E : T;
}
/**
* Events emitter via an async iterator interface.
*/
export class Events<T> {
/**
* Returns a standard async iterator interface object.
*
* @returns async iterator interface object.
*/
iterator(): Events.Iterator<T>;
/**
* Emits an event to be consumed via the iterator.
*
* @param value
*/
emit(value: T): void;
/**
* Informs the iterator that no new events will be emitted.
*/
end(): void;
}
export namespace Events {
class Iterator<T> implements AsyncIterator<T> {
constructor(events: Events<T>);
[Symbol.asyncIterator](): AsyncIterator<T>;
next(): Promise<IteratorResult<T>>;
}
}

203
node_modules/@hapi/teamwork/lib/index.js generated vendored Executable file
View File

@@ -0,0 +1,203 @@
'use strict';
const internals = {};
exports.Team = class {
#meetings = null;
#count = null;
#notes = null;
#done = false;
#strict = false;
constructor(options) {
this._init(options);
}
static _notes(instance) {
return instance.#notes;
}
_init(options = {}) {
this.work = new Promise((resolve, reject) => {
this._resolve = resolve;
this._reject = reject;
});
const meetings = options.meetings ?? 1;
const strict = !!options.strict;
if (!Number.isInteger(meetings) || meetings <= 0) {
if (meetings === 0 && !strict) {
return this._finalize(null, null);
}
throw new Error('Invalid meetings value');
}
this.#meetings = meetings;
this.#count = meetings;
this.#notes = [];
this.#done = false;
this.#strict = strict;
}
_finalize(err, note) {
this.#done = true;
this.#notes = null;
if (err) {
this._reject(err);
}
else {
this._resolve(note);
}
}
attend(note) {
if (this.#done) {
if (this.#strict) {
throw new Error('Unscheduled meeting');
}
// else ignore
return;
}
if (note instanceof Error) {
return this._finalize(note);
}
this.#notes.push(note);
if (--this.#count) {
return;
}
this._finalize(null, this.#meetings === 1 ? this.#notes[0] : this.#notes);
}
async regroup(options) {
try {
await this.work;
}
catch {}
this._init(options);
}
};
exports.Events = class {
#iterators = new Set();
static _iterators(instance) {
return instance.#iterators;
}
static isIterator(iterator) {
return iterator instanceof internals.EventsIterator;
}
iterator() {
const iterator = new internals.EventsIterator(this);
this.#iterators.add(iterator);
return iterator;
}
emit(value) {
for (const iterator of this.#iterators) {
iterator._queue({ value, done: false });
}
}
end() {
for (const iterator of this.#iterators) {
iterator._queue({ done: true });
}
}
_remove(iterator) {
this.#iterators.delete(iterator);
}
};
internals.EventsIterator = class {
#events;
#pending = null;
#queue = [];
constructor(events) {
this.#events = events;
}
[Symbol.asyncIterator]() {
return this;
}
next() {
if (this.#queue.length) {
return Promise.resolve(this.#queue.shift());
}
if (!this.#events) {
return { done: true };
}
this.#pending = new exports.Team();
return this.#pending.work;
}
return() {
this._cleanup();
return { done: true };
}
_cleanup() {
this.#events?._remove(this);
this.#events = null;
}
_queue(item) {
if (item.done) {
this._cleanup();
}
if (this.#pending) {
this.#pending.attend(item);
this.#pending = null;
}
else {
this.#queue.push(item);
}
}
};

36
node_modules/@hapi/teamwork/package.json generated vendored Executable file
View File

@@ -0,0 +1,36 @@
{
"name": "@hapi/teamwork",
"description": "Wait for multiple callback",
"version": "6.0.1",
"repository": "git://github.com/hapijs/teamwork",
"main": "lib/index.js",
"files": [
"lib"
],
"keywords": [
"async",
"flow control",
"callback"
],
"types": "lib/index.d.ts",
"engines": {
"node": ">=14.0.0"
},
"eslintConfig": {
"extends": [
"plugin:@hapi/module"
]
},
"devDependencies": {
"@hapi/code": "^9.0.0",
"@hapi/eslint-plugin": "^6.0.0",
"@hapi/lab": "^25.0.0",
"@types/node": "^17.0.31",
"typescript": "^4.6.4"
},
"scripts": {
"test": "lab -a @hapi/code -t 100 -L -Y",
"test-cov-html": "lab -a @hapi/code -r html -o coverage.html"
},
"license": "BSD-3-Clause"
}