@@ -159,7 +159,7 @@ var Queue = class _Queue {
159159 const r = callback ( v ) ;
160160 if ( r !== void 0 ) outQueue . push ( r ) ;
161161 } ;
162- this . map ( c ) . then ( outQueue . end ) ;
162+ void this . map ( c ) . then ( outQueue . end ) ;
163163 return outQueue ;
164164 } ;
165165 /**
@@ -174,7 +174,7 @@ var Queue = class _Queue {
174174 const r = await callback ( v ) ;
175175 if ( r !== void 0 ) outQueue . push ( r ) ;
176176 } ;
177- this [ n === Infinity ? "map" : "mapParallel" ] ( c , n ) . then ( outQueue . end ) ;
177+ void this [ n === Infinity ? "map" : "mapParallel" ] ( c , n ) . then ( outQueue . end ) ;
178178 return outQueue ;
179179 } ;
180180 /**
@@ -191,7 +191,7 @@ var Queue = class _Queue {
191191 else if ( index === 1 ) q2 . push ( value ) ;
192192 else throw new Error ( "Invalid index" ) ;
193193 } ;
194- this . map ( c ) . then ( ( ) => {
194+ void this . map ( c ) . then ( ( ) => {
195195 q1 . end ( ) ;
196196 q2 . end ( ) ;
197197 } ) ;
@@ -205,7 +205,7 @@ var Queue = class _Queue {
205205 batch = ( n ) => {
206206 const outQueue = new _Queue ( ) ;
207207 let buffer = [ ] ;
208- this . map ( ( v ) => {
208+ void this . map ( ( v ) => {
209209 buffer . push ( v ) ;
210210 if ( buffer . length === n ) {
211211 outQueue . push ( buffer ) ;
@@ -223,7 +223,7 @@ var Queue = class _Queue {
223223 */
224224 flat = ( ) => {
225225 const outQueue = new _Queue ( ) ;
226- this . map ( ( v ) => {
226+ void this . map ( ( v ) => {
227227 if ( v instanceof Array ) outQueue . push ( ...v ) ;
228228 else throw new Error ( "Value is not an array" ) ;
229229 } ) . then ( outQueue . end ) ;
@@ -246,7 +246,7 @@ var Queue = class _Queue {
246246 else if ( index === 1 ) q2 . push ( value ) ;
247247 else throw new Error ( "Invalid index" ) ;
248248 } ;
249- this [ n === Infinity ? "map" : "mapParallel" ] ( c , n ) . then ( ( ) => {
249+ void this [ n === Infinity ? "map" : "mapParallel" ] ( c , n ) . then ( ( ) => {
250250 q1 . end ( ) ;
251251 q2 . end ( ) ;
252252 } ) ;
@@ -259,9 +259,24 @@ var Queue = class _Queue {
259259 */
260260 umerge = ( q ) => {
261261 const outQueue = new _Queue ( ) ;
262- Promise . all ( [ this , q ] . map ( ( q2 ) => q2 . map ( outQueue . push ) ) ) . then ( outQueue . end ) ;
262+ void Promise . all ( [ this , q ] . map ( ( q2 ) => q2 . map ( outQueue . push ) ) ) . then (
263+ outQueue . end
264+ ) ;
263265 return outQueue ;
264266 } ;
267+ /**
268+ * Creates multiple clones of the queue.
269+ * @param count The number of clone queues to create (default: 1).
270+ * @returns An array of cloned queues.
271+ */
272+ clone = ( count = 1 ) => {
273+ if ( count < 1 ) throw new Error ( "Count must be at least 1" ) ;
274+ const queues = Array . from ( { length : count } , ( ) => new _Queue ( ) ) ;
275+ void this . map ( ( v ) => queues . map ( ( q ) => q . push ( v ) ) ) . then (
276+ ( ) => queues . map ( ( q ) => q . end ( ) )
277+ ) ;
278+ return queues ;
279+ } ;
265280 /**
266281 * Collects all the values in the queue into an array.
267282 * @returns A promise that resolves to an array containing all the values in the queue.
0 commit comments