@@ -243,26 +243,38 @@ const zipped = fflate.zipSync({
243243 ' dir1' : {
244244 ' nested' : {
245245 // You can use Unicode in filenames
246- ' 你好.txt' : strToU8 (' Hey there!' )
246+ ' 你好.txt' : fflate . strToU8 (' Hey there!' )
247247 },
248248 // You can also manually write out a directory path
249249 ' other/tmp.txt' : new Uint8Array ([97 , 98 , 99 , 100 ])
250250 },
251+
251252 // You can also provide compression options
252253 ' massiveImage.bmp' : [aMassiveFile, {
253254 level: 9 ,
254- mem: 12 ,
255- // ZIP-specific: mtime works here too, defaults to current time
256- mtime: new Date (' 10/20/2020' )
255+ mem: 12
257256 }],
258257 // PNG is pre-compressed; no need to waste time
259- ' superTinyFile.png' : [aPNGFile, { level: 0 }]
258+ ' superTinyFile.png' : [aPNGFile, { level: 0 }],
259+
260+ // Directories take options too
261+ ' exec' : [{
262+ ' hello.sh' : [fflate .strToU8 (' echo hello world' ), {
263+ // ZIP only: Set the operating system to Unix
264+ os: 3 ,
265+ // ZIP only: Make this file executable on Unix
266+ attrs: 0o755 << 16
267+ }]
268+ }, {
269+ // ZIP and GZIP support mtime (defaults to current time)
270+ mtime: new Date (' 10/20/2020' )
271+ }]
260272}, {
261273 // These options are the defaults for all files, but file-specific
262274 // options take precedence.
263275 level: 1 ,
264- // Obfuscate mtime by default
265- mtime: 0
276+ // Obfuscate last modified time by default
277+ mtime: new Date ( ' 1/1/1980 ' )
266278});
267279
268280// If you write the zipped data to myzip.zip and unzip, the folder
@@ -442,8 +454,7 @@ gzs.terminate();
442454zip ({ f1: aMassiveFile, ' f2.txt' : anotherMassiveFile }, {
443455 // The options object is still optional, you can still do just
444456 // zip(archive, callback)
445- level: 6 ,
446- mtime: 0
457+ level: 6
447458}, (err , data ) => {
448459 // Save the ZIP file
449460});
0 commit comments