Socket
Socket
Sign inDemoInstall

json-parse-even-better-errors

Package Overview
Dependencies
0
Maintainers
6
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.0 to 2.3.1

9

index.js

@@ -69,3 +69,6 @@ 'use strict'

// things other than objects and arrays aren't indented, so ignore those
// Important: in both of these regexps, the $1 capture group is the newline
// or undefined, and the $2 capture group is the indent, or undefined.
const formatRE = /^\s*[{\[]((?:\r?\n)+)([\s\t]*)/
const emptyRE = /^(?:\{\}|\[\])((?:\r?\n)+)?$/

@@ -81,3 +84,7 @@ const parseJson = (txt, reviver, context) => {

// JSON.stringify ignores symbols, so this is reasonably safe.
const [, newline, indent] = parseText.match(formatRE) || [, '', '']
// if the string is '{}' or '[]', then use the default 2-space indent.
const [, newline = '\n', indent = ' '] = parseText.match(emptyRE) ||
parseText.match(formatRE) ||
[, '', '']
const result = JSON.parse(parseText, reviver)

@@ -84,0 +91,0 @@ if (result && typeof result === 'object') {

2

LICENSE.md
Copyright 2017 Kat Marchán
Copyright npm, Inc. and Contributors
Copyright npm, Inc.

@@ -4,0 +4,0 @@ Permission is hereby granted, free of charge, to any person obtaining a

{
"name": "json-parse-even-better-errors",
"version": "2.3.0",
"version": "2.3.1",
"description": "JSON.parse with context information on error",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc