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

pouchdb-json

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pouchdb-json - npm Package Compare versions

Comparing version 6.0.7 to 6.1.0

21

lib/index.js

@@ -9,3 +9,6 @@ 'use strict';

function slowJsonParse(str) {
function safeJsonParse(str) {
// This try/catch guards against stack overflow errors.
// JSON.parse() is faster than vuvuzela.parse() but vuvuzela
// cannot overflow.
try {

@@ -19,18 +22,2 @@ return JSON.parse(str);

function safeJsonParse(str) {
// try/catch is deoptimized in V8, leading to slower
// times than we'd like to have. Most documents are _not_
// huge, and do not require a slower code path just to parse them.
// We can be pretty sure that a document under 50000 characters
// will not be so deeply nested as to throw a stack overflow error
// (depends on the engine and available memory, though, so this is
// just a hunch). 50000 was chosen based on the average length
// of this string in our test suite, to try to find a number that covers
// most of our test cases (26 over this size, 26378 under it).
if (str.length < 50000) {
return JSON.parse(str);
}
return slowJsonParse(str);
}
function safeJsonStringify(json) {

@@ -37,0 +24,0 @@ try {

2

package.json
{
"name": "pouchdb-json",
"version": "6.0.7",
"version": "6.1.0",
"description": "PouchDB utilities for safely stringifying and parsing JSON.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

import vuvuzela from 'vuvuzela';
function slowJsonParse(str) {
function safeJsonParse(str) {
// This try/catch guards against stack overflow errors.
// JSON.parse() is faster than vuvuzela.parse() but vuvuzela
// cannot overflow.
try {

@@ -12,18 +15,2 @@ return JSON.parse(str);

function safeJsonParse(str) {
// try/catch is deoptimized in V8, leading to slower
// times than we'd like to have. Most documents are _not_
// huge, and do not require a slower code path just to parse them.
// We can be pretty sure that a document under 50000 characters
// will not be so deeply nested as to throw a stack overflow error
// (depends on the engine and available memory, though, so this is
// just a hunch). 50000 was chosen based on the average length
// of this string in our test suite, to try to find a number that covers
// most of our test cases (26 over this size, 26378 under it).
if (str.length < 50000) {
return JSON.parse(str);
}
return slowJsonParse(str);
}
export default safeJsonParse;
export default safeJsonParse;
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