Skip to content

Commit dd0ad61

Browse files
committed
basic jsdoc pass for ZipArchiveEntry.
1 parent 6fec986 commit dd0ad61

1 file changed

Lines changed: 178 additions & 0 deletions

File tree

lib/archivers/zip/zip-archive-entry.js

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,78 +46,173 @@ var ZipArchiveEntry = module.exports = function(name) {
4646

4747
inherits(ZipArchiveEntry, ArchiveEntry);
4848

49+
/**
50+
* Returns the extra fields related to the entry.
51+
*
52+
* @returns {Buffer}
53+
*/
4954
ZipArchiveEntry.prototype.getCentralDirectoryExtra = function() {
5055
return this.getExtra();
5156
};
5257

58+
/**
59+
* Returns the comment set for the entry.
60+
*
61+
* @returns {string}
62+
*/
5363
ZipArchiveEntry.prototype.getComment = function() {
5464
return this.comment !== null ? this.comment : '';
5565
};
5666

67+
/**
68+
* Returns the compressed size of the entry.
69+
*
70+
* @returns {number}
71+
*/
5772
ZipArchiveEntry.prototype.getCompressedSize = function() {
5873
return this.csize;
5974
};
6075

76+
/**
77+
* Returns the CRC32 digest for the entry.
78+
*
79+
* @returns {number}
80+
*/
6181
ZipArchiveEntry.prototype.getCrc = function() {
6282
return this.crc;
6383
};
6484

85+
/**
86+
* Returns the external file attributes for the entry.
87+
*
88+
* @returns {number}
89+
*/
6590
ZipArchiveEntry.prototype.getExternalAttributes = function() {
6691
return this.exattr;
6792
};
6893

94+
/**
95+
* Returns the extra fields related to the entry.
96+
*
97+
* @returns {Buffer}
98+
*/
6999
ZipArchiveEntry.prototype.getExtra = function() {
70100
return this.extra !== null ? this.extra : constants.EMPTY;
71101
};
72102

103+
/**
104+
* Returns the general purpose bits related to the entry.
105+
*
106+
* @returns {GeneralPurposeBit}
107+
*/
73108
ZipArchiveEntry.prototype.getGeneralPurposeBit = function() {
74109
return this.gpb;
75110
};
76111

112+
/**
113+
* Returns the internal file attributes for the entry.
114+
*
115+
* @returns {number}
116+
*/
77117
ZipArchiveEntry.prototype.getInternalAttributes = function() {
78118
return this.inattr;
79119
};
80120

121+
/**
122+
* Returns the last modified date of the entry.
123+
*
124+
* @returns {number}
125+
*/
81126
ZipArchiveEntry.prototype.getLastModifiedDate = function() {
82127
return this.getTime();
83128
};
84129

130+
/**
131+
* Returns the extra fields related to the entry.
132+
*
133+
* @returns {Buffer}
134+
*/
85135
ZipArchiveEntry.prototype.getLocalFileDataExtra = function() {
86136
return this.getExtra();
87137
};
88138

139+
/**
140+
* Returns the compression method used on the entry.
141+
*
142+
* @returns {number}
143+
*/
89144
ZipArchiveEntry.prototype.getMethod = function() {
90145
return this.method;
91146
};
92147

148+
/**
149+
* Returns the filename of the entry.
150+
*
151+
* @returns {string}
152+
*/
93153
ZipArchiveEntry.prototype.getName = function() {
94154
return this.name;
95155
};
96156

157+
/**
158+
* Returns the platform on which the entry was made.
159+
*
160+
* @returns {number}
161+
*/
97162
ZipArchiveEntry.prototype.getPlatform = function() {
98163
return this.platform;
99164
};
100165

166+
/**
167+
* Returns the size of the entry.
168+
*
169+
* @returns {number}
170+
*/
101171
ZipArchiveEntry.prototype.getSize = function() {
102172
return this.size;
103173
};
104174

175+
/**
176+
* Returns a date object representing the last modified date of the entry.
177+
*
178+
* @returns {number|Date}
179+
*/
105180
ZipArchiveEntry.prototype.getTime = function() {
106181
return this.time !== -1 ? zipUtil.dosToDate(this.time) : -1;
107182
};
108183

184+
/**
185+
* Returns the DOS timestamp for the entry.
186+
*
187+
* @returns {number}
188+
*/
109189
ZipArchiveEntry.prototype.getTimeDos = function() {
110190
return this.time !== -1 ? this.time : 0;
111191
};
112192

193+
/**
194+
* Returns the UNIX file permissions for the entry.
195+
*
196+
* @returns {number}
197+
*/
113198
ZipArchiveEntry.prototype.getUnixMode = function() {
114199
return this.platform !== constants.PLATFORM_UNIX ? 0 : ((this.getExternalAttributes() >> constants.SHORT_SHIFT) & constants.SHORT_MASK);
115200
};
116201

202+
/**
203+
* Returns the version of ZIP needed to extract the entry.
204+
*
205+
* @returns {number}
206+
*/
117207
ZipArchiveEntry.prototype.getVersionNeededToExtract = function() {
118208
return this.minver;
119209
};
120210

211+
/**
212+
* Sets the comment of the entry.
213+
*
214+
* @param comment
215+
*/
121216
ZipArchiveEntry.prototype.setComment = function(comment) {
122217
if (Buffer.byteLength(comment) !== comment.length) {
123218
this.getGeneralPurposeBit().useUTF8ForNames(true);
@@ -126,6 +221,11 @@ ZipArchiveEntry.prototype.setComment = function(comment) {
126221
this.comment = comment;
127222
};
128223

224+
/**
225+
* Sets the compressed size of the entry.
226+
*
227+
* @param size
228+
*/
129229
ZipArchiveEntry.prototype.setCompressedSize = function(size) {
130230
if (size < 0) {
131231
throw new Error('invalid entry compressed size');
@@ -134,6 +234,11 @@ ZipArchiveEntry.prototype.setCompressedSize = function(size) {
134234
this.csize = size;
135235
};
136236

237+
/**
238+
* Sets the checksum of the entry.
239+
*
240+
* @param crc
241+
*/
137242
ZipArchiveEntry.prototype.setCrc = function(crc) {
138243
if (crc < 0) {
139244
throw new Error('invalid entry crc32');
@@ -142,14 +247,29 @@ ZipArchiveEntry.prototype.setCrc = function(crc) {
142247
this.crc = crc;
143248
};
144249

250+
/**
251+
* Sets the external file attributes of the entry.
252+
*
253+
* @param attr
254+
*/
145255
ZipArchiveEntry.prototype.setExternalAttributes = function(attr) {
146256
this.exattr = attr >>> 0;
147257
};
148258

259+
/**
260+
* Sets the extra fields related to the entry.
261+
*
262+
* @param extra
263+
*/
149264
ZipArchiveEntry.prototype.setExtra = function(extra) {
150265
this.extra = extra;
151266
};
152267

268+
/**
269+
* Sets the general purpose bits related to the entry.
270+
*
271+
* @param gpb
272+
*/
153273
ZipArchiveEntry.prototype.setGeneralPurposeBit = function(gpb) {
154274
if (!(gpb instanceof GeneralPurposeBit)) {
155275
throw new Error('invalid entry GeneralPurposeBit');
@@ -158,10 +278,20 @@ ZipArchiveEntry.prototype.setGeneralPurposeBit = function(gpb) {
158278
this.gpb = gpb;
159279
};
160280

281+
/**
282+
* Sets the internal file attributes of the entry.
283+
*
284+
* @param attr
285+
*/
161286
ZipArchiveEntry.prototype.setInternalAttributes = function(attr) {
162287
this.inattr = attr;
163288
};
164289

290+
/**
291+
* Sets the compression method of the entry.
292+
*
293+
* @param method
294+
*/
165295
ZipArchiveEntry.prototype.setMethod = function(method) {
166296
if (method < 0) {
167297
throw new Error('invalid entry compression method');
@@ -170,6 +300,11 @@ ZipArchiveEntry.prototype.setMethod = function(method) {
170300
this.method = method;
171301
};
172302

303+
/**
304+
* Sets the name of the entry.
305+
*
306+
* @param name
307+
*/
173308
ZipArchiveEntry.prototype.setName = function(name) {
174309
name = normalizePath(name, false).replace(/^\w+:/, '').replace(/^(\.\.\/|\/)+/, '');
175310

@@ -180,10 +315,20 @@ ZipArchiveEntry.prototype.setName = function(name) {
180315
this.name = name;
181316
};
182317

318+
/**
319+
* Sets the platform on which the entry was made.
320+
*
321+
* @param platform
322+
*/
183323
ZipArchiveEntry.prototype.setPlatform = function(platform) {
184324
this.platform = platform;
185325
};
186326

327+
/**
328+
* Sets the size of the entry.
329+
*
330+
* @param size
331+
*/
187332
ZipArchiveEntry.prototype.setSize = function(size) {
188333
if (size < 0) {
189334
throw new Error('invalid entry size');
@@ -192,6 +337,12 @@ ZipArchiveEntry.prototype.setSize = function(size) {
192337
this.size = size;
193338
};
194339

340+
/**
341+
* Sets the time of the entry.
342+
*
343+
* @param time
344+
* @param forceLocalTime
345+
*/
195346
ZipArchiveEntry.prototype.setTime = function(time, forceLocalTime) {
196347
if (!(time instanceof Date)) {
197348
throw new Error('invalid entry time');
@@ -200,6 +351,11 @@ ZipArchiveEntry.prototype.setTime = function(time, forceLocalTime) {
200351
this.time = zipUtil.dateToDos(time, forceLocalTime);
201352
};
202353

354+
/**
355+
* Sets the UNIX file permissions for the entry.
356+
*
357+
* @param mode
358+
*/
203359
ZipArchiveEntry.prototype.setUnixMode = function(mode) {
204360
mode |= this.isDirectory() ? constants.S_IFDIR : constants.S_IFREG;
205361

@@ -211,18 +367,40 @@ ZipArchiveEntry.prototype.setUnixMode = function(mode) {
211367
this.platform = constants.PLATFORM_UNIX;
212368
};
213369

370+
/**
371+
* Sets the version of ZIP needed to extract this entry.
372+
*
373+
* @param minver
374+
*/
214375
ZipArchiveEntry.prototype.setVersionNeededToExtract = function(minver) {
215376
this.minver = minver;
216377
};
217378

379+
/**
380+
* Returns true if this entry represents a directory.
381+
*
382+
* @returns {boolean}
383+
*/
218384
ZipArchiveEntry.prototype.isDirectory = function() {
219385
return this.getName().slice(-1) === '/';
220386
};
221387

388+
/**
389+
* Returns true if this entry represents a unix symlink,
390+
* in which case the entry's content contains the target path
391+
* for the symlink.
392+
*
393+
* @returns {boolean}
394+
*/
222395
ZipArchiveEntry.prototype.isUnixSymlink = function() {
223396
return (this.getUnixMode() & UnixStat.FILE_TYPE_FLAG) === UnixStat.LINK_FLAG;
224397
};
225398

399+
/**
400+
* Returns true if this entry is using the ZIP64 extension of ZIP.
401+
*
402+
* @returns {boolean}
403+
*/
226404
ZipArchiveEntry.prototype.isZip64 = function() {
227405
return this.csize > constants.ZIP64_MAGIC || this.size > constants.ZIP64_MAGIC;
228406
};

0 commit comments

Comments
 (0)