Permalink
Browse files

Demo

  • Loading branch information...
1 parent fac11e4 commit 3ae67738b3e96c9ffae87bbc2f041224ab4f0bca @janjongboom janjongboom committed Dec 28, 2011
Showing with 33 additions and 0 deletions.
  1. +33 −0 demo.js
View
33 demo.js
@@ -0,0 +1,33 @@
+var fs = require("fs");
+var zip = require("./index");
+
+(function () {
+ var archive = new zip();
+
+ archive.add("hello.txt", new Buffer("Hello world", "utf8"));
+
+ var buffer = archive.toBuffer();
+ fs.writeFile("./test1.zip", buffer, function () {
+ console.log("Finished");
+ });
+})
+
+(function () {
+ var zip = require("./index");
+
+ var archive = new zip();
+ archive.addFiles([
+ { name: "moehah.txt", path: "./test/moehah.txt" },
+ { name: "images/sam.jpg", path: "./test/images.jpg" }
+ ], function () {
+ var buff = archive.toBuffer();
+
+ fs.writeFile("./test_new.zip", buff, function () {
+ console.log("im finished");
+ });
+ }, function (err) {
+ console.log(err);
+ });
+ //archive.add("smile.txt", new Buffer("Smile!", "utf8"));
+
+}())

0 comments on commit 3ae6773

Please sign in to comment.