Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clarinet

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clarinet - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

samples/loggly.js

63

clarinet.js

@@ -68,3 +68,3 @@ ;(function (clarinet) {

, NUMBER_DECIMAL_POINT : S++ // .
, NUMBER_DIGIT : S++ // [0-9]
, NUMBER_DIGIT : S++ // [0-9]
};

@@ -126,3 +126,3 @@

}
var stringTokenPattern = /[\\"\n]/g;

@@ -170,2 +170,8 @@

//var Buffer = this.Buffer || function Buffer () {}; // if we don't have Buffers, fake it so we can do `var instanceof Buffer` and not throw an error
this.bytes_remaining = 0; // number of bytes remaining in multi byte utf8 char to read after split boundary
this.bytes_in_sequence = 0; // bytes in multi byte utf8 char to read
this.temp_buffs = { "2": new Buffer(2), "3": new Buffer(3), "4": new Buffer(4) }; // for rebuilding chars split before boundary is reached
this.string = '';
var me = this;

@@ -201,5 +207,42 @@ Stream.apply(me);

CStream.prototype.write = function (data) {
this._parser.write(data.toString());
this.emit("data", data);
return true;
var data = new Buffer(data);
for (var i = 0; i < data.length; i++) {
var n = data[i];
// check for carry over of a multi byte char split between data chunks
// & fill temp buffer it with start of this data chunk up to the boundary limit set in the last iteration
if (this.bytes_remaining > 0) {
for (var j = 0; j < this.bytes_remaining; j++) {
this.temp_buffs[this.bytes_in_sequence][this.bytes_in_sequence - this.bytes_remaining + j] = data[j];
}
this.string = this.temp_buffs[this.bytes_in_sequence].toString();
this.bytes_in_sequence = this.bytes_remaining = 0;
i = i + j - 1;
this._parser.write(this.string);
this.emit("data", this.string);
return true;
} else if (this.bytes_remaining === 0 && n >= 128) { // else if no remainder bytes carried over, parse multi byte (>=128) chars one at a time
if ((n >= 194) && (n <= 223)) this.bytes_in_sequence = 2;
if ((n >= 224) && (n <= 239)) this.bytes_in_sequence = 3;
if ((n >= 240) && (n <= 244)) this.bytes_in_sequence = 4;
if ((this.bytes_in_sequence + i) > data.length) { // if bytes needed to complete char fall outside data length, we have a boundary split
for (var k = 0; k <= (data.length - 1 - i); k++) {
this.temp_buffs[this.bytes_in_sequence][k] = data[i + k]; // fill temp data of correct size with bytes available in this chunk
}
this.bytes_remaining = (i + this.bytes_in_sequence) - data.length;
i = data.length - 1;
} else {
this.string = data.slice(i, (i + this.bytes_in_sequence)).toString();
i = i + this.bytes_in_sequence - 1;
this._parser.write(this.string);
this.emit("data", this.string);
return true;
}
} else {
this._parser.write(data.toString());
this.emit("data", data);
return true;
}
}
};

@@ -250,3 +293,3 @@

function closeNumber(parser) {
if (parser.numberNode)
if (parser.numberNode)
emit(parser, "onvalue", parseFloat(parser.numberNode));

@@ -314,3 +357,3 @@ parser.numberNode = "";

else if (c === "[") parser.state = S.OPEN_ARRAY;
else if (c !== '\r' && c !== '\n' && c !== ' ' && c !== '\t')
else if (c !== '\r' && c !== '\n' && c !== ' ' && c !== '\t')
error(parser, "Non-whitespace before {[.");

@@ -433,3 +476,3 @@ continue;

}
if (c === '\\' && !slashed) {
if (c === '\\' && !slashed) {
slashed = true;

@@ -459,3 +502,3 @@ parser.textNode += chunk.substring(starti, i-1);

}
stringTokenPattern.lastIndex = i;

@@ -559,3 +602,3 @@ var reResult = stringTokenPattern.exec(chunk);

} else if (c==='e' || c==='E') {
if(parser.numberNode.indexOf('e')!==-1 ||
if(parser.numberNode.indexOf('e')!==-1 ||
parser.numberNode.indexOf('E')!==-1 )

@@ -562,0 +605,0 @@ error(parser, 'Invalid number has two exponential');

3

package.json

@@ -9,4 +9,5 @@ { "name" : "clarinet"

, "Roly Fentanes (http://about.me/roly)"
, "John Lancaster (http://jlank.com)"
]
, "version" : "0.7.1"
, "version" : "0.7.2"
, "main" : "./clarinet.js"

@@ -13,0 +14,0 @@ , "homepage" : "https://github.com/dscape/clarinet"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc