Permalink
Browse files

0.1.2 release changes

  • Loading branch information...
1 parent e347c32 commit 85f6ad33e2f88fa55ffca6b47cc97e149d827a1e @ditesh committed Dec 20, 2011
Showing with 21 additions and 67 deletions.
  1. +5 −0 CHANGELOG
  2. +5 −0 README.md
  3. +7 −8 demo.js
  4. +3 −58 main.js
  5. +1 −1 package.json
View
@@ -1,3 +1,8 @@
+0.1.2 (Tue Dec 20 18:35:27 MYT 2011):
+
+ * Removed top()
+ * Minor variable renames
+
0.1.1:
* Added changelog
View
@@ -5,11 +5,16 @@ node-mbox is an evented wrapper around mbox files for Node.js. It offers the fol
* mboxrd support (see http://qmail.org/man/man5/mbox.html for information on mboxrd)
* read messages
* delete messages
+* sync to disk
# Usage
See `demo.js`
+# Does this actually work?
+
+Yep. Parsed a 2.2GB mbox file on a slow disk in under a minute with 4KB buffers. It works but it could certainly be faster :)
+
# License
Copyright (C) 2011 Ditesh Shashikant Gathani <ditesh@gathani.org>
View
15 demo.js
@@ -1,6 +1,6 @@
/*
- node-mboxrd demo file
+ node-mbox demo file
Copyright (C) 2011 Ditesh Shashikant Gathani <ditesh@gathani.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -24,12 +24,12 @@
*/
var fs = require("fs");
-var mboxrd = require("./main.js").mboxrd;
+var mbox = require("./main.js").mbox;
var filename = "mbox"; // This is slightly sloppy - be sure to have your mboxrd file named mbox in the current directory
var count = 0;
var fd = fs.openSync(filename, "r+");
-var box = new mboxrd(fd);
+var box = new mbox(fd); // Note that it accepts fd's, and not filenames
box.on("error", function(err) {
@@ -45,7 +45,7 @@ box.on("init", function(status, err) {
if (status) {
count = box.count();
- console.log("Successfully read mboxrd file ("+count+" messages. Getting messaegs (if any).");
+ console.log("Successfully read mboxrd file ("+count+" messages. Getting messages (if any).");
if (count > 0) box.get(0);
@@ -64,11 +64,10 @@ box.on("get", function(status, msgnumber, data) {
if (status === true) {
- console.log("Successfully got msg " + msgnumber + " with data: " + data);
+ console.log("Successfully got msg " + msgnumber);
-// if (msgnumber + 1 < count) box.get(msgnumber+1);
-// else process.exit(0);
- box.delete(0);
+ if (msgnumber + 1 < count) box.get(msgnumber+1);
+ else box.delete(0);
} else {
View
61 main.js
@@ -1,6 +1,6 @@
/*
- node-mboxrd library
+ node-mbox library
Copyright (C) 2011 Ditesh Shashikant Gathani <ditesh@gathani.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -28,7 +28,7 @@ var util = require("util");
var events = require("events");
var unixlib = require("unixlib");
-this.mboxrd = function(fd, options) {
+this.mbox = function(fd, options) {
if (options === undefined) options = {};
@@ -137,61 +137,6 @@ this.mboxrd = function(fd, options) {
};
- this.top = function(msgnumber) {
-
- var self = this;
-
- if (options.init === false) {
-
- self.emit("error", "Specified mboxrd has not been fully parsed yet or there was an error parsing it (trap 'init' event for more details)");
- return false;
-
- }
-
- if (msgnumber > omessages.count || messages.deleted[msgnumber] !== undefined) {
-
- self.emit("top", false, msgnumber);
- return false;
-
- }
-
- var i = 0;
- var lines = 0;
- var bodyend = 0;
- var headersearch = true;
- var message = this.get(msgnumber);
-
- while (i < message.length) {
-
- if (headersearch === true && message[i] === "\n" && message[i+1] === "\n") {
-
- bodyend = i;
- headersearch = false;
-
- } else if (headersearch === false && lines >= linesreq) {
-
- break;
-
- } else if (headersearch === false && message[i] === "\n") {
-
- lines++;
-
- if (lines >= linesreq) {
-
- bodyend = i;
- break;
-
- }
- }
-
- i += 1;
-
- }
-
- self.emit("top", true, msgnumber, message.slice(0, bodyend));
-
- };
-
// Note that this closes fd
this.write = function(filename) {
@@ -344,4 +289,4 @@ this.mboxrd = function(fd, options) {
};
-util.inherits(this.mboxrd, events.EventEmitter);
+util.inherits(this.mbox, events.EventEmitter);
View
@@ -1,6 +1,6 @@
{
"name": "mbox",
- "version": "v0.1.1",
+ "version": "v0.1.2",
"description": "Evented wrapper for mboxrd files",
"homepage": "https://github.com/ditesh/node-mbox",
"keywords": ["mbox", "mboxrd", "mail", "email"],

0 comments on commit 85f6ad3

Please sign in to comment.