Skip to content

Commit 7911b84

Browse files
committed
fix: lint
1 parent e6a5a5b commit 7911b84

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

src/Generator.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ import * as utils from './utils';
99
* can create three kinds of headers: FILE, DIRECTORY, and EXTENDED. The file and
1010
* directory is expected, but the extended header is able to store additional
1111
* metadata that does not fit in the standard header.
12-
*
12+
*
1313
* This class can also be used to generate data chunks padded to 512 bytes. Note
1414
* that the chunk size shouldn't exceed 512 bytes.
15-
*
15+
*
1616
* Note that the generator maintains an internal state and must be used for
1717
* operations like generating data chunks, end chunks, or headers, otherwise an
1818
* error will be thrown.
19-
*
19+
*
2020
* For reference, this is the structure of a tar header.
21-
*
21+
*
2222
* | Start | Size | Description |
2323
* |--------|------|-----------------------------------------------------------|
2424
* | 0 | 100 | File name (first 100 bytes) |
@@ -51,17 +51,17 @@ import * as utils from './utils';
5151
* The device major and minor are specific to linux kernel, which is not
5252
* relevant to this virtual tar implementation. This is the reason these fields
5353
* have been left blank.
54-
*
54+
*
5555
* The data for extended headers is formatted slightly differently, with the
5656
* general format following this structure.
5757
* <size> <key>=<value>\n
58-
*
58+
*
5959
* Here, the <size> stands for the byte length of the entire line (including the
6060
* size number itself, the space, the equals, and the \n). Unlike in regular
6161
* strings, the end marker for a key-value pair is the \n (newline) character.
6262
* Moreover, unlike the USTAR header, the numbers are written in stringified
6363
* decimal format.
64-
*
64+
*
6565
* The key can be any supported metadata key, and the value is binary data
6666
* storing the actual value. These are the currently supported keys for
6767
* the extended metadata:
@@ -135,13 +135,13 @@ class Generator {
135135
* If the file path is longer than 255 characters, then an error will be
136136
* thrown. An extended header needs to be generated first, then the file path
137137
* can be set to an empty string.
138-
*
138+
*
139139
* The content of the file must follow this header in separate chunks.
140-
*
140+
*
141141
* @param filePath the path of the file relative to the tar root
142142
* @param stat the stats of the file
143143
* @returns one 512-byte chunk corresponding to the header
144-
*
144+
*
145145
* @see {@link generateExtended} for generating headers with extended metadata
146146
* @see {@link generateDirectory} for generating directory headers instead
147147
* @see {@link generateData} for generating data chunks
@@ -178,11 +178,11 @@ class Generator {
178178
* the size is ignored and set to 0 for directories. If the file path is longer
179179
* than 255 characters, then an error will be thrown. An extended header needs
180180
* to be generated first, then the file path can be set to an empty string.
181-
*
181+
*
182182
* @param filePath the path of the file relative to the tar root
183183
* @param stat the stats of the file
184184
* @returns one 512-byte chunk corresponding to the header
185-
*
185+
*
186186
* @see {@link generateExtended} for generating headers with extended metadata
187187
* @see {@link generateFile} for generating file headers instead
188188
*/
@@ -207,7 +207,7 @@ class Generator {
207207
* Generates an extended metadata header based on the total size of the data
208208
* following the header. If there is no need for extended metadata, then avoid
209209
* using this, as it would just waste space.
210-
*
210+
*
211211
* @param size the size of the binary data block containing the metadata
212212
* @returns one 512-byte chunk corresponding to the header
213213
*/
@@ -230,13 +230,13 @@ class Generator {
230230
* file size is 1023 bytes, then you need to provide a 512-byte chunk first,
231231
* then provide the remaining 511-byte chunk later. You can not chunk it up
232232
* like sending over the first 100 bytes, then sending over the next 512.
233-
*
233+
*
234234
* This method is used to generate blocks for both a file and the exnteded
235235
* header.
236-
*
236+
*
237237
* @param data a block of binary data (512-bytes at largest)
238238
* @returns one 512-byte padded chunk corresponding to the data block
239-
*
239+
*
240240
* @see {@link generateExtended} for generating headers with extended metadata
241241
* @see {@link generateFile} for generating file headers preceeding data block
242242
*/
@@ -282,7 +282,7 @@ class Generator {
282282
* Generates a null chunk. Two invocations are needed to create a valid
283283
* archive end marker. After two invocations, the generator state will be
284284
* set to ENDED and no further data can be fed through the generator.
285-
*
285+
*
286286
* @returns one 512-byte null chunk
287287
*/
288288
generateEnd(): Uint8Array {

src/Parser.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import * as utils from './utils';
1111
* tokens can be either a header token corresponding to either a file, a
1212
* directory, or an extended header, a data token returning the data, and an end
1313
* token signifiying the ending of the archive.
14-
*
14+
*
1515
* For reference, this is the structure of a tar header.
16-
*
16+
*
1717
* | Start | Size | Description |
1818
* |--------|------|-----------------------------------------------------------|
1919
* | 0 | 100 | File name (first 100 bytes) |
@@ -46,17 +46,17 @@ import * as utils from './utils';
4646
* The device major and minor are specific to linux kernel, which is not
4747
* relevant to this virtual tar implementation. This is the reason these fields
4848
* have been left blank.
49-
*
49+
*
5050
* The data for extended headers is formatted slightly differently, with the
5151
* general format following this structure.
5252
* <size> <key>=<value>\n
53-
*
53+
*
5454
* Here, the <size> stands for the byte length of the entire line (including the
5555
* size number itself, the space, the equals, and the \n). Unlike in regular
5656
* strings, the end marker for a key-value pair is the \n (newline) character.
5757
* Moreover, unlike the USTAR header, the numbers are written in stringified
5858
* decimal format.
59-
*
59+
*
6060
* The key can be any supported metadata key, and the value is binary data
6161
* storing the actual value. These are the currently supported keys for
6262
* the extended metadata:
@@ -132,30 +132,30 @@ class Parser {
132132
* undefined token is only returned when the chunk does not correspond to an
133133
* actual token. For example, the first null chunk in the archive end marker
134134
* will return an undefined. The second null chunk will return an end token.
135-
*
135+
*
136136
* The header token can return different types of headers. The three supported
137137
* headers are FILE, DIRECTORY, and EXTENDED. Note that the file stat is
138138
* returned with each header. It might contain default values if it was not
139139
* set in the header. The default value for strings is '', for numbers is 0,
140140
* and for dates is Date(0), which is 11:00 AM 1 January 1970.
141-
*
141+
*
142142
* Note that extended headers will not be automatically parsed. If some
143143
* metadata was put into the extended header instead, then it will need to be
144144
* parsed separately to get the information out, and the metadata field in the
145145
* header will contain the default value for its type.
146-
*
146+
*
147147
* A data header is pretty simple, containing the bytes of the file. Note that
148148
* this is not aligned to the 512-byte boundary. For example, if a file has
149149
* 513 bytes of data, then the first chunk will return the 512 bytes of data,
150150
* and the next data chunk will return 1 byte, removing the padding. The data
151151
* token also has another field, `end`. This is a boolean which is true when
152152
* the last chunk of data is being sent. The expected token after an ended
153153
* data token is a header or an end token.
154-
*
154+
*
155155
* The end token signifies that the archive has ended. This sets the internal
156156
* state to ENDED, and no further data can be written to it and attempts to
157157
* write any additional data will throw an error.
158-
*
158+
*
159159
* @param data a single 512-byte chunk from the tar file
160160
* @returns a parsed token, or undefined if no tokens can be returned
161161
*/

src/VirtualTar.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,10 @@ class VirtualTar {
498498
} else {
499499
// Token is of type end. Clean up the pending promises then trigger the
500500
// end callback.
501-
this.settled().then(this.endCallback);
501+
(async () => {
502+
await this.settled();
503+
this.endCallback();
504+
})();
502505
}
503506
}
504507
}

0 commit comments

Comments
 (0)