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

@edge-runtime/format

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edge-runtime/format - npm Package Compare versions

Comparing version 1.1.0-beta.19 to 1.1.0-beta.20

62

dist/index.js

@@ -75,2 +75,11 @@ "use strict";

}
const symbols = Object.getOwnPropertySymbols(value);
if (symbols.length > 0) {
symbols.forEach((symbol) => {
const obj = value;
const symbolKey = `[${symbol.toString()}]`;
obj[symbolKey] = obj[symbol];
delete obj[symbol];
});
}
const keys = ctx.showHidden

@@ -98,4 +107,6 @@ ? Object.getOwnPropertyNames(value)

}
const isValueFunction = kind(value, 'function');
const isValueArray = Array.isArray(value);
let base = '';
if (kind(value, 'function')) {
if (isValueFunction) {
base = `[Function${value.name ? ': ' + value.name : ''}]`;

@@ -115,4 +126,8 @@ }

}
const braces = Array.isArray(value) ? ['[', ']'] : ['{', '}'];
if (keys.length === 0 && (!Array.isArray(value) || value.length === 0)) {
const braces = isValueArray
? ['[', ']']
: isValueFunction
? ['', '']
: ['{', '}'];
if (keys.length === 0 && (!isValueArray || value.length === 0)) {
return braces[0] + base + braces[1];

@@ -126,7 +141,7 @@ }

ctx.seen.push(value);
const output = Array.isArray(value)
let output = isValueArray
? formatArray(ctx, value, recurseTimes, visibleKeys, keys)
: keys.map((key) => formatProperty(ctx, value, recurseTimes, visibleKeys, key, false));
ctx.seen.pop();
return reduceToSingleString(output, base, braces);
return reduceToSingleString(output, base, braces, isValueFunction);
}

@@ -137,3 +152,3 @@ function inspect(value, opts) {

}
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, isArray) {
let name;

@@ -159,3 +174,3 @@ let str;

if (str.indexOf('\n') > -1) {
if (array) {
if (isArray) {
str = str

@@ -182,17 +197,7 @@ .split('\n')

if (name === undefined) {
if (array && key.match(/^\d+$/)) {
if (isArray && key.match(/^\d+$/)) {
return str;
}
name = JSON.stringify('' + key);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.slice(1, -1);
}
else {
name = name
.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'");
}
}
return `${name}: ${str}`;
return `${key}: ${str}`;
}

@@ -261,3 +266,3 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {

}
function reduceToSingleString(output, base, braces) {
function reduceToSingleString(output, base, braces, isValueFunction) {
const length = output.reduce((prev, cur) => {

@@ -267,10 +272,19 @@ return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;

if (length > 60) {
const prefix = isValueFunction ? ' {' : '';
const suffix = isValueFunction ? '\n}' : ' ';
return (braces[0] +
(base === '' ? '' : base + '\n ') +
(base === '' ? '' : base + prefix + '\n ') +
' ' +
output.join(',\n ') +
' ' +
`${output.join(',\n ')}` +
suffix +
braces[1]);
}
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
const prefix = isValueFunction ? ' { ' : ' ';
const suffix = isValueFunction ? ' } ' : ' ';
return (braces[0] +
base +
prefix +
output.join(', ') +
suffix +
braces[1]).trim();
}

@@ -277,0 +291,0 @@ function safeStringify(object) {

@@ -5,3 +5,3 @@ {

"homepage": "https://github.com/vercel/edge-runtime#readme",
"version": "1.1.0-beta.19",
"version": "1.1.0-beta.20",
"main": "dist/index.js",

@@ -51,3 +51,3 @@ "repository": {

"types": "dist/index.d.ts",
"gitHead": "8b90a6f627231cd85f7e64b97e984b4d1cf8bb5d"
"gitHead": "01e1e2a4bcdd58ba5e3e9813a46c1d144ab95fab"
}

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