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

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 4.0.1 to 4.1.0

30

lib/format.js

@@ -365,2 +365,26 @@ class Format {

pojoKeys (obj) {
if (this.options.includeEnumerable) {
const keys = []
for (const i in (obj || this.object)) {
keys.push(i)
}
return keys
} else if (this.options.includeGetters) {
const own = new Set(Object.keys(obj || this.object))
const proto = Object.getPrototypeOf(obj || this.object)
if (proto) {
const desc = Object.getOwnPropertyDescriptors(proto)
for (const [name, prop] of Object.entries(desc)) {
if (prop.enumerable && typeof prop.get === 'function') {
// public wrappers around internal things are worth showing
own.add(name)
}
}
}
return Array.from(own)
} else
return Object.keys(obj || this.object)
}
pojo () {

@@ -373,4 +397,4 @@ // get the body first so the id can be seen

}
pojoIsEmpty () {
return Object.keys(this.object).length === 0
pojoIsEmpty (obj) {
return this.pojoKeys(obj).length === 0
}

@@ -392,3 +416,3 @@ pojoEmpty () {

pojoEntries (object) {
const ent = Object.entries(object)
const ent = this.pojoKeys(object).map(k => [k, object[k]])
return this.sort ? ent.sort((a, b) => a[0].localeCompare(b[0])) : ent

@@ -395,0 +419,0 @@ }

4

lib/has.js

@@ -43,3 +43,3 @@ const Same = require('./same.js')

pojoIsEmpty () {
return Object.keys(this.expect).length === 0
return this.pojoExpectIsEmpty()
}

@@ -148,3 +148,3 @@ arrayIsEmpty () {

let out = this.pojoBody()
let expKeys = Object.keys(this.expect)
let expKeys = this.pojoKeys(this.expect)

@@ -151,0 +151,0 @@ if (expKeys.indexOf('name') === -1 && this.expect.name) {

const Format = require('./format.js')
const frag = require('diff-frag')
const jsdiff = require('diff')

@@ -215,4 +214,7 @@

pojoIsEmpty () {
return super.pojoIsEmpty() && Object.keys(this.expect).length === 0
return super.pojoIsEmpty() && this.pojoExpectIsEmpty()
}
pojoExpectIsEmpty () {
return super.pojoIsEmpty(this.expect)
}
arrayIsEmpty () {

@@ -380,4 +382,4 @@ return super.arrayIsEmpty() && this.expect.length === 0

let out = this.pojoBody()
let objKeys = Object.keys(this.object)
let expKeys = Object.keys(this.expect)
let objKeys = this.pojoKeys()
let expKeys = this.pojoKeys(this.expect)
// catch 2 often non-enumerable but very important items

@@ -384,0 +386,0 @@ if (objKeys.indexOf('name') === -1 &&

{
"name": "tcompare",
"version": "4.0.1",
"version": "4.1.0",
"description": "A comprehensive comparison library, for use in test frameworks",

@@ -30,5 +30,3 @@ "main": "index.js",

},
"dependencies": {
"diff-frag": "^1.0.1"
}
"dependencies": {}
}

@@ -66,2 +66,15 @@ # tcompare

* `includeEnumerable` - Set to `true` to walk over _all_ enumerable
properties of a given object when comparing or formatting, rather than
the default of only showing enumerable own-properties. Note that
calling getter functions may be hazardous, as they may trigger
side-effects.
* `includeGetters` - Set to `true` to walk over all enumerable getters
on an object's prototype (but not from further down the prototype
chain), in addition to own-properties. This is useful in cases where
you want to compare or print an object with enumerable getters that
return internal values in a read-only manner. Note that calling
getter functions can be hazardous, as they may trigger side-effects.
* `sort` - Set to `true` to sort object keys. This is important when

@@ -68,0 +81,0 @@ serializing in a deterministic way.

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