Skip to content

Commit e434c7b

Browse files
committed
some cleanup/formatting around onWriteEntry
1 parent cc7ce8e commit e434c7b

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

src/pack.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ export class Pack
9191
filter: Exclude<TarOptions['filter'], undefined>
9292
jobs: number;
9393

94-
[WRITEENTRYCLASS]: typeof WriteEntry | typeof WriteEntrySync;
95-
onWriteEntry?: (entry: WriteEntry) => void
94+
[WRITEENTRYCLASS]: typeof WriteEntry | typeof WriteEntrySync
95+
onWriteEntry?: (entry: WriteEntry) => void;
9696
[QUEUE]: Yallist<PackJob>;
9797
[JOBS]: number = 0;
9898
[PROCESSING]: boolean = false;
@@ -387,9 +387,13 @@ export class Pack
387387
[ENTRY](job: PackJob) {
388388
this[JOBS] += 1
389389
try {
390-
const e = new this[WRITEENTRYCLASS](job.path, this[ENTRYOPT](job))
390+
const e = new this[WRITEENTRYCLASS](
391+
job.path,
392+
this[ENTRYOPT](job),
393+
)
391394
this.onWriteEntry?.(e)
392-
return e.on('end', () => this[JOBDONE](job))
395+
return e
396+
.on('end', () => this[JOBDONE](job))
393397
.on('error', er => this.emit('error', er))
394398
} catch (er) {
395399
this.emit('error', er)

test/list.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ t.test('basic', t => {
3434
t.test('file maxReadSize=' + maxReadSize, t => {
3535
t.test('sync', t => {
3636
const actual: string[] = []
37-
const onReadEntry = (entry: ReadEntry) => actual.push(entry.path)
37+
const onReadEntry = (entry: ReadEntry) =>
38+
actual.push(entry.path)
3839
list({
3940
file: file,
4041
sync: true,
@@ -46,7 +47,8 @@ t.test('basic', t => {
4647

4748
t.test('async promise', async t => {
4849
const actual: string[] = []
49-
const onReadEntry = (entry: ReadEntry) => actual.push(entry.path)
50+
const onReadEntry = (entry: ReadEntry) =>
51+
actual.push(entry.path)
5052
return await list({
5153
file,
5254
onReadEntry,
@@ -56,7 +58,8 @@ t.test('basic', t => {
5658

5759
t.test('async cb', t => {
5860
const actual: string[] = []
59-
const onReadEntry = (entry: ReadEntry) => actual.push(entry.path)
61+
const onReadEntry = (entry: ReadEntry) =>
62+
actual.push(entry.path)
6063
list(
6164
{
6265
file: file,
@@ -79,15 +82,17 @@ t.test('basic', t => {
7982
t.test('stream', t => {
8083
t.test('sync', t => {
8184
const actual: string[] = []
82-
const onReadEntry = (entry: ReadEntry) => actual.push(entry.path)
85+
const onReadEntry = (entry: ReadEntry) =>
86+
actual.push(entry.path)
8387
const l = list({ sync: true, onReadEntry })
8488
l.end(fs.readFileSync(file))
8589
return check(actual, t)
8690
})
8791

8892
t.test('async', t => {
8993
const actual: string[] = []
90-
const onReadEntry = (entry: ReadEntry) => actual.push(entry.path)
94+
const onReadEntry = (entry: ReadEntry) =>
95+
actual.push(entry.path)
9196
const l = list()
9297
l.on('entry', onReadEntry)
9398
l.on('end', _ => check(actual, t).then(_ => t.end()))
@@ -130,7 +135,8 @@ t.test('basic', t => {
130135
t.test('no filter function, stream', t => {
131136
const check = () => t.same(actual, expect)
132137
const actual: string[] = []
133-
const onReadEntry = (entry: ReadEntry) => actual.push(entry.path)
138+
const onReadEntry = (entry: ReadEntry) =>
139+
actual.push(entry.path)
134140
fs.createReadStream(file).pipe(
135141
list(fileList)
136142
.on('entry', onReadEntry)

test/pack.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ t.test('pack a file', t => {
9999
)
100100
const hs = new Header(sync)
101101
t.match(hs, expect)
102-
t.strictSame(seen.map(e => e.path), ['one-byte.txt'])
102+
t.strictSame(
103+
seen.map(e => e.path),
104+
['one-byte.txt'],
105+
)
103106
t.end()
104107
})
105108
})

0 commit comments

Comments
 (0)