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

clarinet

Package Overview
Dependencies
Maintainers
3
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.11.0 to 0.12.0

31

clarinet.js

@@ -30,3 +30,6 @@ ;(function (clarinet) {

var buffers = [ "textNode", "numberNode" ]
var buffers = {
textNode: undefined,
numberNode: ""
}
, streamWraps = clarinet.EVENTS.filter(function (ev) {

@@ -97,6 +100,6 @@ return ev !== "error" && ev !== "end";

;
for (var i = 0, l = buffers.length; i < l; i ++) {
var len = parser[buffers[i]].length;
for (var buffer in buffers) {
var len = parser[buffer] === undefined ? 0 : parser[buffer].length;
if (len > maxAllowed) {
switch (buffers[i]) {
switch (buffer) {
case "text":

@@ -107,3 +110,3 @@ closeText(parser);

default:
error(parser, "Max buffer length exceeded: "+ buffers[i]);
error(parser, "Max buffer length exceeded: "+ buffer);
}

@@ -118,4 +121,4 @@ }

function clearBuffers (parser) {
for (var i = 0, l = buffers.length; i < l; i ++) {
parser[buffers[i]] = "";
for (var buffer in buffers) {
parser[buffer] = buffers[buffer];
}

@@ -299,6 +302,6 @@ }

parser.textNode = textopts(parser.opt, parser.textNode);
if (parser.textNode) {
if (parser.textNode !== undefined) {
emit(parser, (event ? event : "onvalue"), parser.textNode);
}
parser.textNode = "";
parser.textNode = undefined;
}

@@ -313,2 +316,5 @@

function textopts (opt, text) {
if (text === undefined) {
return text;
}
if (opt.trim) text = text.trim();

@@ -466,2 +472,6 @@ if (opt.normalize) text = text.replace(/\s+/g, " ");

case S.STRING:
if (parser.textNode === undefined) {
parser.textNode = "";
}
// thanks thejh, this is an about 50% performance improvement.

@@ -496,5 +506,2 @@ var starti = i-1

parser.position += i - 1 - starti;
if(!parser.textNode) {
emit(parser, "onvalue", "");
}
break;

@@ -501,0 +508,0 @@ }

@@ -11,3 +11,3 @@ {

],
"version": "0.11.0",
"version": "0.12.0",
"main": "./clarinet.js",

@@ -41,3 +41,3 @@ "homepage": "https://github.com/dscape/clarinet",

"scripts": {
"test": "./node_modules/mocha/bin/mocha -r should -t 10000 -s 2000 test/clarinet.js test/npm.js test/utf8-chunks.js test/position.js"
"test": "mocha -r should -t 10000 -s 2000 test/clarinet.js test/npm.js test/utf8-chunks.js test/position.js"
},

@@ -52,3 +52,3 @@ "engines": {

},
"license": "BSD"
"license": "BSD-2-Clause"
}
# clarinet
![NPM Downloads](http://img.shields.io/npm/dm/clarinet.svg?style=flat) ![NPM Version](http://img.shields.io/npm/v/clarinet.svg?style=flat)
![NPM Downloads](http://img.shields.io/npm/dm/clarinet.svg?style=flat) ![NPM Version](http://img.shields.io/npm/v/clarinet.svg?style=flat) [![CDNJS](https://img.shields.io/cdnjs/v/clarinet.svg)](https://cdnjs.com/libraries/clarinet)

@@ -58,3 +58,3 @@ `clarinet` is a sax-like streaming parser for JSON. works in the browser and node.js. `clarinet` is inspired (and forked) from [sax-js][saxjs]. just like you shouldn't use `sax` when you need `dom` you shouldn't use `clarinet` when you need `JSON.parse`. for a more detailed introduction and a performance study please refer to this [article][blog].

parser.onkey = function (key) {
// got a key in an object.
// got a subsequent key in an object.
};

@@ -157,3 +157,3 @@ parser.oncloseobject = function () {

`key` - an object key: argument: key, a string with the current key
`key` - an object key: argument: key, a string with the current key. Not called for first key (use `openobject` for that).

@@ -160,0 +160,0 @@ `closeobject` - indication that an object was closed

Sorry, the diff of this file is not supported yet

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