Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
45
gaia/apps/email/js/ext/imap/protocol/snippetparser.js
Executable file
45
gaia/apps/email/js/ext/imap/protocol/snippetparser.js
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
define(['./textparser'], function($textparser) {
|
||||
|
||||
var TextParser = $textparser.TextParser;
|
||||
|
||||
function bufferAppend(buffer1, buffer2) {
|
||||
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
|
||||
tmp.set(new Uint8Array(buffer1), 0);
|
||||
tmp.set(new Uint8Array(buffer2), buffer1.byteLength);
|
||||
return tmp.buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper around the textparser, accumulates buffer content and returns it as
|
||||
* part of the .complete step.
|
||||
*/
|
||||
function SnippetParser(partDef) {
|
||||
TextParser.apply(this, arguments);
|
||||
}
|
||||
|
||||
SnippetParser.prototype = {
|
||||
parse: function(buffer) {
|
||||
if (!this._buffer) {
|
||||
this._buffer = buffer;
|
||||
} else {
|
||||
this._buffer = bufferAppend(this._buffer, buffer);
|
||||
}
|
||||
|
||||
// do some magic parsing
|
||||
TextParser.prototype.parse.apply(this, arguments);
|
||||
},
|
||||
|
||||
complete: function() {
|
||||
var content =
|
||||
TextParser.prototype.complete.apply(this, arguments);
|
||||
|
||||
content.buffer = this._buffer;
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
SnippetParser: SnippetParser
|
||||
};
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue