Socket
Socket
Sign inDemoInstall

tcompare

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcompare - npm Package Compare versions

Comparing version 3.0.2 to 4.0.0

80

lib/format.js

@@ -83,2 +83,3 @@ class Format {

: this.parent.isSet() ? this.style.setEntrySep()
: this.parent.isString() ? ''
: this.style.pojoEntrySep()

@@ -97,3 +98,3 @@ }

: new Array(this.level).join(this.indent)
const key = this.parent.isSet() || this.parent.isArray() || this.isKey
const key = this.parent.isSet() || this.parent.isArray() || this.parent.isString() || this.isKey
? ''

@@ -130,2 +131,3 @@ : this.printKey(this.key)

case 'string':
return this.string()
case 'boolean':

@@ -270,2 +272,50 @@ case 'number':

string () {
if (this.parent && this.parent.isString())
return this.style.stringLine(this.object)
if (this.stringIsEmpty())
return this.stringEmpty()
if (this.stringIsOneLine())
return this.stringOneLine()
const b = this.stringBody()
return this.stringHead() + b + this.stringTail()
}
isString () {
return typeof this.object === 'string'
}
stringIsEmpty () {
return this.object.length === 0
}
stringEmpty () {
return this.style.stringEmpty()
}
stringIsOneLine () {
return /^[^\n]*\n?$/.test(this.object)
}
stringOneLine () {
return this.style.stringOneLine(this.object)
}
stringHead () {
return this.style.stringHead()
}
stringBody () {
const lines = this.object.split('\n')
const lastLine = lines.pop()
return lines.map((line, num) =>
this.stringLine(num, line + '\n')).join('') +
this.stringLastLine(lines.length - 1, lastLine + '\n')
}
stringLine (key, val) {
return this.stringLastLine(key, val) + this.style.stringLineSep()
}
stringLastLine (key, val) {
return this.child(val, { key }).print()
}
stringTail () {
return this.style.stringTail(this.indentLevel())
}
array () {

@@ -354,4 +404,4 @@ if (this.arrayIsEmpty())

indentLevel () {
return new Array(this.level).join(this.indent)
indentLevel (n = 0) {
return new Array(this.level + n).join(this.indent)
}

@@ -435,2 +485,8 @@

bufferEnd: () => '>',
stringEmpty: () => '""',
stringOneLine: str => JSON.stringify(str),
stringHead: () => 'String(\n',
stringLineSep: () => '\n',
stringLine: str => JSON.stringify(str.replace(/\n$/, '')).slice(1, -1),
stringTail: (indent) => `\n${indent})`,
},

@@ -453,3 +509,3 @@

errorEmpty: (er, cls) => `new ${cls}(${JSON.stringify(er.message)})`,
errorHead: (er, cls) => `Object.assign(new ${cls}(${JSON.stringify(er.message)}), {`,
errorHead: (er, cls) => `Object.assign(new ${cls}(${JSON.stringify(er.message)}), {\n`,
errorTail: () => '})',

@@ -468,3 +524,9 @@ pojoEmpty: cls => '{}',

bufferBody: buf => buf.toString('hex'),
bufferEnd: () => '", "hex")'
bufferEnd: () => '", "hex")',
stringEmpty: () => '""',
stringLineSep: () => ' +\n',
stringLine: str => JSON.stringify(str),
stringOneLine: str => JSON.stringify(str),
stringHead: () => 'String(\n',
stringTail: (indent) => `\n${indent})`,
},

@@ -502,3 +564,9 @@

bufferBody: buf => buf.toString('hex'),
bufferEnd: () => '", "hex")'
bufferEnd: () => '", "hex")',
stringEmpty: () => '""',
stringLineSep: () => '+',
stringLine: str => JSON.stringify(str),
stringOneLine: str => JSON.stringify(str),
stringHead: () => '',
stringTail: () => '',
},

@@ -505,0 +573,0 @@ }

@@ -189,2 +189,3 @@ const Format = require('./format.js')

}
arrayEmpty () { return this.spaceIfNoPref(super.arrayEmpty()) }

@@ -206,2 +207,3 @@ arrayHead () { return this.spaceIfNoPref(super.arrayHead()) }

// don't need a stringIsEmpty, because we will simple diff if !==
mapIsEmpty () {

@@ -208,0 +210,0 @@ return super.mapIsEmpty() && this.expect.size === 0

2

package.json
{
"name": "tcompare",
"version": "3.0.2",
"version": "4.0.0",
"description": "A comprehensive comparison library, for use in test frameworks",

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

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