Skip to content

Commit eafc4b8

Browse files
committed
remove yallist from parse, but NOT from pack
We actually do lean on the logic of the linked list nodes internal references to keep PackJob tasks in order, even as the head of the list moves on when jobs complete, so a simple Array.shift() isn't sufficient. Close: #401
1 parent d281312 commit eafc4b8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/pack.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ export class Pack
9292

9393
[WRITEENTRYCLASS]: typeof WriteEntry | typeof WriteEntrySync
9494
onWriteEntry?: (entry: WriteEntry) => void;
95+
// Note: we actually DO need a linked list here, because we
96+
// shift() to update the head of the list where we start, but still
97+
// while that happens, need to know what the next item in the queue
98+
// will be. Since we do multiple jobs in parallel, it's not as simple
99+
// as just an Array.shift(), since that would lose the information about
100+
// the next job in the list. We could add a .next field on the PackJob
101+
// class, but then we'd have to be tracking the tail of the queue the
102+
// whole time, and Yallist just does that for us anyway.
95103
[QUEUE]: Yallist<PackJob>;
96104
[JOBS]: number = 0;
97105
[PROCESSING]: boolean = false;

src/parse.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// the full 512 bytes of a header to come in. We will Buffer.concat()
33
// it to the next write(), which is a mem copy, but a small one.
44
//
5-
// this[QUEUE] is a Yallist of entries that haven't been emitted
5+
// this[QUEUE] is a list of entries that haven't been emitted
66
// yet this can only get filled up if the user keeps write()ing after
77
// a write() returns false, or does a write() with more than one entry
88
//
@@ -20,7 +20,6 @@
2020

2121
import { EventEmitter as EE } from 'events'
2222
import { BrotliDecompress, Unzip } from 'minizlib'
23-
import { Yallist } from 'yallist'
2423
import { Header } from './header.js'
2524
import { TarOptions } from './options.js'
2625
import { Pax } from './pax.js'
@@ -79,8 +78,7 @@ export class Parser extends EE implements Warner {
7978
writable: true = true
8079
readable: false = false;
8180

82-
[QUEUE]: Yallist<ReadEntry | [string | symbol, any, any]> =
83-
new Yallist();
81+
[QUEUE]: (ReadEntry | [string | symbol, any, any])[] = [];
8482
[BUFFER]?: Buffer;
8583
[READENTRY]?: ReadEntry;
8684
[WRITEENTRY]?: ReadEntry;

0 commit comments

Comments
 (0)