This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

8
node_modules/queue/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2014 Jesse Tane <jesse.tane@gmail.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.

173
node_modules/queue/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,173 @@
// Type definitions for Queue 4.5.1
// Project: https://github.com/jessetane/queue
// Definitions by: Alex Miller <https://github.com/codex->
import { EventEmitter } from "events";
export interface Options {
/**
* Max number of jobs the queue should process concurrently.
*
* @default Infinity
*/
concurrency?: number;
/**
* Milliseconds to wait for a job to execute its callback.
*
* @default 0
*/
timeout?: number;
/**
* Ensures the queue is always running if jobs are available. Useful in situations where you are using a queue only for concurrency control.
*
* @default false
*/
autostart?: boolean;
/**
* An array to set job callback arguments on.
*
* @default null
*/
results?: any[];
}
interface Queue extends EventEmitter {
/**
* Max number of jobs the queue should process concurrently.
*/
concurrency: number;
/**
* Milliseconds to wait for a job to execute its callback.
*/
timeout: number;
/**
* Ensures the queue is always running if jobs are available.
*/
autostart: boolean;
/**
* An array to set job callback arguments on.
*/
results: any[] | null;
/**
* Jobs pending + jobs to process.
*/
readonly length: number;
/**
* Adds one or more elements to the end of the Queue and returns the new length of the Queue.
*
* @param workers New workers of the Queue.
*/
push(...workers: QueueWorker[]): number;
/**
* Adds one or more elements to the front of the Queue and returns the new length of the Queue.
*
* @param workers Workers to insert at the start of the Queue.
*/
unshift(...workers: QueueWorker[]): number;
/**
* Adds and/or removes elements from the queue.
*
* @param start The zero-based location in the Queue from which to start removing elements.
* @param deleteCount The number of elements to remove.
*/
splice(start: number, deleteCount?: number): Queue;
/**
* Adds and/or removes elements from the queue.
*
* @param start The zero-based location in the Queue from which to start removing elements.
* @param deleteCount The number of elements to remove.
* @param workers Workers to insert into the Queue in place of the deleted elements.
*/
splice(start: number, deleteCount: number, ...workers: QueueWorker[]): Queue;
/**
* Removes the last element from the Queue and returns that element.
*/
pop(): QueueWorker | undefined;
/**
* Removes the first element from the Queue and returns that element.
*/
shift(): QueueWorker | undefined;
/**
* Extracts a section of the Queue and returns Queue.
*
* @param start The beginning of the specified portion of the Queue.
* @param end The end of the specified portion of the Queue.
*/
slice(start?: number, end?: number): Queue;
/**
* Reverses the order of the elements of the Queue in place.
*/
reverse(): Queue;
/**
* Returns the first (least) index of an element within the Queue equal to the specified value, or -1 if none is found.
*
* @param searchElement The value to locate in the Queue.
* @param fromIndex The Queue index at which to begin the search. If omitted, the search starts at index 0.
*/
indexOf(searchElement: QueueWorker, fromIndex?: number): number;
/**
* Returns the last (greatest) index of an element within the Queue equal to the specified value, or -1 if none is found.
*
* @param searchElement The value to locate in the Queue.
* @param fromIndex The Queue index at which to begin the search. If omitted, the search starts at the last index in the Queue.
*/
lastIndexOf(searchElement: QueueWorker, fromIndex?: number): number;
/**
* Starts the queue.
*
* @param callback Callback to be called when the queue empties or when an error occurs.
*/
start(callback?: (error?: Error) => void): void;
/**
* Stops the queue.
*/
stop(): void;
/**
* Stop and empty the queue immediately.
*
* @param error error of why the stop has occurred, to be passed to start callback if supplied.
*/
end(error?: Error): void;
}
interface QueueConstructor {
(options?: Options): Queue;
new (options?: Options): Queue;
}
declare const Queue: QueueConstructor;
export default Queue;
export interface QueueWorker {
(callback?: QueueWorkerCallback): void;
/**
* Override queue timeout.
*/
timeout?: number;
}
export interface QueueWorkerCallback {
(error?: Error, data?: Object): void;
}

195
node_modules/queue/index.js generated vendored Normal file
View File

@@ -0,0 +1,195 @@
var inherits = require('inherits')
var EventEmitter = require('events').EventEmitter
module.exports = Queue
module.exports.default = Queue
function Queue (options) {
if (!(this instanceof Queue)) {
return new Queue(options)
}
EventEmitter.call(this)
options = options || {}
this.concurrency = options.concurrency || Infinity
this.timeout = options.timeout || 0
this.autostart = options.autostart || false
this.results = options.results || null
this.pending = 0
this.session = 0
this.running = false
this.jobs = []
this.timers = {}
}
inherits(Queue, EventEmitter)
var arrayMethods = [
'pop',
'shift',
'indexOf',
'lastIndexOf'
]
arrayMethods.forEach(function (method) {
Queue.prototype[method] = function () {
return Array.prototype[method].apply(this.jobs, arguments)
}
})
Queue.prototype.slice = function (begin, end) {
this.jobs = this.jobs.slice(begin, end)
return this
}
Queue.prototype.reverse = function () {
this.jobs.reverse()
return this
}
var arrayAddMethods = [
'push',
'unshift',
'splice'
]
arrayAddMethods.forEach(function (method) {
Queue.prototype[method] = function () {
var methodResult = Array.prototype[method].apply(this.jobs, arguments)
if (this.autostart) {
this.start()
}
return methodResult
}
})
Object.defineProperty(Queue.prototype, 'length', {
get: function () {
return this.pending + this.jobs.length
}
})
Queue.prototype.start = function (cb) {
if (cb) {
callOnErrorOrEnd.call(this, cb)
}
this.running = true
if (this.pending >= this.concurrency) {
return
}
if (this.jobs.length === 0) {
if (this.pending === 0) {
done.call(this)
}
return
}
var self = this
var job = this.jobs.shift()
var once = true
var session = this.session
var timeoutId = null
var didTimeout = false
var resultIndex = null
var timeout = job.hasOwnProperty('timeout') ? job.timeout : this.timeout
function next (err, result) {
if (once && self.session === session) {
once = false
self.pending--
if (timeoutId !== null) {
delete self.timers[timeoutId]
clearTimeout(timeoutId)
}
if (err) {
self.emit('error', err, job)
} else if (didTimeout === false) {
if (resultIndex !== null) {
self.results[resultIndex] = Array.prototype.slice.call(arguments, 1)
}
self.emit('success', result, job)
}
if (self.session === session) {
if (self.pending === 0 && self.jobs.length === 0) {
done.call(self)
} else if (self.running) {
self.start()
}
}
}
}
if (timeout) {
timeoutId = setTimeout(function () {
didTimeout = true
if (self.listeners('timeout').length > 0) {
self.emit('timeout', next, job)
} else {
next()
}
}, timeout)
this.timers[timeoutId] = timeoutId
}
if (this.results) {
resultIndex = this.results.length
this.results[resultIndex] = null
}
this.pending++
self.emit('start', job)
var promise = job(next)
if (promise && promise.then && typeof promise.then === 'function') {
promise.then(function (result) {
return next(null, result)
}).catch(function (err) {
return next(err || true)
})
}
if (this.running && this.jobs.length > 0) {
this.start()
}
}
Queue.prototype.stop = function () {
this.running = false
}
Queue.prototype.end = function (err) {
clearTimers.call(this)
this.jobs.length = 0
this.pending = 0
done.call(this, err)
}
function clearTimers () {
for (var key in this.timers) {
var timeoutId = this.timers[key]
delete this.timers[key]
clearTimeout(timeoutId)
}
}
function callOnErrorOrEnd (cb) {
var self = this
this.on('error', onerror)
this.on('end', onend)
function onerror (err) { self.end(err) }
function onend (err) {
self.removeListener('error', onerror)
self.removeListener('end', onend)
cb(err, this.results)
}
}
function done (err) {
this.session++
this.running = false
this.emit('end', err)
}

43
node_modules/queue/package.json generated vendored Normal file
View File

@@ -0,0 +1,43 @@
{
"name": "queue",
"version": "6.0.2",
"description": "asynchronous function queue with adjustable concurrency",
"keywords": [
"queue",
"async",
"asynchronous",
"synchronous",
"job",
"task",
"concurrency",
"concurrent"
],
"files": [
"index.js",
"index.d.ts"
],
"dependencies": {
"inherits": "~2.0.3"
},
"devDependencies": {
"@types/node": "*",
"browserify": "^16.2.3",
"coveralls": "^3.0.3",
"istanbul": "^0.4.5",
"standard": "^12.0.1",
"tape": "^4.10.1",
"tsd-check": "*",
"typescript": "^3.3.3333"
},
"scripts": {
"test": "standard && node test && tsd-check",
"test-browser": "standard && browserify test/index.js > test/bundle.js && echo \"open test/index.html in your browser\"",
"travis": "standard && istanbul cover test --report lcovonly && cat coverage/lcov.info | coveralls",
"travis-ts": "tsc test/typescript.ts --m System --out /dev/null && echo 'TypeScript compilation passed.'",
"example": "node example",
"lint": "standard"
},
"repository": "https://github.com/jessetane/queue.git",
"author": "Jesse Tane <jesse.tane@gmail.com>",
"license": "MIT"
}

221
node_modules/queue/readme.md generated vendored Normal file
View File

@@ -0,0 +1,221 @@
```
____ __ _____ __ _____
/ __ `/ / / / _ \/ / / / _ \
/ /_/ / /_/ / __/ /_/ / __/
\__, /\__,_/\___/\__,_/\___/
/_/
```
Asynchronous function queue with adjustable concurrency.
[![npm](http://img.shields.io/npm/v/queue.svg?style=flat-square)](http://www.npmjs.org/queue)
[![tests](https://img.shields.io/travis/jessetane/queue.svg?style=flat-square&branch=master)](https://travis-ci.org/jessetane/queue)
[![coverage](https://img.shields.io/coveralls/jessetane/queue.svg?style=flat-square&branch=master)](https://coveralls.io/r/jessetane/queue)
This module exports a class `Queue` that implements most of the `Array` API. Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods. Processing begins when you call `q.start()`.
## Example
`npm run example`
``` javascript
var queue = require('../')
var q = queue({ results: [] })
// add jobs using the familiar Array API
q.push(function (cb) {
const result = 'two'
cb(null, result)
})
q.push(
function (cb) {
const result = 'four'
cb(null, result)
},
function (cb) {
const result = 'five'
cb(null, result)
}
)
// jobs can accept a callback or return a promise
q.push(function () {
return new Promise(function (resolve, reject) {
const result = 'one'
resolve(result)
})
})
q.unshift(function (cb) {
const result = 'one'
cb(null, result)
})
q.splice(2, 0, function (cb) {
const result = 'three'
cb(null, result)
})
// use the timeout feature to deal with jobs that
// take too long or forget to execute a callback
q.timeout = 100
q.on('timeout', function (next, job) {
console.log('job timed out:', job.toString().replace(/\n/g, ''))
next()
})
q.push(function (cb) {
setTimeout(function () {
console.log('slow job finished')
cb()
}, 200)
})
q.push(function (cb) {
console.log('forgot to execute callback')
})
// jobs can also override the queue's timeout
// on a per-job basis
function extraSlowJob (cb) {
setTimeout(function () {
console.log('extra slow job finished')
cb()
}, 400)
}
extraSlowJob.timeout = 500
q.push(extraSlowJob)
// jobs can also opt-out of the timeout altogether
function superSlowJob (cb) {
setTimeout(function () {
console.log('super slow job finished')
cb()
}, 1000)
}
superSlowJob.timeout = null
q.push(superSlowJob)
// get notified when jobs complete
q.on('success', function (result, job) {
console.log('job finished processing:', job.toString().replace(/\n/g, ''))
console.log('The result is:', result)
})
// begin processing, get notified on end / failure
q.start(function (err) {
if (err) throw err
console.log('all done:', q.results)
})
```
## Install
`npm install queue`
_Note_: You may need to install the [`events`](https://github.com/Gozala/events) dependency if
your environment does not have it by default (eg. browser, react-native).
## Test
`npm test`
`npm run test-browser`
## API
### `var q = queue([opts])`
Constructor. `opts` may contain inital values for:
* `q.concurrency`
* `q.timeout`
* `q.autostart`
* `q.results`
## Instance methods
### `q.start([cb])`
cb, if passed, will be called when the queue empties or when an error occurs.
### `q.stop()`
Stops the queue. can be resumed with `q.start()`.
### `q.end([err])`
Stop and empty the queue immediately.
## Instance methods mixed in from `Array`
Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array). Note that `slice` does not copy the queue.
### `q.push(element1, ..., elementN)`
### `q.unshift(element1, ..., elementN)`
### `q.splice(index , howMany[, element1[, ...[, elementN]]])`
### `q.pop()`
### `q.shift()`
### `q.slice(begin[, end])`
### `q.reverse()`
### `q.indexOf(searchElement[, fromIndex])`
### `q.lastIndexOf(searchElement[, fromIndex])`
## Properties
### `q.concurrency`
Max number of jobs the queue should process concurrently, defaults to `Infinity`.
### `q.timeout`
Milliseconds to wait for a job to execute its callback. This can be overridden by specifying a `timeout` property on a per-job basis.
### `q.autostart`
Ensures the queue is always running if jobs are available. Useful in situations where you are using a queue only for concurrency control.
### `q.results`
An array to set job callback arguments on.
### `q.length`
Jobs pending + jobs to process (readonly).
## Events
### `q.emit('start', job)`
Immediately before a job begins to execute.
### `q.emit('success', result, job)`
After a job executes its callback.
### `q.emit('error', err, job)`
After a job passes an error to its callback.
### `q.emit('timeout', continue, job)`
After `q.timeout` milliseconds have elapsed and a job has not executed its callback.
### `q.emit('end'[, err])`
After all jobs have been processed
## Releases
The latest stable release is published to [npm](http://npmjs.org/queue). Abbreviated changelog below:
* [6.0](https://github.com/jessetane/queue/archive/6.0.1.tar.gz)
* Add `start` event before job begins (@joelgriffith)
* Add `timeout` property on a job to override the queue's timeout (@joelgriffith)
* [5.0](https://github.com/jessetane/queue/archive/5.0.0.tar.gz)
* Updated TypeScript bindings (@Codex-)
* [4.4](https://github.com/jessetane/queue/archive/4.4.0.tar.gz)
* Add results feature
* [4.3](https://github.com/jessetane/queue/archive/4.3.0.tar.gz)
* Add promise support (@kwolfy)
* [4.2](https://github.com/jessetane/queue/archive/4.2.0.tar.gz)
* Unref timers on end
* [4.1](https://github.com/jessetane/queue/archive/4.1.0.tar.gz)
* Add autostart feature
* [4.0](https://github.com/jessetane/queue/archive/4.0.0.tar.gz)
* Change license to MIT
* [3.1.x](https://github.com/jessetane/queue/archive/3.0.6.tar.gz)
* Add .npmignore
* [3.0.x](https://github.com/jessetane/queue/archive/3.0.6.tar.gz)
* Change the default concurrency to `Infinity`
* Allow `q.start()` to accept an optional callback executed on `q.emit('end')`
* [2.x](https://github.com/jessetane/queue/archive/2.2.0.tar.gz)
* Major api changes / not backwards compatible with 1.x
* [1.x](https://github.com/jessetane/queue/archive/1.0.2.tar.gz)
* Early prototype
## License
Copyright © 2014 Jesse Tane <jesse.tane@gmail.com>
This work is free. You can redistribute it and/or modify it under the
terms of the [MIT License](https://opensource.org/licenses/MIT).
See LICENSE for full details.