mirror of
https://github.com/abrendan/MicDropMessages.git
synced 2025-08-26 06:22:02 +02:00
Initial commit
This commit is contained in:
30
node_modules/formidable/lib/json_parser.js
generated
vendored
Normal file
30
node_modules/formidable/lib/json_parser.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
if (global.GENTLY) require = GENTLY.hijack(require);
|
||||
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
function JSONParser(parent) {
|
||||
this.parent = parent;
|
||||
this.chunks = [];
|
||||
this.bytesWritten = 0;
|
||||
}
|
||||
exports.JSONParser = JSONParser;
|
||||
|
||||
JSONParser.prototype.write = function(buffer) {
|
||||
this.bytesWritten += buffer.length;
|
||||
this.chunks.push(buffer);
|
||||
return buffer.length;
|
||||
};
|
||||
|
||||
JSONParser.prototype.end = function() {
|
||||
try {
|
||||
var fields = JSON.parse(Buffer.concat(this.chunks));
|
||||
for (var field in fields) {
|
||||
this.onField(field, fields[field]);
|
||||
}
|
||||
} catch (e) {
|
||||
this.parent.emit('error', e);
|
||||
}
|
||||
this.data = null;
|
||||
|
||||
this.onEnd();
|
||||
};
|
Reference in New Issue
Block a user